diff options
author | John A. Leuenhagen <john@zlima12.com> | 2020-10-04 14:08:35 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2020-12-07 09:25:13 -0800 |
commit | 1a7415a9e25a0f5bc4d79d847e31f2779d01cf2c (patch) | |
tree | fc97bdf6da85c1047609a37ae074ec9568046adf | |
parent | 717d70db600fbe09354ed141977f83b50b38104a (diff) | |
download | f2fs-tools-1a7415a9e25a0f5bc4d79d847e31f2779d01cf2c.tar.gz |
mkfs.f2fs: add -h and --help
These two arguments would simply print the usage message.
Signed-off-by: John A. Leuenhagen <john@zlima12.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | man/mkfs.f2fs.8 | 3 | ||||
-rw-r--r-- | mkfs/f2fs_format_main.c | 12 |
2 files changed, 13 insertions, 2 deletions
diff --git a/man/mkfs.f2fs.8 b/man/mkfs.f2fs.8 index e2aee76..7745177 100644 --- a/man/mkfs.f2fs.8 +++ b/man/mkfs.f2fs.8 @@ -256,6 +256,9 @@ Number of sectors. Default is determined by device size. .TP .BI \-V Print the version number and exit. +.TP +.BI \-h,\ \-\-help +Print usage and exit. .SH AUTHOR This version of .B mkfs.f2fs diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c index f2f0a80..b14d735 100644 --- a/mkfs/f2fs_format_main.c +++ b/mkfs/f2fs_format_main.c @@ -20,6 +20,7 @@ #include <time.h> #include <uuid.h> #include <errno.h> +#include <getopt.h> #include "config.h" #ifdef HAVE_LIBBLKID @@ -125,12 +126,16 @@ static void add_default_options(void) static void f2fs_parse_options(int argc, char *argv[]) { - static const char *option_string = "qa:c:C:d:e:E:g:il:mo:O:rR:s:S:z:t:T:U:Vfw:"; + static const char *option_string = "qa:c:C:d:e:E:g:hil:mo:O:rR:s:S:z:t:T:U:Vfw:"; + static const struct option long_opts[] = { + { .name = "help", .has_arg = 0, .flag = NULL, .val = 'h' }, + { .name = NULL, .has_arg = 0, .flag = NULL, .val = 0 } + }; int32_t option=0; int val; char *token; - while ((option = getopt(argc,argv,option_string)) != EOF) { + while ((option = getopt_long(argc,argv,option_string,long_opts,NULL)) != EOF) { switch (option) { case 'q': c.dbg_lv = -1; @@ -164,6 +169,9 @@ static void f2fs_parse_options(int argc, char *argv[]) if (!strcmp(optarg, "android")) c.defset = CONF_ANDROID; break; + case 'h': + mkfs_usage(); + break; case 'i': c.large_nat_bitmap = 1; break; |