mirror of https://github.com/digint/btrbk
btrbk: bugfix: use latest longest match for resolving mount point (e.g. for autofs)
parent
3dc06c8067
commit
37c0e840e9
10
btrbk
10
btrbk
|
@ -1862,9 +1862,6 @@ sub btrfs_mountpoint($)
|
|||
unless($mounts) {
|
||||
$mounts = system_list_mounts($vol);
|
||||
return undef unless($mounts);
|
||||
# sort descending by file length
|
||||
my @sorted = sort { length($b->{file}) <=> length($a->{file}) } @$mounts;
|
||||
$mounts = \@sorted;
|
||||
$mountpoint_cache{$host} = $mounts;
|
||||
}
|
||||
|
||||
|
@ -1875,8 +1872,11 @@ sub btrfs_mountpoint($)
|
|||
my $mnt_path = $_->{file};
|
||||
$mnt_path .= '/' unless($mnt_path =~ /\/$/); # correctly handle root path="/"
|
||||
if($realpath =~ /^\Q$mnt_path\E/) {
|
||||
$mountpoint = $_;
|
||||
last;
|
||||
if((not $mountpoint) || (length($_->{file}) >= length($mountpoint->{file}))) {
|
||||
# pick longest match (last if same size).
|
||||
# NOTE: on duplicate match (mounted multiple times, e.g. autofs), use the latest in list.
|
||||
$mountpoint = $_;
|
||||
}
|
||||
}
|
||||
}
|
||||
unless($mountpoint) {
|
||||
|
|
Loading…
Reference in New Issue