[PATCH] fsck: add --workers option to configure worker threads
Utkal Singh
singhutkal015 at gmail.com
Sun Mar 22 17:47:06 AEDT 2026
Add a --workers=# command-line option to fsck.erofs to allow users
to configure the number of worker threads used during verification.
Parse the value using strtoul() and validate it against UINT_MAX
before storing it in fsckcfg.nr_workers. Return -EINVAL for invalid
inputs (non-numeric characters or out-of-range values).
Signed-off-by: Utkal Singh <singhutkal015 at gmail.com>
---
fsck/main.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/fsck/main.c b/fsck/main.c
index 16cc627..37e21f4 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -4,6 +4,7 @@
* Author: Daeho Jeong <daehojeong at google.com>
*/
#include <stdlib.h>
+#include <limits.h>
#include <getopt.h>
#include <time.h>
#include <utime.h>
@@ -42,6 +43,7 @@ struct erofsfsck_cfg {
erofs_nid_t nid;
const char *inode_path;
bool nosbcrc;
+ unsigned int nr_workers;
};
static struct erofsfsck_cfg fsckcfg;
@@ -64,6 +66,7 @@ static struct option long_options[] = {
{"nid", required_argument, 0, 15},
{"path", required_argument, 0, 16},
{"no-sbcrc", no_argument, 0, 512},
+ {"workers", required_argument, 0, 17},
{0, 0, 0, 0},
};
@@ -117,6 +120,7 @@ static void usage(int argc, char **argv)
" --nid=# check or extract from the target inode of nid #\n"
" --path=X check or extract from the target inode of path X\n"
" --no-sbcrc bypass the superblock checksum verification\n"
+ " --workers=# number of worker threads\n"
" --[no-]xattrs whether to dump extended attributes (default off)\n"
"\n"
" -a, -A, -y no-op, for compatibility with fsck of other filesystems\n"
@@ -257,6 +261,15 @@ static int erofsfsck_parse_options_cfg(int argc, char **argv)
case 16:
fsckcfg.inode_path = optarg;
break;
+ case 17: {
+ char *endptr;
+ unsigned long v = strtoul(optarg, &endptr, 0);
+
+ if (*endptr || v > UINT_MAX)
+ return -EINVAL;
+ fsckcfg.nr_workers = v;
+ break;
+ }
case 512:
fsckcfg.nosbcrc = true;
break;
--
2.43.0
More information about the Linux-erofs
mailing list