mirror of
https://github.com/speed47/btrfs-list
synced 2024-09-30 04:43:31 +00:00
Compare commits
3 commits
0264500d22
...
f4d929e7ed
Author | SHA1 | Date | |
---|---|---|---|
f4d929e7ed | |||
472c2ecf21 | |||
43c76231d2 |
18
README.md
18
README.md
|
@ -22,15 +22,15 @@ into this:
|
|||
# Usage
|
||||
|
||||
```
|
||||
Usage: btrfs-list [options] [mountpoint]
|
||||
Usage: btrfs-list [options] [mountpoint1 [mountpoint2 [...]]]
|
||||
|
||||
If no [mountpoint] is specified, display info for all btrfs filesystems.
|
||||
If no mountpoints are specified, display info for all btrfs filesystems.
|
||||
|
||||
-h, --help display this message
|
||||
--debug enable debug output
|
||||
-q, --quiet silence the quota disabled & quota rescan warnings
|
||||
--version display version info
|
||||
--color=WHEN colorize the output; WHEN can be 'never',
|
||||
--color WHEN colorize the output; WHEN can be 'never',
|
||||
'always', or 'auto' (default is:
|
||||
colorize if STDOUT is a term)
|
||||
-n, --no-color synonym of --color=never
|
||||
|
@ -39,6 +39,8 @@ If no [mountpoint] is specified, display info for all btrfs filesystems.
|
|||
-r, --raw show raw numbers instead of human-readable
|
||||
--btrfs-binary BIN path to the btrfs binary to use instead of using
|
||||
the first binary found in the PATH
|
||||
--ignore-version-check try to continue even if btrfs-progs seems too old
|
||||
--ignore-root-check try to continue even if we are not root
|
||||
|
||||
-s, --hide-snap hide all snapshots
|
||||
-S, --snap-only only show snapshots
|
||||
|
@ -49,9 +51,10 @@ If no [mountpoint] is specified, display info for all btrfs filesystems.
|
|||
take up more space than SIZE
|
||||
-f, --free-space only show free space on the filesystem
|
||||
|
||||
-p, --profile PROFILE consider data profile as 'dup', 'single', 'raid0',
|
||||
'raid1', 'raid10', 'raid5' or 'raid6', for
|
||||
free space calculation (default: autodetect)
|
||||
-p, --profile PROFILE override data profile detection and consider it
|
||||
as 'dup', 'single', 'raid0', 'raid1',
|
||||
'raid1c3', 'raid1c4', 'raid10', 'raid5' or
|
||||
'raid6' for free space calculation
|
||||
|
||||
-a, --show-all show all information for each item
|
||||
--show-gen show generation of each item
|
||||
|
@ -68,6 +71,9 @@ If no [mountpoint] is specified, display info for all btrfs filesystems.
|
|||
default if STDOUT is NOT a term)
|
||||
--no-wide always truncate uuids on output (useful to
|
||||
override above default)
|
||||
--max-name-len LEN trim long subvol names to LEN. 0 means never trim.
|
||||
Defaults to 80 if STDOUT is a term, 0 otherwise.
|
||||
--indent LEN number of spaces to indent the tree, default: 3.
|
||||
|
||||
SIZE can be a number (in bytes), or a number followed by k, M, G, T or P.
|
||||
```
|
||||
|
|
49
btrfs-list
49
btrfs-list
|
@ -45,13 +45,13 @@ use constant FAKE_ID_GHOST => -2;
|
|||
|
||||
sub help {
|
||||
print <<"EOF";
|
||||
Usage: $0 [options] [mountpoints]
|
||||
Usage: $0 [options] [mountpoint1 [mountpoint2 [...]]]
|
||||
|
||||
If no [mountpoints] are specified, display info for all btrfs filesystems.
|
||||
If no mountpoints are specified, display info for all btrfs filesystems.
|
||||
|
||||
-h, --help display this message
|
||||
--debug enable debug output
|
||||
-q, --quiet silence the quota disabled & quota rescan warnings
|
||||
-q, --quiet silence warnings
|
||||
--version display version info
|
||||
--color WHEN colorize the output; WHEN can be 'never',
|
||||
'always', or 'auto' (default is:
|
||||
|
@ -443,7 +443,7 @@ help() if $opt_help;
|
|||
# check btrfs-progs version
|
||||
|
||||
my $cmd = run_cmd(fatal => 1, cmd => [qw{ btrfs --version }]);
|
||||
my ($version) = $cmd->{stdout}->[0] =~ /v(\d+\.\d+)/;
|
||||
my ($version_verbatim, $version) = $cmd->{stdout}->[0] =~ /v((\d+\.\d+)\S*)/;
|
||||
|
||||
if (version->declare($version)->numify lt version->declare("3.18")->numify && !$opt_ignore_version_check) {
|
||||
print STDERR "FATAL: you're using an old version of btrfs-progs, v$version, "
|
||||
|
@ -652,6 +652,7 @@ foreach my $fuuid (keys %filesystems) {
|
|||
cgen => 0,
|
||||
parent => '-',
|
||||
top => '-', # top_level
|
||||
uuid => $fuuid,
|
||||
puuid => PARENT_UUID_DF, # parent_uuid
|
||||
ruuid => '-', # received_uuid
|
||||
type => 'fs',
|
||||
|
@ -792,6 +793,31 @@ foreach my $fuuid (keys %filesystems) {
|
|||
-d $mp or next;
|
||||
next if $opt_free_space;
|
||||
|
||||
# let's still fill the info for the main volume
|
||||
$vol{$fuuid}{5} = {
|
||||
id => 5,
|
||||
path => "[main]",
|
||||
gen => 0,
|
||||
cgen => 0,
|
||||
parent => '-',
|
||||
top => '-',
|
||||
uuid => '-', # may be filled below
|
||||
puuid => PARENT_UUID_NONE_MAINVOL,
|
||||
ruuid => '-',
|
||||
type => 'mainvol',
|
||||
mode => 'rw',
|
||||
mp => $mp,
|
||||
};
|
||||
|
||||
# grab the uuid of the main volume, note that sometimes there is none, and UUID is reported as '-'
|
||||
# also get the current geenration, and the gen at creation (which should always be 0)
|
||||
$cmd = run_cmd(silent_stderr => 1, cmd => [qw{ btrfs subvolume show -b }, $mp]);
|
||||
foreach (@{$cmd->{stdout}}) {
|
||||
/^\s*UUID:\s*([0-9a-f-]+)/ and $vol{$fuuid}{5}{uuid} = $1;
|
||||
/Generation:\s*(\d+)/ and $vol{$fuuid}{5}{gen} = $1;
|
||||
/Gen at creation:\s*(\d+)/ and $vol{$fuuid}{5}{cgen} = $1;
|
||||
}
|
||||
|
||||
$cmd = run_cmd(silent_stderr => 1, cmd => [qw{ btrfs quota rescan -s }, $mp]);
|
||||
if ($cmd->{stdout}->[0] && $cmd->{stdout}->[0] =~ /operation running|current key/) {
|
||||
print STDERR "WARNING: a quota rescan is running, size information is not correct yet\n" if not $opt_quiet;
|
||||
|
@ -809,21 +835,6 @@ foreach my $fuuid (keys %filesystems) {
|
|||
}
|
||||
} ## end if ($cmd->{status} || ...)
|
||||
|
||||
# let's still fill the info for the main volume
|
||||
$vol{$fuuid}{5} = {
|
||||
id => 5,
|
||||
path => "[main]",
|
||||
gen => 0,
|
||||
cgen => 0,
|
||||
parent => '-',
|
||||
top => '-',
|
||||
puuid => PARENT_UUID_NONE_MAINVOL,
|
||||
ruuid => '-',
|
||||
type => 'mainvol',
|
||||
mode => 'rw',
|
||||
mp => $mp,
|
||||
};
|
||||
|
||||
foreach (@{$cmd->{stdout}}) {
|
||||
if (m{^(\d+)/(\d+)\s+(\S+)\s+(\S+)}) {
|
||||
my ($qid, $id, $rfer, $excl) = ($1, $2, human2raw($3), human2raw($4));
|
||||
|
|
Loading…
Reference in a new issue