aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcos Paulo de Souza <mpdesouza@suse.com>2020-02-07 10:19:50 -0300
committerEryu Guan <guaneryu@gmail.com>2020-02-17 21:05:57 +0800
commit2f9b4039253d3a6f91cb2a22639a243b5a27e110 (patch)
treeb8cfd4ce0daabe207f0c7ed1092d49ddfdd8db2b
parent0ea2b67b095d95f214551558a6b1fda948d3ba97 (diff)
downloadxfstests-dev-2f9b4039253d3a6f91cb2a22639a243b5a27e110.tar.gz
common/btrfs: Improve _require_btrfs_command
Now _require_btrfs_command can also check for subfuntion options, like "subvolume delete --subvolid". Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
-rw-r--r--common/btrfs13
1 files changed, 11 insertions, 2 deletions
diff --git a/common/btrfs b/common/btrfs
index 85b33e4c..7971c046 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -12,12 +12,14 @@ _btrfs_get_subvolid()
# _require_btrfs_command <command> [<subcommand>|<option>]
# We check for btrfs and (optionally) features of the btrfs command
-# It can both subfunction like "inspect-internal dump-tree" and
-# options like "check --qgroup-report"
+# This function support both subfunction like "inspect-internal dump-tree" and
+# options like "check --qgroup-report", and also subfunction options like
+# "subvolume delete --subvolid"
_require_btrfs_command()
{
local cmd=$1
local param=$2
+ local param_arg=$3
local safe_param
_require_command "$BTRFS_UTIL_PROG" btrfs
@@ -39,6 +41,13 @@ _require_btrfs_command()
$BTRFS_UTIL_PROG $cmd $param --help &> /dev/null
[ $? -eq 0 ] || _notrun "$BTRFS_UTIL_PROG too old (must support $cmd $param)"
+
+ test -z "$param_arg" && return
+
+ # replace leading "-"s for grep
+ safe_param=$(echo $param_arg | sed 's/^-*//')
+ $BTRFS_UTIL_PROG $cmd $param --help | grep -wq $safe_param || \
+ _notrun "$BTRFS_UTIL_PROG too old (must support $cmd $param $param_arg)"
}
# Require extra check on btrfs qgroup numbers