]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
common/btrfs: add helper _has_btrfs_sysfs_feature_attr
authorAnand Jain <anand.jain@oracle.com>
Thu, 2 Nov 2023 11:28:19 +0000 (19:28 +0800)
committerZorro Lang <zlang@kernel.org>
Thu, 16 Nov 2023 02:42:39 +0000 (10:42 +0800)
With this helper, btrfs test cases can now check if a particular feature
is implemented in the kernel.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/btrfs

index c3bffd2ae3f738ed6f6070e170bd7464003f1d38..fbc26181f7bc5e487d48caa1eca45fcd8ca5230f 100644 (file)
@@ -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
+}