Skip to content

Commit 6db9705

Browse files
committed
btrfs-progs: convert: add option --version, update help text
For completeness and parity with other tools add the option --version and mention --help. Signed-off-by: David Sterba <[email protected]>
1 parent 5e5764a commit 6db9705

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

Diff for: convert/main.c

+15-3
Original file line numberDiff line numberDiff line change
@@ -1868,6 +1868,10 @@ static const char * const convert_usage[] = {
18681868
OPTLINE("-O|--features LIST", "comma separated list of filesystem features"),
18691869
OPTLINE("--no-progress", "show only overview, not the detailed progress"),
18701870
"",
1871+
"General:",
1872+
OPTLINE("--version", "print the btrfs-convert version and exit"),
1873+
OPTLINE("--help", "print this help and exit"),
1874+
"",
18711875
"Supported filesystems:",
18721876
"\text2/3/4: "
18731877
#if BTRFSCONVERT_EXT2
@@ -1910,11 +1914,10 @@ int BOX_MAIN(convert)(int argc, char *argv[])
19101914
cpu_detect_flags();
19111915
hash_init_accel();
19121916
btrfs_assert_feature_buf_size();
1913-
printf("btrfs-convert from %s\n\n", PACKAGE_STRING);
19141917

19151918
while(1) {
19161919
enum { GETOPT_VAL_NO_PROGRESS = GETOPT_VAL_FIRST, GETOPT_VAL_CHECKSUM,
1917-
GETOPT_VAL_UUID };
1920+
GETOPT_VAL_UUID, GETOPT_VAL_VERSION };
19181921
static const struct option long_options[] = {
19191922
{ "no-progress", no_argument, NULL,
19201923
GETOPT_VAL_NO_PROGRESS },
@@ -1932,7 +1935,8 @@ int BOX_MAIN(convert)(int argc, char *argv[])
19321935
{ "copy-label", no_argument, NULL, 'L' },
19331936
{ "uuid", required_argument, NULL, GETOPT_VAL_UUID },
19341937
{ "nodesize", required_argument, NULL, 'N' },
1935-
{ "help", no_argument, NULL, GETOPT_VAL_HELP},
1938+
{ "help", no_argument, NULL, GETOPT_VAL_HELP },
1939+
{ "version", no_argument, NULL, GETOPT_VAL_VERSION },
19361940
{ NULL, 0, NULL, 0 }
19371941
};
19381942
int c = getopt_long(argc, argv, "dinN:rl:LpO:", long_options, NULL);
@@ -2024,11 +2028,18 @@ int BOX_MAIN(convert)(int argc, char *argv[])
20242028
strncpy_null(fsid, optarg, sizeof(fsid));
20252029
}
20262030
break;
2031+
case GETOPT_VAL_VERSION:
2032+
printf("btrfs-convert, part of %s\n", PACKAGE_STRING);
2033+
ret = 0;
2034+
goto success;
20272035
case GETOPT_VAL_HELP:
20282036
default:
20292037
usage(&convert_cmd, c != GETOPT_VAL_HELP);
20302038
}
20312039
}
2040+
2041+
printf("btrfs-convert from %s\n\n", PACKAGE_STRING);
2042+
20322043
set_argv0(argv);
20332044
if (check_argc_exact(argc - optind, 1)) {
20342045
usage(&convert_cmd, 1);
@@ -2072,5 +2083,6 @@ int BOX_MAIN(convert)(int argc, char *argv[])
20722083
}
20732084
if (ret)
20742085
return 1;
2086+
success:
20752087
return 0;
20762088
}

0 commit comments

Comments
 (0)