btrbk: cosmetics

pull/30/head
Axel Burri 2015-01-26 17:23:37 +01:00
parent 93ece28ee6
commit 38956cf410
1 changed files with 44 additions and 44 deletions

88
btrbk
View File

@ -186,50 +186,6 @@ sub get_rsh($$)
} }
sub btr_subvolume_detail($;$)
{
my $vol = shift || die;
my $config = shift;
my ($rsh, $real_vol) = get_rsh($vol, $config);
my $ret = run_cmd("$rsh /sbin/btrfs subvolume show $real_vol 2>/dev/null", 1);
if($ret)
{
if($ret eq "$real_vol is btrfs root") {
DEBUG "found btrfs root: $vol";
return { id => 5, is_root => 1 };
}
elsif($ret =~ /^$real_vol/) {
TRACE "btr_detail: found btrfs subvolume: $vol";
my %trans = (
name => "Name",
uuid => "uuid",
parent_uuid => "Parent uuid",
creation_time => "Creation time",
id => "Object ID",
gen => "Generation \\(Gen\\)",
cgen => "Gen at creation",
parent_id => "Parent",
top_level => "Top Level",
flags => "Flags",
);
my %detail;
foreach (keys %trans) {
if($ret =~ /^\s+$trans{$_}:\s+(.*)$/m) {
$detail{$_} = $1;
} else {
WARN "Failed to parse subvolume detail \"$trans{$_}\": $ret";
}
}
DEBUG "parsed " . scalar(keys %detail) . " subvolume detail items: $vol";
TRACE "btr_detail for $vol: " . Dumper \%detail;
return \%detail;
}
}
WARN "Failed to fetch subvolume detail for: $vol";
return undef;
}
sub config_key($$) sub config_key($$)
{ {
my $node = shift || die; my $node = shift || die;
@ -502,6 +458,50 @@ sub btr_filesystem_usage($;$)
} }
sub btr_subvolume_detail($;$)
{
my $vol = shift || die;
my $config = shift;
my ($rsh, $real_vol) = get_rsh($vol, $config);
my $ret = run_cmd("$rsh /sbin/btrfs subvolume show $real_vol 2>/dev/null", 1);
if($ret)
{
if($ret eq "$real_vol is btrfs root") {
DEBUG "found btrfs root: $vol";
return { id => 5, is_root => 1 };
}
elsif($ret =~ /^$real_vol/) {
TRACE "btr_detail: found btrfs subvolume: $vol";
my %trans = (
name => "Name",
uuid => "uuid",
parent_uuid => "Parent uuid",
creation_time => "Creation time",
id => "Object ID",
gen => "Generation \\(Gen\\)",
cgen => "Gen at creation",
parent_id => "Parent",
top_level => "Top Level",
flags => "Flags",
);
my %detail;
foreach (keys %trans) {
if($ret =~ /^\s+$trans{$_}:\s+(.*)$/m) {
$detail{$_} = $1;
} else {
WARN "Failed to parse subvolume detail \"$trans{$_}\": $ret";
}
}
DEBUG "parsed " . scalar(keys %detail) . " subvolume detail items: $vol";
TRACE "btr_detail for $vol: " . Dumper \%detail;
return \%detail;
}
}
WARN "Failed to fetch subvolume detail for: $vol";
return undef;
}
sub btr_subvolume_list($;$@) sub btr_subvolume_list($;$@)
{ {
my $vol = shift || die; my $vol = shift || die;