[PATCH 1/5] erofs-utils: mount: add "-d <0-9>" option to set debug level
Yifan Zhao
zhaoyifan28 at huawei.com
Tue Dec 23 20:59:52 AEDT 2025
Add support for setting the debug level, a feature currently missing in
mount.erofs.
Signed-off-by: Yifan Zhao <zhaoyifan28 at huawei.com>
---
lib/backends/nbd.c | 2 +-
mount/main.c | 14 ++++++++++++--
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/lib/backends/nbd.c b/lib/backends/nbd.c
index 77c4f60..da27334 100644
--- a/lib/backends/nbd.c
+++ b/lib/backends/nbd.c
@@ -321,7 +321,7 @@ static int erofs_nbd_nl_cfg_cb(struct nl_msg *msg, void *arg)
ctx->errcode = -EBADMSG;
}
*ctx->index = nla_get_u32(msg_attr[NBD_ATTR_INDEX]);
- erofs_dbg("Connected /dev/nbd%d\n", *ctx->index);
+ erofs_dbg("Connected /dev/nbd%d", *ctx->index);
ctx->errcode = 0;
return NL_OK;
}
diff --git a/mount/main.c b/mount/main.c
index 29d1884..02a7962 100644
--- a/mount/main.c
+++ b/mount/main.c
@@ -91,6 +91,7 @@ static void usage(int argc, char **argv)
"General options:\n"
" -V, --version print the version number of mount.erofs and exit\n"
" -h, --help display this help and exit\n"
+ " -d <0-9> set output verbosity; 0=quiet, 9=verbose (default=%i)\n"
" -o options comma-separated list of mount options\n"
" -t type[.subtype] filesystem type (and optional subtype)\n"
" subtypes: fuse, local, nbd\n"
@@ -109,7 +110,7 @@ static void usage(int argc, char **argv)
" oci.zinfo=<path> path to gzip zinfo file (optional)\n"
" oci.insecure use HTTP instead of HTTPS (optional)\n"
#endif
- , argv[0]);
+ , argv[0], EROFS_WARN);
}
static void version(void)
@@ -279,10 +280,11 @@ static int erofsmount_parse_options(int argc, char **argv)
};
char *dot;
int opt;
+ int i;
nbdsrc.ocicfg.layer_index = -1;
- while ((opt = getopt_long(argc, argv, "VNfhno:st:uv",
+ while ((opt = getopt_long(argc, argv, "VNfhd:no:st:uv",
long_options, NULL)) != -1) {
switch (opt) {
case 'h':
@@ -291,6 +293,14 @@ static int erofsmount_parse_options(int argc, char **argv)
case 'V':
version();
exit(0);
+ case 'd':
+ i = atoi(optarg);
+ if (i < EROFS_MSG_MIN || i > EROFS_MSG_MAX) {
+ erofs_err("invalid debug level %d", i);
+ return -EINVAL;
+ }
+ cfg.c_dbg_lvl = i;
+ break;
case 'o':
mountcfg.full_options = optarg;
mountcfg.flags =
--
2.43.0
More information about the Linux-erofs
mailing list