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
8
btrbk
8
btrbk
|
@ -1862,9 +1862,6 @@ sub btrfs_mountpoint($)
|
||||||
unless($mounts) {
|
unless($mounts) {
|
||||||
$mounts = system_list_mounts($vol);
|
$mounts = system_list_mounts($vol);
|
||||||
return undef unless($mounts);
|
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;
|
$mountpoint_cache{$host} = $mounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1875,8 +1872,11 @@ sub btrfs_mountpoint($)
|
||||||
my $mnt_path = $_->{file};
|
my $mnt_path = $_->{file};
|
||||||
$mnt_path .= '/' unless($mnt_path =~ /\/$/); # correctly handle root path="/"
|
$mnt_path .= '/' unless($mnt_path =~ /\/$/); # correctly handle root path="/"
|
||||||
if($realpath =~ /^\Q$mnt_path\E/) {
|
if($realpath =~ /^\Q$mnt_path\E/) {
|
||||||
|
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 = $_;
|
$mountpoint = $_;
|
||||||
last;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unless($mountpoint) {
|
unless($mountpoint) {
|
||||||
|
|
Loading…
Reference in New Issue