From 30edf5b7669cd8565c41ac72e5a2064060b8c877 Mon Sep 17 00:00:00 2001 From: Axel Burri Date: Fri, 6 Mar 2020 23:13:22 +0100 Subject: [PATCH] btrbk: action ls: fix match on child subvols of "/" If PATH contains double slash (intentional behavior of vinfo_child), the match on root_path fails. Fixed by removing "//" from path. --- btrbk | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/btrbk b/btrbk index a92174c..b3c68b0 100755 --- a/btrbk +++ b/btrbk @@ -5315,7 +5315,7 @@ MAIN: $mountinfo_cache{$root_vol->{MACHINE_ID}} = $mountinfo; } - my @path_hidden; + my @mnt_path_hidden; foreach my $mnt (reverse @$mountinfo) { my $mnt_path = $mnt->{mount_point}; $mnt_path .= '/' unless($mnt_path =~ /\/$/); # append trailing slash @@ -5334,11 +5334,12 @@ MAIN: my $subvol_list = vinfo_subvol_list($vol); foreach my $svol ($vol, @$subvol_list) { my $svol_path = $svol->{PATH}; + $svol_path =~ s/^\/\//\//; # sanitize "//" (see vinfo_child) $svol_path .= '/' unless($svol_path =~ /\/$/); # append trailing slash next unless($svol_path =~ /^\Q$root_path\E/); - if(grep { $svol_path =~ /^\Q$_\E/ } @path_hidden) { + if(grep { $svol_path =~ /^\Q$_\E/ } @mnt_path_hidden) { DEBUG "subvolume is hidden by another mount point: $svol->{PRINT}"; next; } @@ -5358,7 +5359,7 @@ MAIN: } } last if($root_path =~ /^\Q$mnt_path\E/); - push @path_hidden, ($mnt->{mount_point} . '/'); + push @mnt_path_hidden, $mnt_path; } }