]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common/f2fs: introduce _require_inject_f2fs_command()
authorChao Yu <chao@kernel.org>
Thu, 9 Oct 2025 08:50:43 +0000 (16:50 +0800)
committerZorro Lang <zlang@kernel.org>
Fri, 17 Oct 2025 16:53:53 +0000 (00:53 +0800)
Introduce _require_inject_f2fs_command() to check whether inject.f2fs
supports specific metaarea and member parameters.

Meanwhile, let's check inject.f2fs requirement inside
_require_inject_f2fs_command() for cleanup.

Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Chao Yu <chao@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/f2fs
tests/f2fs/009
tests/f2fs/012
tests/f2fs/019
tests/f2fs/020
tests/f2fs/022

index 4d0d688b0d7f9a0b7467665006cc3558cfca2e40..82d3102ea8fce78f61f343b7b8acdd8402772776 100644 (file)
@@ -69,3 +69,30 @@ _check_f2fs_filesystem()
 
     return 0
 }
+
+# check that inject.f2fs supports to inject specific field in specific meta area
+_require_inject_f2fs_command()
+{
+       _require_command "$F2FS_INJECT_PROG" inject.f2fs
+
+       if [ $# -ne 2 ]; then
+               echo "Usage: _require_inject_f2fs_command metaarea member" 1>&2
+               _exit 1
+       fi
+       metaarea=$1
+       member=$2
+
+       case $metaarea in
+       sb|cp|nat|sit)
+               val=0
+               ;;
+       ssa|node|dent)
+               ;;
+       *)
+               _notrun "unsupport metaarea: $metaarea"
+               ;;
+       esac
+
+       $F2FS_INJECT_PROG "--$metaarea" "$val" "-h" | grep "$member:" > /dev/null || \
+               _notrun "--$metaarea --mb $member support is missing"
+}
index 7333d4845879413eaaf373eebcf7a0dfecd7ca6b..4c179f2dfd90655a08a8cf5aee186fc7f507e1cc 100755 (executable)
@@ -12,7 +12,7 @@
 _begin_fstest auto quick
 
 _require_scratch
-_require_command "$F2FS_INJECT_PROG" inject.f2fs
+_require_inject_f2fs_command node i_links
 _require_command "$(type -P socket)" socket
 
 _fixed_by_git_commit f2fs-tools 958cd6e \
index 7438d9ced40ddad2cabfd1c318d71ab9e1bb85a3..53d54bf6b5cebdf61f75323f70d207bc38606cc6 100755 (executable)
@@ -20,7 +20,7 @@ _fixed_by_kernel_commit 91b587ba79e1 \
 export LC_ALL=C.UTF-8
 _require_scratch_nocheck
 _require_command "$F2FS_IO_PROG" f2fs_io
-_require_command "$F2FS_INJECT_PROG" inject.f2fs
+_require_inject_f2fs_command dent d_hash
 
 #check whether f2fs supports "lookup_mode=x" mount option
 mntopt=""
index 2307bd9602eca7d589eec41e271fee519545af5d..a6e6e38cd763a4b5ec59cb0a40b88882bc4e1bb5 100755 (executable)
@@ -18,7 +18,7 @@ _fixed_by_kernel_commit 77de19b6867f \
        "f2fs: fix to avoid out-of-boundary access in dnode page"
 
 _require_scratch_nocheck
-_require_command "$F2FS_INJECT_PROG" inject.f2fs
+_require_inject_f2fs_command node addr
 
 # remove all mkfs options to avoid layout change of on-disk inode
 export MKFS_OPTIONS=""
index 38bc6582729c91433cb2f184e1ea70e47d307fe4..a693313401f8a60c5439249dea20f50cfa06a533 100755 (executable)
@@ -20,7 +20,7 @@ _fixed_by_kernel_commit 061cf3a84bde \
        "f2fs: fix to do sanity check on ino and xnid"
 
 _require_scratch_nocheck
-_require_command "$F2FS_INJECT_PROG" inject.f2fs
+_require_inject_f2fs_command node i_xattr_nid
 _require_attrs user
 
 # remove all mkfs options to avoid layout change of on-disk inode
index ed3b4f2b0e7c6f1be35b6fcf5a477dd58692b117..48a8386b1a8fb61c7f5b9c13ce9c86282f0fd0d0 100755 (executable)
@@ -19,7 +19,7 @@ _fixed_by_kernel_commit xxxxxxxxxxxx \
        "f2fs: fix to do sanity check on node footer for non inode dnode"
 
 _require_scratch_nocheck
-_require_command "$F2FS_INJECT_PROG" inject.f2fs
+_require_inject_f2fs_command node i_nid
 
 # remove all mkfs options to avoid layout change of on-disk inode
 export MKFS_OPTIONS=""