mirror of https://github.com/digint/btrbk
btrbk: add --rootid command option for "btrfs subvolume show"
parent
1aa0fe1aad
commit
cb5e361f7a
14
btrbk
14
btrbk
|
@ -878,11 +878,14 @@ sub btrfs_filesystem_usage($)
|
|||
# for btrfs root, returns at least: (id is_root)
|
||||
# for btrfs-progs >= 4.1, also returns key: "received_uuid"
|
||||
# if present, also returns (unvalidated) keys: (name creation_time flags)
|
||||
sub btrfs_subvolume_show($)
|
||||
sub btrfs_subvolume_show($;@)
|
||||
{
|
||||
my $vol = shift || die;
|
||||
my %opts = @_;
|
||||
my @cmd_options;
|
||||
push(@cmd_options, '--rootid=' . $opts{rootid}) if($opts{rootid}); # btrfs-progs >= 4.12
|
||||
my $path = $vol->{PATH} // die;
|
||||
my $ret = run_cmd(cmd => vinfo_cmd($vol, "btrfs subvolume show", { unsafe => $path }),
|
||||
my $ret = run_cmd(cmd => vinfo_cmd($vol, "btrfs subvolume show", @cmd_options, { unsafe => $path }),
|
||||
rsh => vinfo_rsh($vol),
|
||||
non_destructive => 1,
|
||||
catch_stderr => 1, # hack for shell-based run_cmd()
|
||||
|
@ -943,7 +946,7 @@ sub btrfs_subvolume_show($)
|
|||
"Top level ID" => "top_level", # btrfs-progs >= 4.1
|
||||
"Flags" => "flags",
|
||||
);
|
||||
foreach (split("\n", $ret)) {
|
||||
foreach (@ret_lines) {
|
||||
next unless /^\s+(.+):\s+(.*)$/;
|
||||
my ($key, $value) = ($1, $2);
|
||||
if($trans{$key}) {
|
||||
|
@ -990,6 +993,11 @@ sub btrfs_subvolume_show($)
|
|||
VINFO(\%detail, "detail") if($loglevel >=4);
|
||||
}
|
||||
|
||||
if($opts{rootid} && ($detail{id} != $opts{rootid})) {
|
||||
ERROR "Failed to parse subvolume detail (rootid mismatch) for: $vol->{PRINT}";
|
||||
return undef;
|
||||
}
|
||||
|
||||
if($detail{id} == 5) {
|
||||
DEBUG "found btrfs root: $vol->{PRINT}";
|
||||
$detail{is_root} = 1;
|
||||
|
|
|
@ -48,7 +48,7 @@ run_cmd()
|
|||
reject_filtered_cmd()
|
||||
{
|
||||
# note that the backslash is NOT a metacharacter in a POSIX bracket expression!
|
||||
option_match='-[a-zA-Z-]+' # matches short as well as long options
|
||||
option_match='-[a-zA-Z0-9=-]+' # matches short as well as long options
|
||||
file_match='[0-9a-zA-Z_@+./-]*' # matches file path (equal to $file_match in btrbk)
|
||||
|
||||
if [[ -n "$restrict_path_list" ]]; then
|
||||
|
|
Loading…
Reference in New Issue