From: Baokun Li <libaokun@linux.alibaba.com>
To: linux-ext4@vger.kernel.org
Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz,
yi.zhang@huawei.com, ojaswin@linux.ibm.com,
ritesh.list@gmail.com
Subject: [PATCH e2fsprogs 2/5] fsck: fix -C fd option parsing when fd is a separate argument
Date: Tue, 14 Jul 2026 14:31:33 +0800 [thread overview]
Message-ID: <20260714063136.1284287-3-libaokun@linux.alibaba.com> (raw)
In-Reply-To: <20260714063136.1284287-1-libaokun@linux.alibaba.com>
The e2fsprogs fsck wrapper (misc/fsck.c, installed via make install)
supports the -C option for progress reporting. The fd can be passed
either attached (-C6) or separated (-C 6).
Currently the wrapper handles "-C6" correctly, but fails to handle
"-C 6" properly:
# fsck -h | head -n1
fsck 1.47.4 (6-Mar-2025)
# fsck -C6 -N /dev/sda
[/sbin/fsck.ext4 (1) -- /dev/sda] fsck.ext4 -C6 /dev/sda
# fsck -C 6 -N /dev/sda
[/sbin/fsck.ext4 (1) -- /dev/sda] fsck.ext4 6 -C0 /dev/sda
When "-C 6" is passed, it is parsed as "-C0" with "6" leaked as a
stray argument. This is because in PRS(), the separate-argument branch
uses argv[i] (which is "-C") instead of argv[i+1] (which is "6")
to parse the fd value. string_to_int("-C") returns -1, so progress_fd
stays at 0 and the "6" is never consumed. Later the wrapper generates
"-C0" from progress_fd=0 and the stray "6" is passed before the device.
Fix by using argv[i+1] to correctly parse the separate fd argument.
Note: this is the e2fsprogs fsck wrapper (misc/fsck.c), not the
util-linux fsck wrapper (disk-utils/fsck.c) which handles this
correctly.
Signed-off-by: Baokun Li <libaokun@linux.alibaba.com>
---
misc/fsck.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/misc/fsck.c b/misc/fsck.c
index cb935e1b4b71..318ecfcb4102 100644
--- a/misc/fsck.c
+++ b/misc/fsck.c
@@ -1188,7 +1188,7 @@ static void PRS(int argc, char *argv[])
goto next_arg;
} else if (argc > i + 1 &&
argv[i + 1][0] != '-') {
- progress_fd = string_to_int(argv[i]);
+ progress_fd = string_to_int(argv[i+1]);
if (progress_fd < 0)
progress_fd = 0;
else {
--
2.43.7
next prev parent reply other threads:[~2026-07-14 6:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 6:31 [PATCH e2fsprogs 0/5] fsck: fix stale "bad orphan inode" after fsck runs Baokun Li
2026-07-14 6:31 ` [PATCH e2fsprogs 1/5] fsck: consume -l option instead of passing to e2fsck Baokun Li
2026-07-14 6:31 ` Baokun Li [this message]
2026-07-14 6:31 ` [PATCH e2fsprogs 3/5] e2fsck: flush superblock immediately after orphan cleanup Baokun Li
2026-07-14 6:31 ` [PATCH e2fsprogs 4/5] tests: add fsck option-parsing regression test Baokun Li
2026-07-14 6:31 ` [PATCH e2fsprogs 5/5] tests: add orphan-cleanup flush " Baokun Li
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=20260714063136.1284287-3-libaokun@linux.alibaba.com \
--to=libaokun@linux.alibaba.com \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--cc=tytso@mit.edu \
--cc=yi.zhang@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.