From 24c58f2d973c855cc0af0a12e225fd2f07b342d4 Mon Sep 17 00:00:00 2001 From: Anand Jain Date: Thu, 2 Nov 2023 19:28:19 +0800 Subject: common/btrfs: add helper _has_btrfs_sysfs_feature_attr With this helper, btrfs test cases can now check if a particular feature is implemented in the kernel. Signed-off-by: Anand Jain Reviewed-by: Filipe Manana Signed-off-by: Zorro Lang --- common/btrfs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'common') diff --git a/common/btrfs b/common/btrfs index c3bffd2a..fbc26181 100644 --- a/common/btrfs +++ b/common/btrfs @@ -753,3 +753,15 @@ _require_scratch_enable_simple_quota() _notrun "simple quotas not available" _scratch_unmount } + +_has_btrfs_sysfs_feature_attr() +{ + local feature_attr=$1 + + [ -z $feature_attr ] && \ + _fail "Missing feature name argument for _has_btrfs_sysfs_attr" + + modprobe btrfs &> /dev/null + + test -e /sys/fs/btrfs/features/$feature_attr +} -- cgit v1.2.3