From: Milan Broz Date: Mon, 5 Mar 2012 21:07:10 +0000 (+0100) Subject: lsblk: add --version switch X-Git-Tag: v2.22-rc1~703 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5791238768d6a2ca46bb140cde70b1fcf200afff;p=thirdparty%2Futil-linux.git lsblk: add --version switch [kzak@redhat.com: - update usage() and man page] Signed-off-by: Milan Broz --- diff --git a/misc-utils/lsblk.8 b/misc-utils/lsblk.8 index cd63948dba..64cf4a9883 100644 --- a/misc-utils/lsblk.8 +++ b/misc-utils/lsblk.8 @@ -60,6 +60,8 @@ Use the raw output format. All potentially unsafe characters are hex-escaped (\\ .IP "\fB\-t, \-\-topology\fP" Output info about block device topology. This option is equivalent to "-o NAME,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED". +.IP "\fB\-V, \-\-version\fP" +Output version information and exit. .SH NOTES For the partitions are some information (e.g. queue attributes) inherited from parental device. diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index 2eb2b72370..4709aaaae0 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -1085,14 +1085,15 @@ static void __attribute__((__noreturn__)) help(FILE *out) " -P, --pairs use key=\"value\" output format\n" " -r, --raw use raw output format\n" " -s, --inverse inverse dependencies\n" - " -t, --topology output info about topology\n")); + " -t, --topology output info about topology\n" + " -V, --version output version information and exit\n")); - fprintf(out, _("\nAvailable columns:\n")); + fprintf(out, _("\nAvailable columns (for --output):\n")); for (i = 0; i < NCOLS; i++) - fprintf(out, " %10s %s\n", infos[i].name, _(infos[i].help)); + fprintf(out, " %11s %s\n", infos[i].name, _(infos[i].help)); - fprintf(out, _("\nFor more information see lsblk(8).\n")); + fprintf(out, USAGE_MAN_TAIL("lsblk(8)")); exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); } @@ -1133,6 +1134,7 @@ int main(int argc, char *argv[]) { "exclude", 1, 0, 'e' }, { "topology", 0, 0, 't' }, { "pairs", 0, 0, 'P' }, + { "version", 0, 0, 'V' }, { NULL, 0, 0, 0 }, }; @@ -1143,7 +1145,7 @@ int main(int argc, char *argv[]) lsblk = &_ls; memset(lsblk, 0, sizeof(*lsblk)); - while((c = getopt_long(argc, argv, "abdDe:fhlnmo:Pirst", longopts, NULL)) != -1) { + while((c = getopt_long(argc, argv, "abdDe:fhlnmo:PirstV", longopts, NULL)) != -1) { switch(c) { case 'a': lsblk->all_devices = 1; @@ -1222,6 +1224,10 @@ int main(int argc, char *argv[]) columns[ncolumns++] = COL_SCHED; columns[ncolumns++] = COL_RQ_SIZE; break; + case 'V': + printf(_("%s from %s\n"), program_invocation_short_name, + PACKAGE_STRING); + return EXIT_SUCCESS; default: help(stderr); }