aboutsummaryrefslogtreecommitdiff
path: root/dump/main.c
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@umorpha.io>2023-11-02 13:31:21 -0600
committerGao Xiang <hsiangkao@linux.alibaba.com>2023-11-06 13:42:17 +0800
commit197e3294bcdf93f37d12989cd830a33c055b1a53 (patch)
tree9aac85ed36e2a603e42037d3b13c64688f9370f1 /dump/main.c
parentf528b82ffbcb15484a7195c1a1d08ece0ff67350 (diff)
downloaderofs-utils-197e3294bcdf93f37d12989cd830a33c055b1a53.tar.gz
erofs-utils: improve the usage and version text of non-fuse commands
For each command: - Change the format of --help to be closer to the usual GNU format - Have the --version text mention that it is part of erofs-utils - Include compile-time feature flags in -V - Have --help and --version print on stdout not stderr - Exit with 0 from --help and --version - Have flag errors print a message saying to use --help instead of printing the full help text For fsck.erofs: - Consolidate the descriptions of --[no-]preserve[-<owner|perms> - Clarify the range that -d accepts For mkfs.erofs: - Print supported algorithms and their level ranges+defaults - Clarify the range that -d accepts For mkfs.erofs to have access to the algorithms' level ranges and defaults, it is necessary to modify z_erofs_list_available_compressors() to return the full `struct erofs_algorithm` instead of just the `->name`. Signed-off-by: Luke T. Shumaker <lukeshu@umorpha.io> Link: https://lore.kernel.org/r/20231102193122.140921-3-lukeshu@lukeshu.com Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Diffstat (limited to 'dump/main.c')
-rw-r--r--dump/main.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/dump/main.c b/dump/main.c
index a952f32..293093d 100644
--- a/dump/main.c
+++ b/dump/main.c
@@ -106,25 +106,31 @@ static struct erofsdump_feature feature_lists[] = {
static int erofsdump_readdir(struct erofs_dir_context *ctx);
-static void usage(void)
+static void usage(int argc, char **argv)
{
- fputs("usage: [options] IMAGE\n\n"
- "Dump erofs layout from IMAGE, and [options] are:\n"
- " -S show statistic information of the image\n"
- " -V, --version print the version number of dump.erofs and exit.\n"
- " -e show extent info (INODE required)\n"
- " -s show information about superblock\n"
- " --device=X specify an extra device to be used together\n"
- " --ls show directory contents (INODE required)\n"
- " --nid=# show the target inode info of nid #\n"
- " --path=X show the target inode info of path X\n"
- " -h, --help display this help and exit.\n",
- stderr);
+ // " 1 2 3 4 5 6 7 8 "
+ // "12345678901234567890123456789012345678901234567890123456789012345678901234567890\n"
+ printf(
+ "Usage: %s [OPTIONS] IMAGE\n"
+ "Dump erofs layout from IMAGE.\n"
+ "\n"
+ "General options:\n"
+ " -V, --version print the version number of dump.erofs and exit\n"
+ " -h, --help display this help and exit\n"
+ "\n"
+ " -S show statistic information of the image\n"
+ " -e show extent info (INODE required)\n"
+ " -s show information about superblock\n"
+ " --device=X specify an extra device to be used together\n"
+ " --ls show directory contents (INODE required)\n"
+ " --nid=# show the target inode info of nid #\n"
+ " --path=X show the target inode info of path X\n",
+ argv[0]);
}
static void erofsdump_print_version(void)
{
- printf("dump.erofs %s\n", cfg.c_version);
+ printf("dump.erofs (erofs-utils) %s\n", cfg.c_version);
}
static int erofsdump_parse_options_cfg(int argc, char **argv)
@@ -155,7 +161,7 @@ static int erofsdump_parse_options_cfg(int argc, char **argv)
++dumpcfg.totalshow;
break;
case 'h':
- usage();
+ usage(argc, argv);
exit(0);
case 3:
err = blob_open_ro(&sbi, optarg);
@@ -663,7 +669,7 @@ int main(int argc, char **argv)
err = erofsdump_parse_options_cfg(argc, argv);
if (err) {
if (err == -EINVAL)
- usage();
+ fprintf(stderr, "Try '%s --help' for more information.\n", argv[0]);
goto exit;
}
@@ -690,7 +696,7 @@ int main(int argc, char **argv)
erofsdump_print_statistic();
if (dumpcfg.show_extent && !dumpcfg.show_inode) {
- usage();
+ fprintf(stderr, "Try '%s --help' for more information.\n", argv[0]);
goto exit_put_super;
}