Compare commits

...

3 commits

Author SHA1 Message Date
Stéphane Lesimple 0264500d22 fix: bad indent when --indent was != 3 (fixes #19) 2024-04-14 12:43:03 +02:00
Stéphane Lesimple 99a6cfdfd1 chore: perltidy 2024-04-14 12:36:34 +02:00
Stéphane Lesimple f379aeb42f fix: support names with spaces (fixes #20) 2024-04-14 12:36:34 +02:00

View file

@ -213,7 +213,7 @@ sub link2real {
sub pretty_print { sub pretty_print {
my ($raw, $mode) = @_; my ($raw, $mode) = @_;
=cut =comment
debug("pretty_print(@_);"); debug("pretty_print(@_);");
my @c = caller(0); my @c = caller(0);
debug(Dumper(\@c)); debug(Dumper(\@c));
@ -413,7 +413,7 @@ if ($opt_max_name_len > 0 && $opt_max_name_len < 4) {
$opt_max_name_len = 4; $opt_max_name_len = 4;
} }
$opt_indent //= 4; $opt_indent //= 3;
if (defined $opt_profile && $opt_profile !~ /^(raid([0156]|1c[34]|10)|single|dup)$/) { if (defined $opt_profile && $opt_profile !~ /^(raid([0156]|1c[34]|10)|single|dup)$/) {
print STDERR "FATAL: invalid argument for --profile\n"; print STDERR "FATAL: invalid argument for --profile\n";
@ -505,7 +505,7 @@ foreach my $mp (@mountPoints) {
# get filesystems list # get filesystems list
=cut =comment
# btrfs filesystem show # btrfs filesystem show
Label: 'beurre' uuid: 010705d8-430f-4f5b-9315-12df40677e97 Label: 'beurre' uuid: 010705d8-430f-4f5b-9315-12df40677e97
Total devices 4 FS bytes used 18.23MiB Total devices 4 FS bytes used 18.23MiB
@ -718,7 +718,7 @@ foreach my $fuuid (keys %filesystems) {
next; next;
} }
# ID 257 gen 17 cgen 11 parent 5 top level 5 parent_uuid - received_uuid - uuid 9bc4..fd75 path sub1 # ID 257 gen 17 cgen 11 parent 5 top level 5 parent_uuid - received_uuid - uuid 9bc4..fd75 path sub1 with spaces
$vol{$fuuid}{$vuuid}{puuid} = PARENT_UUID_NONE; # old btrfsprogs don't have puuid, set a sane default $vol{$fuuid}{$vuuid}{puuid} = PARENT_UUID_NONE; # old btrfsprogs don't have puuid, set a sane default
/(\s|^)ID (\d+)/ and $vol{$fuuid}{$vuuid}{id} = $2; /(\s|^)ID (\d+)/ and $vol{$fuuid}{$vuuid}{id} = $2;
/(\s|^)gen (\d+)/ and $vol{$fuuid}{$vuuid}{gen} = $2; /(\s|^)gen (\d+)/ and $vol{$fuuid}{$vuuid}{gen} = $2;
@ -727,7 +727,7 @@ foreach my $fuuid (keys %filesystems) {
/(\s|^)top level (\d+)/ and $vol{$fuuid}{$vuuid}{top} = $2; /(\s|^)top level (\d+)/ and $vol{$fuuid}{$vuuid}{top} = $2;
/(\s|^)parent_uuid (\S+)/ and $vol{$fuuid}{$vuuid}{puuid} = $2; /(\s|^)parent_uuid (\S+)/ and $vol{$fuuid}{$vuuid}{puuid} = $2;
/(\s|^)received_uuid (\S+)/ and $vol{$fuuid}{$vuuid}{ruuid} = $2; /(\s|^)received_uuid (\S+)/ and $vol{$fuuid}{$vuuid}{ruuid} = $2;
/(\s|^)path (\S+)/ and $vol{$fuuid}{$vuuid}{path} = $2; /(\s|^)path (.+)/ and $vol{$fuuid}{$vuuid}{path} = $2;
$vol{$fuuid}{$vuuid}{path} =~ s/^<FS_TREE>\///; $vol{$fuuid}{$vuuid}{path} =~ s/^<FS_TREE>\///;
$vol{$fuuid}{$vuuid}{type} = 'subvol'; # by default, will be overriden below if applicable $vol{$fuuid}{$vuuid}{type} = 'subvol'; # by default, will be overriden below if applicable
$vol{$fuuid}{$vuuid}{mode} = 'rw'; # by default, will be overriden below if applicable $vol{$fuuid}{$vuuid}{mode} = 'rw'; # by default, will be overriden below if applicable
@ -739,7 +739,7 @@ foreach my $fuuid (keys %filesystems) {
# now, list only snapshots, we also get their otime for free # now, list only snapshots, we also get their otime for free
$cmd = run_cmd(cmd => [qw{ btrfs subvolume list -us }, $mp]); $cmd = run_cmd(cmd => [qw{ btrfs subvolume list -us }, $mp]);
# ID 694 gen 30002591 cgen 30002589 top level 5 otime 2022-01-02 14:37:14 path test-backup2 # ID 694 gen 30002591 cgen 30002589 top level 5 otime 2022-01-02 14:37:14 path test backup2 with spaces
foreach (@{$cmd->{stdout}}) { foreach (@{$cmd->{stdout}}) {
my ($found, $otime); my ($found, $otime);
/(\s|^)uuid ([0-9a-f-]+)/ and exists $vol{$fuuid}{$2} and $found = $2; /(\s|^)uuid ([0-9a-f-]+)/ and exists $vol{$fuuid}{$2} and $found = $2;
@ -769,7 +769,7 @@ foreach my $fuuid (keys %filesystems) {
# v3.18 (no --raw) # v3.18 (no --raw)
=cut =comment
WARNING: Qgroup data inconsistent, rescan recommended WARNING: Qgroup data inconsistent, rescan recommended
qgroupid rfer excl max_rfer max_excl parent child qgroupid rfer excl max_rfer max_excl parent child
-------- ---- ---- -------- -------- ------ ----- -------- ---- ---- -------- -------- ------ -----
@ -779,7 +779,7 @@ qgroupid rfer excl max_rfer max_excl parent child
# v3.19+ has --raw, and additionally, since v4.1, we get 'none' instead of 0: # v3.19+ has --raw, and additionally, since v4.1, we get 'none' instead of 0:
=cut =comment
qgroupid rfer excl max_rfer max_excl parent child qgroupid rfer excl max_rfer max_excl parent child
-------- ---- ---- -------- -------- ------ ----- -------- ---- ---- -------- -------- ------ -----
0/5 9848498 8015121 none none --- --- 0/5 9848498 8015121 none none --- ---
@ -1002,7 +1002,7 @@ sub longest {
# loop through all the items # loop through all the items
foreach my $item (@orderedAll) { foreach my $item (@orderedAll) {
my $len = ($useDepth ? (($item->{depth} || 0) * 3) : 0); my $len = ($useDepth ? (($item->{depth} || 0) * $opt_indent) : 0);
$len += length($item->{$key} || ''); $len += length($item->{$key} || '');
$longest = $len if $len > $longest; $longest = $len if $len > $longest;
} }