From: Chao Yu <chao@kernel.org>
To: Zorro Lang <zlang@kernel.org>, fstests@vger.kernel.org
Cc: jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net,
Chao Yu <chao@kernel.org>
Subject: [PATCH 3/3] common/f2fs: introduce _require_inject_f2fs_command()
Date: Thu, 9 Oct 2025 16:50:43 +0800 [thread overview]
Message-ID: <20251009085043.16910-3-chao@kernel.org> (raw)
In-Reply-To: <20251009085043.16910-1-chao@kernel.org>
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>
---
common/f2fs | 27 +++++++++++++++++++++++++++
tests/f2fs/009 | 2 +-
tests/f2fs/012 | 2 +-
tests/f2fs/019 | 2 +-
tests/f2fs/020 | 2 +-
tests/f2fs/022 | 2 +-
6 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/common/f2fs b/common/f2fs
index 4d0d688b..82d3102e 100644
--- a/common/f2fs
+++ b/common/f2fs
@@ -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"
+}
diff --git a/tests/f2fs/009 b/tests/f2fs/009
index 7333d484..4c179f2d 100755
--- a/tests/f2fs/009
+++ b/tests/f2fs/009
@@ -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 \
diff --git a/tests/f2fs/012 b/tests/f2fs/012
index 7438d9ce..53d54bf6 100755
--- a/tests/f2fs/012
+++ b/tests/f2fs/012
@@ -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=""
diff --git a/tests/f2fs/019 b/tests/f2fs/019
index 2307bd96..a6e6e38c 100755
--- a/tests/f2fs/019
+++ b/tests/f2fs/019
@@ -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=""
diff --git a/tests/f2fs/020 b/tests/f2fs/020
index 38bc6582..a6933134 100755
--- a/tests/f2fs/020
+++ b/tests/f2fs/020
@@ -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
diff --git a/tests/f2fs/022 b/tests/f2fs/022
index ed3b4f2b..48a8386b 100755
--- a/tests/f2fs/022
+++ b/tests/f2fs/022
@@ -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=""
--
2.40.1
next prev parent reply other threads:[~2025-10-09 9:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-09 8:50 [PATCH 1/3] common/config: source common/f2fs in _source_specific_fs() Chao Yu
2025-10-09 8:50 ` [PATCH 2/3] common/rc: move _check_f2fs_filesystem() to common/f2fs Chao Yu
2025-10-17 16:21 ` Zorro Lang
2025-10-09 8:50 ` Chao Yu [this message]
2025-10-17 16:50 ` [PATCH 3/3] common/f2fs: introduce _require_inject_f2fs_command() Zorro Lang
2025-10-17 16:06 ` [PATCH 1/3] common/config: source common/f2fs in _source_specific_fs() Zorro Lang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251009085043.16910-3-chao@kernel.org \
--to=chao@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=zlang@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox