From 0439e6079feedc487bfd355247d9b6152486097b Mon Sep 17 00:00:00 2001 From: Axel Burri Date: Wed, 22 May 2019 23:02:36 +0200 Subject: [PATCH] btrbk: fix vinfo_resolved Fix for rare cases: - fix for paths named "0" - return undef if not strictly below $vol (or allow_equal is set) --- btrbk | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/btrbk b/btrbk index 08981a7..c7e996e 100755 --- a/btrbk +++ b/btrbk @@ -2779,7 +2779,7 @@ sub vinfo_subvol_list($;@) } -# returns vinfo_child if $node is in tree below $vol, or undef +# returns vinfo_child if $node is in tree below $vol (or equal if allow_equal), or undef sub vinfo_resolved($$;@) { my $node = shift || die; @@ -2792,9 +2792,13 @@ sub vinfo_resolved($$;@) unshift(@path, $nn->{REL_PATH}); $nn = $nn->{TOP_LEVEL}; } + if(scalar(@path) == 0) { + return $vol if($opts{allow_equal} && not defined($vol->{NODE_SUBDIR})); + return undef; + } return undef if($nn->{is_root} && (!$vol->{node}{is_root})); my $jpath = join('/', @path); - if($vol->{NODE_SUBDIR}) { + if(defined($vol->{NODE_SUBDIR})) { return undef unless($jpath =~ s/^\Q$vol->{NODE_SUBDIR}\E\///); } if(defined($opts{btrbk_direct_leaf})) { @@ -2820,7 +2824,7 @@ sub vinfo_resolved_all_mountpoints($$) my $mnt_vol = vinfo($vol->{URL_PREFIX} . $mnt_path, $vol->{CONFIG}); $mnt_vol->{node} = $mnt_node; TRACE "vinfo_resolved_all_mountpoints: trying mountpoint: $mnt_vol->{PRINT}"; - my $vinfo = vinfo_resolved($node, $mnt_vol); + my $vinfo = vinfo_resolved($node, $mnt_vol, allow_equal => 1); return $vinfo if($vinfo); } return undef;