From: "Darrick J. Wong" <djwong@kernel.org>
To: Zorro Lang <zlang@redhat.com>
Cc: fstests <fstests@vger.kernel.org>, xfs <linux-xfs@vger.kernel.org>
Subject: [PATCH] fsstress: allow multiple suboptions to -f
Date: Thu, 4 Dec 2025 13:53:17 -0800 [thread overview]
Message-ID: <20251204215317.GE89454@frogsfrogsfrogs> (raw)
From: Darrick J. Wong <djwong@kernel.org>
I got bitten by fsstress's argument parsing recently because it turns
out that if you do:
# fsstress -z -f creat=2,unlink=1
It will ignore everything after the '2' and worse yet it won't tell you
that it's done so unless you happen to pass -S to make it spit out the
frequency table.
Adapt process_freq to tokenize the argument string so that it can handle
a comma-separated list of key-value arguments.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
ltp/fsstress.c | 43 +++++++++++++++++++++++++++++--------------
1 file changed, 29 insertions(+), 14 deletions(-)
diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index 00773cc004bfac..c17ac440414325 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -1792,23 +1792,38 @@ opendir_path(pathname_t *name)
void
process_freq(char *arg)
{
- opdesc_t *p;
- char *s;
+ char *token;
+ char *argstr = strdup(arg);
+ char *tokstr = argstr ? argstr : arg;
- s = strchr(arg, '=');
- if (s == NULL) {
- fprintf(stderr, "bad argument '%s'\n", arg);
- exit(1);
- }
- *s++ = '\0';
- for (p = ops; p < ops_end; p++) {
- if (strcmp(arg, p->name) == 0) {
- p->freq = atoi(s);
- return;
+ while ((token = strtok(tokstr, ",")) != NULL) {
+ opdesc_t *p = ops;
+ char *s = strchr(token, '=');
+ int found = 0;
+
+ if (!s) {
+ fprintf(stderr, "bad argument '%s'\n", token);
+ exit(1);
+ }
+
+ *s = '\0';
+ for (; p < ops_end; p++) {
+ if (strcmp(token, p->name) == 0) {
+ p->freq = atoi(s + 1);
+ found = 1;
+ break;
+ }
}
+
+ if (!found) {
+ fprintf(stderr, "can't find op type %s for -f\n", token);
+ exit(1);
+ }
+
+ tokstr = NULL;
}
- fprintf(stderr, "can't find op type %s for -f\n", arg);
- exit(1);
+
+ free(argstr);
}
int
next reply other threads:[~2025-12-04 21:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-04 21:53 Darrick J. Wong [this message]
2025-12-05 6:16 ` [PATCH] fsstress: allow multiple suboptions to -f 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=20251204215317.GE89454@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=zlang@redhat.com \
/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