mirror of https://github.com/digint/btrbk
btrbk: action ls: allow multiple path arguments; soft fail on errors
parent
73c24e0495
commit
c5b3ebb808
25
btrbk
25
btrbk
|
@ -5038,7 +5038,7 @@ MAIN:
|
|||
elsif ($command eq "ls") {
|
||||
$action_ls = 1;
|
||||
$fallback_default_config = 1;
|
||||
$args_expected_min = $args_expected_max = 1;
|
||||
$args_expected_min = 1;
|
||||
@dir_args = @ARGV;
|
||||
}
|
||||
elsif ($command eq "diff") {
|
||||
|
@ -5290,22 +5290,31 @@ MAIN:
|
|||
#
|
||||
# print accessible subvolumes for local path
|
||||
#
|
||||
my $path = $dir_args[0] || die;
|
||||
my $exit_status = 0;
|
||||
my @data;
|
||||
foreach my $path (@dir_args) {
|
||||
my $root_vol = vinfo($path, $config);
|
||||
|
||||
# map url to real path (we need to match against mount points below)
|
||||
my $root_path = system_realpath($root_vol);
|
||||
unless($root_path) {
|
||||
ERROR "Cannot find real path for: $root_vol->{PATH}", @stderr;
|
||||
exit 1;
|
||||
$exit_status = 1;
|
||||
next;
|
||||
}
|
||||
$root_vol = vinfo($root_path, $config);
|
||||
$root_path .= '/' unless($root_path =~ /\/$/); # append trailing slash
|
||||
|
||||
my $mountinfo = system_list_mountinfo($root_vol) || die;
|
||||
my $mountinfo = $mountinfo_cache{$root_vol->{MACHINE_ID}};
|
||||
unless($mountinfo) {
|
||||
$mountinfo = system_list_mountinfo($root_vol);
|
||||
unless($mountinfo) {
|
||||
$exit_status = 1;
|
||||
next;
|
||||
}
|
||||
$mountinfo_cache{$root_vol->{MACHINE_ID}} = $mountinfo;
|
||||
}
|
||||
|
||||
my @data;
|
||||
my @path_hidden;
|
||||
foreach my $mnt (reverse @$mountinfo) {
|
||||
my $mnt_path = $mnt->{mount_point};
|
||||
|
@ -5318,7 +5327,8 @@ MAIN:
|
|||
my $vol = vinfo($mnt->{mount_point}, $config);
|
||||
unless(vinfo_init_root($vol)) {
|
||||
ERROR "Failed to fetch subvolume detail for: $vol->{PRINT}", @stderr;
|
||||
exit 1;
|
||||
$exit_status = 1;
|
||||
next;
|
||||
}
|
||||
|
||||
my $subvol_list = vinfo_subvol_list($vol);
|
||||
|
@ -5349,6 +5359,7 @@ MAIN:
|
|||
last if($root_path =~ /^\Q$mnt_path\E/);
|
||||
push @path_hidden, ($mnt->{mount_point} . '/');
|
||||
}
|
||||
}
|
||||
|
||||
my @sorted = sort { $a->{path} cmp $b->{path} } @data;
|
||||
if($output_format) {
|
||||
|
@ -5356,7 +5367,7 @@ MAIN:
|
|||
} else {
|
||||
print join("\n", map { $_->{path} } @sorted) . "\n";
|
||||
}
|
||||
exit 0;
|
||||
exit $exit_status;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue