mirror of
https://github.com/speed47/btrfs-list
synced 2024-09-28 20:03:32 +00:00
feat: add --deleted
This commit is contained in:
parent
eaee8d8958
commit
3c30304d7e
36
btrfs-list
36
btrfs-list
|
@ -56,6 +56,7 @@ If no [mountpoint] is specified, display info for all btrfs filesystems.
|
||||||
|
|
||||||
-s, --hide-snap hide all snapshots
|
-s, --hide-snap hide all snapshots
|
||||||
-S, --snap-only only show snapshots
|
-S, --snap-only only show snapshots
|
||||||
|
--deleted show deleted parents of orphaned snapshots
|
||||||
--snap-min-excl SIZE hide snapshots whose exclusively allocated extents
|
--snap-min-excl SIZE hide snapshots whose exclusively allocated extents
|
||||||
take up less space than SIZE
|
take up less space than SIZE
|
||||||
--snap-max-excl SIZE hide snapshots whose exclusively allocated extents
|
--snap-max-excl SIZE hide snapshots whose exclusively allocated extents
|
||||||
|
@ -71,6 +72,7 @@ If no [mountpoint] is specified, display info for all btrfs filesystems.
|
||||||
--show-cgen show generation at creation of each item
|
--show-cgen show generation at creation of each item
|
||||||
--show-id show id of each item
|
--show-id show id of each item
|
||||||
--show-uuid show uuid of each item
|
--show-uuid show uuid of each item
|
||||||
|
--show-puuid show parent uuid of each item
|
||||||
--show-otime show snap creation time
|
--show-otime show snap creation time
|
||||||
|
|
||||||
SIZE can be a number (in bytes), or a number followed by k, M, G, T or P.
|
SIZE can be a number (in bytes), or a number followed by k, M, G, T or P.
|
||||||
|
@ -91,6 +93,7 @@ GetOptions(
|
||||||
'show-cgen' => \my $opt_show_cgen,
|
'show-cgen' => \my $opt_show_cgen,
|
||||||
'show-id' => \my $opt_show_id,
|
'show-id' => \my $opt_show_id,
|
||||||
'show-uuid' => \my $opt_show_uuid,
|
'show-uuid' => \my $opt_show_uuid,
|
||||||
|
'show-puuid' => \my $opt_show_puuid,
|
||||||
'show-otime' => \my $opt_show_otime,
|
'show-otime' => \my $opt_show_otime,
|
||||||
'snap-min-used|snap-min-excl=s' => \my $opt_snap_min_used,
|
'snap-min-used|snap-min-excl=s' => \my $opt_snap_min_used,
|
||||||
'snap-max-used|snap-max-excl=s' => \my $opt_snap_max_used,
|
'snap-max-used|snap-max-excl=s' => \my $opt_snap_max_used,
|
||||||
|
@ -101,6 +104,7 @@ GetOptions(
|
||||||
'p|profile=s' => \my $opt_profile,
|
'p|profile=s' => \my $opt_profile,
|
||||||
'r|raw' => \my $opt_raw,
|
'r|raw' => \my $opt_raw,
|
||||||
'btrfs-binary=s' => \my $opt_btrfs_binary,
|
'btrfs-binary=s' => \my $opt_btrfs_binary,
|
||||||
|
'deleted' => \my $opt_deleted,
|
||||||
) or die "FATAL: Error parsing arguments, aborting\n";
|
) or die "FATAL: Error parsing arguments, aborting\n";
|
||||||
|
|
||||||
sub debug {
|
sub debug {
|
||||||
|
@ -252,6 +256,7 @@ if ($opt_show_all) {
|
||||||
$opt_show_cgen = 1;
|
$opt_show_cgen = 1;
|
||||||
$opt_show_id = 1;
|
$opt_show_id = 1;
|
||||||
$opt_show_uuid = 1;
|
$opt_show_uuid = 1;
|
||||||
|
$opt_show_puuid = 1;
|
||||||
$opt_show_otime = 1;
|
$opt_show_otime = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -691,6 +696,7 @@ sub recursive_add_children_of {
|
||||||
}
|
}
|
||||||
|
|
||||||
my $isFirstFS = 1;
|
my $isFirstFS = 1;
|
||||||
|
$opt_deleted ||= 0;
|
||||||
foreach my $fuuid (sort keys %filesystems) {
|
foreach my $fuuid (sort keys %filesystems) {
|
||||||
@ordered = ();
|
@ordered = ();
|
||||||
%seen = ();
|
%seen = ();
|
||||||
|
@ -729,10 +735,24 @@ foreach my $fuuid (sort keys %filesystems) {
|
||||||
}
|
}
|
||||||
debug(">>> orphan loop on $orphan, no known parent: $no_known_parent");
|
debug(">>> orphan loop on $orphan, no known parent: $no_known_parent");
|
||||||
if ($no_known_parent == 1) {
|
if ($no_known_parent == 1) {
|
||||||
|
if ($opt_deleted) {
|
||||||
|
|
||||||
|
# craft a ghost parent if asked to
|
||||||
|
push @ordered,
|
||||||
|
{
|
||||||
|
type => 'deleted',
|
||||||
|
path => "(deleted)",
|
||||||
|
depth => 1,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
# add the orphan ourselves
|
||||||
push @ordered, $vol{$fuuid}{$orphan};
|
push @ordered, $vol{$fuuid}{$orphan};
|
||||||
$seen{$orphan} = 1;
|
$seen{$orphan} = 1;
|
||||||
$vol{$fuuid}{$orphan}{depth} = 1;
|
$vol{$fuuid}{$orphan}{depth} = 1 + $opt_deleted;
|
||||||
recursive_add_children_of(volumes => $vol{$fuuid}, depth => 2, parentuuid => $orphan);
|
|
||||||
|
# and all the orphans' children, if any
|
||||||
|
recursive_add_children_of(volumes => $vol{$fuuid}, depth => 2 + $opt_deleted, parentuuid => $orphan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -770,6 +790,10 @@ foreach my $fuuid (sort keys %filesystems) {
|
||||||
$format .= "%36s ";
|
$format .= "%36s ";
|
||||||
push @header, qw{ UUID };
|
push @header, qw{ UUID };
|
||||||
}
|
}
|
||||||
|
if ($opt_show_puuid) {
|
||||||
|
$format .= "%36s ";
|
||||||
|
push @header, qw{ PARENT_UUID };
|
||||||
|
}
|
||||||
if ($opt_show_otime) {
|
if ($opt_show_otime) {
|
||||||
$format .= "%20s ";
|
$format .= "%20s ";
|
||||||
push @header, qw{ OTIME };
|
push @header, qw{ OTIME };
|
||||||
|
@ -805,7 +829,7 @@ foreach my $fuuid (sort keys %filesystems) {
|
||||||
if ($opt_snap_max_used) {
|
if ($opt_snap_max_used) {
|
||||||
next if ($type eq 'snap' && $line->{rfer} =~ /^\d+$/ && $line->{excl} > $opt_snap_max_used);
|
next if ($type eq 'snap' && $line->{rfer} =~ /^\d+$/ && $line->{excl} > $opt_snap_max_used);
|
||||||
}
|
}
|
||||||
$line->{mode} eq 'ro' and $type = "ro" . $type;
|
$line->{mode} && $line->{mode} eq 'ro' and $type = "ro" . $type;
|
||||||
my $extra = '';
|
my $extra = '';
|
||||||
if (exists $line->{free}) {
|
if (exists $line->{free}) {
|
||||||
$extra = '(' . $line->{profile} . ', ' . sprintf("%s%s%s%s%s", pretty_print($line->{free}, 2)) . ' free';
|
$extra = '(' . $line->{profile} . ', ' . sprintf("%s%s%s%s%s", pretty_print($line->{free}, 2)) . ' free';
|
||||||
|
@ -818,11 +842,15 @@ foreach my $fuuid (sort keys %filesystems) {
|
||||||
$extra = $line->{mp};
|
$extra = $line->{mp};
|
||||||
}
|
}
|
||||||
$line->{depth} ||= 0;
|
$line->{depth} ||= 0;
|
||||||
|
$line->{id} ||= 0;
|
||||||
|
|
||||||
|
#$line->{id} =~ /^\d+$/ or $line->{id} = '-';
|
||||||
my @fields = " " x ($line->{depth} * 3) . $line->{path};
|
my @fields = " " x ($line->{depth} * 3) . $line->{path};
|
||||||
push @fields, ($line->{id} =~ /^\d+$/ ? $line->{id} : '-') if $opt_show_id;
|
push @fields, $line->{id} || '-' if $opt_show_id;
|
||||||
push @fields, $line->{gen} || '-' if $opt_show_gen;
|
push @fields, $line->{gen} || '-' if $opt_show_gen;
|
||||||
push @fields, $line->{cgen} || '-' if $opt_show_cgen;
|
push @fields, $line->{cgen} || '-' if $opt_show_cgen;
|
||||||
push @fields, $line->{uuid} || '-' if $opt_show_uuid;
|
push @fields, $line->{uuid} || '-' if $opt_show_uuid;
|
||||||
|
push @fields, $line->{puuid} || '-' if $opt_show_puuid;
|
||||||
push @fields, $line->{otime} || '-' if $opt_show_otime;
|
push @fields, $line->{otime} || '-' if $opt_show_otime;
|
||||||
push @fields, $type;
|
push @fields, $type;
|
||||||
push @fields, pretty_print($line->{rfer}, 1) if !$noquota;
|
push @fields, pretty_print($line->{rfer}, 1) if !$noquota;
|
||||||
|
|
Loading…
Reference in a new issue