enh: better output in multi-FS mode

This commit is contained in:
Stéphane Lesimple 2022-01-02 21:54:33 +01:00
parent 4349422f40
commit 1e7b0b1ef0

View file

@ -728,7 +728,7 @@ sub recursive_add_children_of {
return;
}
my $isFirstFS = 1;
my @orderedAll;
$opt_deleted ||= 0;
foreach my $fuuid (sort keys %filesystems) {
@ordered = ();
@ -796,65 +796,66 @@ foreach my $fuuid (sort keys %filesystems) {
push @ordered, $vuuid;
}
# find the longest path (including leading spaces)
my $longestpath = 0;
foreach (@ordered) {
push @orderedAll, @ordered;
}
# find the longest path (including leading spaces)
my $longestpath = 0;
foreach (@orderedAll) {
my $len = ($_->{depth} || 0) * 3;
$len += length($_->{path});
$len > $longestpath and $longestpath = $len;
}
my $pretty_print_size = ($opt_raw ? 16 : 7);
}
my $pretty_print_size = ($opt_raw ? 16 : 7);
my $format = "%-${longestpath}s ";
my @header = qw{ NAME };
if ($opt_show_id) {
my $format = "%-${longestpath}s ";
my @header = qw{ NAME };
if ($opt_show_id) {
$format .= "%5s ";
push @header, qw{ ID };
}
if ($opt_show_toplevel) {
}
if ($opt_show_toplevel) {
$format .= "%6s ";
push @header, qw{ TOPLVL };
}
if ($opt_show_gen) {
}
if ($opt_show_gen) {
$format .= "%8s ";
push @header, qw{ GEN };
}
if ($opt_show_cgen) {
}
if ($opt_show_cgen) {
$format .= "%8s ";
push @header, qw{ CGEN };
}
if ($opt_show_uuid) {
}
if ($opt_show_uuid) {
$format .= "%36s ";
push @header, qw{ UUID };
}
if ($opt_show_puuid) {
}
if ($opt_show_puuid) {
$format .= "%36s ";
push @header, qw{ PARENT_UUID };
}
if ($opt_show_otime) {
}
if ($opt_show_otime) {
$format .= "%20s ";
push @header, qw{ OTIME };
}
$format .= "%8s ";
push @header, qw{ TYPE };
}
$format .= "%8s ";
push @header, qw{ TYPE };
my $noquota = $vol{$fuuid}{df}{noquota} || $opt_free_space;
if (!$noquota) {
my $noquota = $vol{$fuuid}{df}{noquota} || $opt_free_space;
if (!$noquota) {
$format .= "%s%${pretty_print_size}s%s%1s%s ";
push @header, '', 'REFE', 'R', '', '';
push @header, '', 'EXCL', '', '', '', 'MOUNTPOINT';
}
else {
}
else {
push @header, '', 'EXC', 'L', '', '', 'MOUNTPOINT';
}
}
$format .= "%s%${pretty_print_size}s%s%1s%s %s\n";
$format .= "%s%${pretty_print_size}s%s%1s%s %s\n";
print "\n" if (!$isFirstFS);
$isFirstFS = 0;
printf $format, @header if !$opt_no_header;
printf $format, @header if !$opt_no_header;
foreach my $line (@ordered) {
foreach my $line (@orderedAll) {
next if ($opt_hide_snapshots and $line->{type} eq 'snap');
next if ($opt_only_snapshots and $line->{type} ne 'snap');
$line->{rfer} ||= 0;
@ -894,5 +895,4 @@ foreach my $fuuid (sort keys %filesystems) {
push @fields, pretty_print($line->{rfer}, 1) if !$noquota;
push @fields, pretty_print($line->{excl}, 1), $extra;
printf $format, @fields;
}
}