From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: linux-erofs@lists.ozlabs.org
Cc: Gao Xiang <hsiangkao@linux.alibaba.com>, nl6720 <nl6720@gmail.com>
Subject: [PATCH v2] erofs-utils: mkfs: introduce --quiet option
Date: Tue, 19 Oct 2021 17:17:49 +0800 [thread overview]
Message-ID: <20211019091749.24528-1-hsiangkao@linux.alibaba.com> (raw)
In-Reply-To: <YW1luAmReW8HpbHn@B-P7TQMD6M-0146.local>
Add a preliminary quiet mode as described in
https://gitlab.archlinux.org/archlinux/archiso/-/issues/148
Suggested-by: nl6720 <nl6720@gmail.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
changes since v1:
- simplify erofs_show_progs().
lib/config.c | 4 +++-
mkfs/main.c | 22 +++++++++++++++++-----
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/lib/config.c b/lib/config.c
index 6d751715fcf2..363dcc5a0525 100644
--- a/lib/config.c
+++ b/lib/config.c
@@ -16,7 +16,7 @@ void erofs_init_configure(void)
{
memset(&cfg, 0, sizeof(cfg));
- cfg.c_dbg_lvl = 2;
+ cfg.c_dbg_lvl = EROFS_WARN;
cfg.c_version = PACKAGE_VERSION;
cfg.c_dry_run = false;
cfg.c_compr_level_master = -1;
@@ -34,6 +34,8 @@ void erofs_show_config(void)
{
const struct erofs_configure *c = &cfg;
+ if (c->c_dbg_lvl < EROFS_WARN)
+ return;
erofs_dump("\tc_version: [%8s]\n", c->c_version);
erofs_dump("\tc_dbg_lvl: [%8d]\n", c->c_dbg_lvl);
erofs_dump("\tc_dry_run: [%8d]\n", c->c_dry_run);
diff --git a/mkfs/main.c b/mkfs/main.c
index 1c8dea55f0cd..055d077988e9 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -46,6 +46,7 @@ static struct option long_options[] = {
{"max-extent-bytes", required_argument, NULL, 9},
{"compress-hints", required_argument, NULL, 10},
{"chunksize", required_argument, NULL, 11},
+ {"quiet", no_argument, 0, 12},
#ifdef WITH_ANDROID
{"mount-point", required_argument, NULL, 512},
{"product-out", required_argument, NULL, 513},
@@ -93,6 +94,7 @@ static void usage(void)
" --force-gid=# set all file gids to # (# = GID)\n"
" --help display this help and exit\n"
" --max-extent-bytes=# set maximum decompressed extent size # in bytes\n"
+ " --quiet quiet execution (do not write anything to standard output.)\n"
#ifndef NDEBUG
" --random-pclusterblks randomize pclusterblks for big pcluster (debugging only)\n"
#endif
@@ -179,6 +181,7 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
{
char *endptr;
int opt, i;
+ bool quiet = false;
while ((opt = getopt_long(argc, argv, "C:E:T:U:d:x:z:",
long_options, NULL)) != -1) {
@@ -342,9 +345,10 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
return -EINVAL;
}
erofs_sb_set_chunked_file();
- erofs_warn("EXPERIMENTAL chunked file feature in use. Use at your own risk!");
break;
-
+ case 12:
+ quiet = true;
+ break;
case 1:
usage();
exit(0);
@@ -377,6 +381,8 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
erofs_err("Unexpected argument: %s\n", argv[optind]);
return -EINVAL;
}
+ if (quiet)
+ cfg.c_dbg_lvl = EROFS_ERR;
return 0;
}
@@ -522,6 +528,12 @@ int parse_source_date_epoch(void)
return 0;
}
+void erofs_show_progs(int argc, char *argv[])
+{
+ if (cfg.c_dbg_lvl >= EROFS_WARN)
+ fprintf(stderr, "%s %s\n", basename(argv[0]), cfg.c_version);
+}
+
int main(int argc, char **argv)
{
int err = 0;
@@ -534,11 +546,10 @@ int main(int argc, char **argv)
char uuid_str[37] = "not available";
erofs_init_configure();
- fprintf(stderr, "%s %s\n", basename(argv[0]), cfg.c_version);
-
erofs_mkfs_default_options();
err = mkfs_parse_options_cfg(argc, argv);
+ erofs_show_progs(argc, argv);
if (err) {
if (err == -EINVAL)
usage();
@@ -593,8 +604,9 @@ int main(int argc, char **argv)
return 1;
}
#endif
-
erofs_show_config();
+ if (erofs_sb_has_chunked_file())
+ erofs_warn("EXPERIMENTAL chunked file feature in use. Use at your own risk!");
erofs_set_fs_root(cfg.c_src_path);
#ifndef NDEBUG
if (cfg.c_random_pclusterblks)
--
2.24.4
prev parent reply other threads:[~2021-10-19 9:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-18 12:16 [PATCH] erofs-utils: mkfs: introduce --quiet option Gao Xiang
2021-10-18 12:48 ` nl6720
2021-10-19 6:23 ` Gao Xiang
2021-10-19 9:17 ` Gao Xiang [this message]
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=20211019091749.24528-1-hsiangkao@linux.alibaba.com \
--to=hsiangkao@linux.alibaba.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=nl6720@gmail.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;
as well as URLs for NNTP newsgroup(s).