From a861538cc8d93245f13d43f51f1365533b76be51 Mon Sep 17 00:00:00 2001 From: Ruediger Meier Date: Sun, 25 Jun 2017 20:43:44 +0200 Subject: [PATCH] blockdev: improve --help and man page Signed-off-by: Ruediger Meier --- disk-utils/blockdev.8 | 9 +++++++-- disk-utils/blockdev.c | 32 ++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/disk-utils/blockdev.8 b/disk-utils/blockdev.8 index c9eeb9b41..0f3291391 100644 --- a/disk-utils/blockdev.8 +++ b/disk-utils/blockdev.8 @@ -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" diff --git a/disk-utils/blockdev.c b/disk-utils/blockdev.c index 4760e021b..ed018a7bf 100644 --- a/disk-utils/blockdev.c +++ b/disk-utils/blockdev.c @@ -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); }