Closed jpluimers closed 6 years ago
I see... that's a pretty old one!
is that on openSUSE? My Debian Stretch is in 4.7.3, and my Arch is on 4.13
Indeed (: It is an openSUSE 13.2 installation that I want to phase out next year.
well, I don't have such old version in my systems, so if anybody wants to adapt this, PRs are welcome
@nachoparker I'd need some help as I'm far from fluent in writing bash
.
It'd basically would come down to finding out which features the btrfs
supports, then adopting the commands because of that.
Can you help me with some code-reviews?
sure,
you can either parse the version ( output of btrfs version
), or just check for an error message, like here
@nachoparker thanks. It doesn't help much that btrfs --version
has changed the format over time. On my systems, I see these:
btrfs-progs v4.13.3
Btrfs v3.12+20131125
What do you see on your systems?
the first type in all my versions
Thanks.
In the mean time, I tried checking on features, but the comparisons fail both using the bash
one and the grep
one.
Do you have an idea why?
Fragment that I changed:
_btrfs_qgroup_show="btrfs qgroup show --si --sort=qgroupid \""$LOCATION\"" 2>&1"
echo "Command: $_btrfs_qgroup_show"
# if we just enabled quota, might have to wait for rescan
#OUT=$( btrfs qgroup show --si --sort=qgroupid "$LOCATION" 2>&1 )
OUT=$( $_btrfs_qgroup_show )
echo "$OUT"
if [[ "$OUT" == *"unrecognized option"* ]]; then
echo "INFO: Legacy btrfs version; trying 'btrfs qgroup show' without '--si'..."
_btrfs_qgroup_show="btrfs qgroup show --sort=qgroupid \""$LOCATION\"" 2>&1"
fi
## This check fails to recognise the failure:
grep -q "unrecognized option" <<< "$OUT" && {
echo "INFO: Legacy btrfs version; trying 'btrfs qgroup show' without '--si'..."
_btrfs_qgroup_show="btrfs qgroup show --sort=qgroupid \""$LOCATION\"" 2>&1"
}
echo "Command: $_btrfs_qgroup_show"
OUT=$( $_btrfs_qgroup_show )
echo "$OUT"
exit 1
Output:
# ./btrfs-du
Command: btrfs qgroup show --si --sort=qgroupid "/" 2>&1
btrfs qgroup show: unrecognized option '--si'
usage: btrfs qgroup show -pcreFf [--sort=qgroupid,rfer,excl,max_rfer,max_excl] <path>
Show subvolume quota groups.
-p print parent qgroup id
-c print child qgroup id
-r print max referenced size of qgroup
-e print max exclusive size of qgroup
-F list all qgroups which impact the given path(include ancestral qgroups)
-f list all qgroups which impact the given path(exclude ancestral qgroups)
--sort=qgroupid,rfer,excl,max_rfer,max_excl
list qgroups in order of qgroupid,rfer,max_rfer or max_excl
you can use '+' or '-' in front of each item.
(+:ascending, -:descending, ascending default)
Command: btrfs qgroup show --si --sort=qgroupid "/" 2>&1
btrfs qgroup show: unrecognized option '--si'
usage: btrfs qgroup show -pcreFf [--sort=qgroupid,rfer,excl,max_rfer,max_excl] <path>
Show subvolume quota groups.
-p print parent qgroup id
-c print child qgroup id
-r print max referenced size of qgroup
-e print max exclusive size of qgroup
-F list all qgroups which impact the given path(include ancestral qgroups)
-f list all qgroups which impact the given path(exclude ancestral qgroups)
--sort=qgroupid,rfer,excl,max_rfer,max_excl
list qgroups in order of qgroupid,rfer,max_rfer or max_excl
you can use '+' or '-' in front of each item.
(+:ascending, -:descending, ascending default)
Found the cause for the last question: you cannot have the 2>&1
bit within a string and later execute it.
@nachoparker can you shoot some comments at https://github.com/jpluimers/btrfs-du/commit/da51a999897bc6e0c0f1c9523bfbd8ad866e9152 ???
on it
Another legacy
btrfs
thing:btrfs qgroup show: unrecognized option '--raw'
Full output:
However, for this version, it looks like the default output already is like
--raw
:Note that this version also lacks support for
--si
: