fsck: add --help and --version
Also cleanup usage() function, never write usage to stderr. FIXME: - currently strtou32_or_err() exits with wrong exit code. - option -C does not use a safe strto*_err function Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
This commit is contained in:
parent
7a87a774af
commit
58745f3599
|
@ -309,6 +309,12 @@ Don't show the title on startup.
|
||||||
.B \-V
|
.B \-V
|
||||||
Produce verbose output, including all filesystem-specific commands
|
Produce verbose output, including all filesystem-specific commands
|
||||||
that are executed.
|
that are executed.
|
||||||
|
.TP
|
||||||
|
\fB\-?\fR, \fB\-\-help\fR
|
||||||
|
Display help text and exit.
|
||||||
|
.TP
|
||||||
|
\fB\-\-version\fR
|
||||||
|
Display version information and exit.
|
||||||
.SH FILESYSTEM SPECIFIC OPTIONS
|
.SH FILESYSTEM SPECIFIC OPTIONS
|
||||||
.B Options which are not understood by fsck are passed to the filesystem-specific checker!
|
.B Options which are not understood by fsck are passed to the filesystem-specific checker!
|
||||||
.PP
|
.PP
|
||||||
|
|
|
@ -1369,8 +1369,9 @@ static int check_all(void)
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __attribute__((__noreturn__)) usage(FILE *out)
|
static void __attribute__((__noreturn__)) usage(void)
|
||||||
{
|
{
|
||||||
|
FILE *out = stdout;
|
||||||
fputs(USAGE_HEADER, out);
|
fputs(USAGE_HEADER, out);
|
||||||
fprintf(out, _(" %s [options] -- [fs-options] [<filesystem> ...]\n"),
|
fprintf(out, _(" %s [options] -- [fs-options] [<filesystem> ...]\n"),
|
||||||
program_invocation_short_name);
|
program_invocation_short_name);
|
||||||
|
@ -1393,13 +1394,14 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
|
||||||
fputs(_(" -t <type> specify filesystem types to be checked;\n"
|
fputs(_(" -t <type> specify filesystem types to be checked;\n"
|
||||||
" <type> is allowed to be a comma-separated list\n"), out);
|
" <type> is allowed to be a comma-separated list\n"), out);
|
||||||
fputs(_(" -V explain what is being done\n"), out);
|
fputs(_(" -V explain what is being done\n"), out);
|
||||||
fputs(_(" -? display this help and exit\n"), out);
|
|
||||||
|
|
||||||
|
fputs(USAGE_SEPARATOR, out);
|
||||||
|
fputs(_(" -?, --help display this help and exit\n"), out);
|
||||||
|
fputs(_(" --version output version information and exit\n"), out);
|
||||||
fputs(USAGE_SEPARATOR, out);
|
fputs(USAGE_SEPARATOR, out);
|
||||||
fputs(_("See the specific fsck.* commands for available fs-options."), out);
|
fputs(_("See the specific fsck.* commands for available fs-options."), out);
|
||||||
fprintf(out, USAGE_MAN_TAIL("fsck(8)"));
|
fprintf(out, USAGE_MAN_TAIL("fsck(8)"));
|
||||||
|
exit(FSCK_EX_OK);
|
||||||
exit(out == stderr ? FSCK_EX_USAGE : FSCK_EX_OK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void signal_cancel(int sig __attribute__((__unused__)))
|
static void signal_cancel(int sig __attribute__((__unused__)))
|
||||||
|
@ -1433,6 +1435,15 @@ static void parse_argv(int argc, char *argv[])
|
||||||
arg = argv[i];
|
arg = argv[i];
|
||||||
if (!arg)
|
if (!arg)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/* the only two longopts to satisfy UL standards */
|
||||||
|
if (!opts_for_fsck && !strcmp(arg, "--help"))
|
||||||
|
usage();
|
||||||
|
if (!opts_for_fsck && !strcmp(arg, "--version")) {
|
||||||
|
printf(UTIL_LINUX_VERSION);
|
||||||
|
exit(FSCK_EX_OK);
|
||||||
|
}
|
||||||
|
|
||||||
if ((arg[0] == '/' && !opts_for_fsck) || strchr(arg, '=')) {
|
if ((arg[0] == '/' && !opts_for_fsck) || strchr(arg, '=')) {
|
||||||
if (num_devices >= MAX_DEVICES)
|
if (num_devices >= MAX_DEVICES)
|
||||||
errx(FSCK_EX_ERROR, _("too many devices"));
|
errx(FSCK_EX_ERROR, _("too many devices"));
|
||||||
|
@ -1536,13 +1547,15 @@ static void parse_argv(int argc, char *argv[])
|
||||||
case 't':
|
case 't':
|
||||||
tmp = NULL;
|
tmp = NULL;
|
||||||
if (fstype)
|
if (fstype)
|
||||||
usage(stderr);
|
errx(FSCK_EX_USAGE,
|
||||||
|
_("option '%s' may be specified only once"), "-t");
|
||||||
if (arg[j+1])
|
if (arg[j+1])
|
||||||
tmp = arg+j+1;
|
tmp = arg+j+1;
|
||||||
else if ((i+1) < argc)
|
else if ((i+1) < argc)
|
||||||
tmp = argv[++i];
|
tmp = argv[++i];
|
||||||
else
|
else
|
||||||
usage(stderr);
|
errx(FSCK_EX_USAGE,
|
||||||
|
_("option '%s' requires an argument"), "-t");
|
||||||
fstype = xstrdup(tmp);
|
fstype = xstrdup(tmp);
|
||||||
compile_fs_type(fstype, &fs_type_compiled);
|
compile_fs_type(fstype, &fs_type_compiled);
|
||||||
goto next_arg;
|
goto next_arg;
|
||||||
|
@ -1550,7 +1563,7 @@ static void parse_argv(int argc, char *argv[])
|
||||||
opts_for_fsck++;
|
opts_for_fsck++;
|
||||||
break;
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
usage(stdout);
|
usage();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
options[++opt] = arg[j];
|
options[++opt] = arg[j];
|
||||||
|
|
Loading…
Reference in New Issue