blockdev: improve --help and man page

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
This commit is contained in:
Ruediger Meier 2017-06-25 20:43:44 +02:00
parent b305445495
commit a861538cc8
2 changed files with 29 additions and 12 deletions

View File

@ -17,13 +17,14 @@ blockdev \- call block device ioctls from the command line
.B blockdev
.B \-\-report
.RI [ device \&...\&]
.br
.B blockdev
.RB \-h | \-V
.SH DESCRIPTION
The utility
.B blockdev
allows one to call block device ioctls from the command line.
.SH OPTIONS
.IP "\fB\-V\fP"
Print version and exit.
.IP "\fB\-q\fP"
Be quiet.
.IP "\fB\-v\fP"
@ -32,6 +33,10 @@ Be verbose.
Print a report for the specified device. It is possible to give multiple
devices. If none is given, all devices which appear in /proc/partitions are
shown. Note that the partition StartSec is in 512-byte sectors.
.IP "\fB\-h\fR, \fB\-\-help\fR"
Display help text and exit.
.IP "\fB\-V\fR, \fB\-\-version\fR"
Print version and exit.
.SH COMMANDS
It is possible to give multiple devices and multiple commands.
.IP "\fB\-\-flushbufs\fP"

View File

@ -180,27 +180,39 @@ static const struct bdc bdcms[] =
static void __attribute__((__noreturn__)) usage(void)
{
FILE * out = stdout;
size_t i;
fprintf(out, _("\nUsage:\n"
" %1$s -V\n"
" %1$s --report [devices]\n"
" %1$s [-v|-q] commands devices\n\n"
"Available commands:\n"), program_invocation_short_name);
fputs(USAGE_HEADER, stdout);
printf(_(
" %1$s [-v|-q] commands devices\n"
" %1$s --report [devices]\n"
" %1$s -h|-V\n"
), program_invocation_short_name);
fprintf(out, _(" %-25s get size in 512-byte sectors\n"), "--getsz");
fputs(USAGE_SEPARATOR, stdout);
puts( _("Call block device ioctls from the command line."));
fputs(USAGE_OPTIONS, stdout);
puts( _(" -q quiet mode"));
puts( _(" -v verbose mode"));
puts( _(" --report print report for specified (or all) devices"));
fputs(USAGE_SEPARATOR, stdout);
print_usage_help_options(16);
fputs(USAGE_SEPARATOR, stdout);
puts( _("Available commands:"));
printf(_(" %-25s get size in 512-byte sectors\n"), "--getsz");
for (i = 0; i < ARRAY_SIZE(bdcms); i++) {
if (bdcms[i].argname)
fprintf(out, " %s %-*s %s\n", bdcms[i].name,
printf(" %s %-*s %s\n", bdcms[i].name,
(int)(24 - strlen(bdcms[i].name)),
bdcms[i].argname, _(bdcms[i].help));
else
fprintf(out, " %-25s %s\n", bdcms[i].name,
printf(" %-25s %s\n", bdcms[i].name,
_(bdcms[i].help));
}
fprintf(out, USAGE_MAN_TAIL("blockdev(1)"));
printf(USAGE_MAN_TAIL("blockdev(1)"));
exit(EXIT_SUCCESS);
}