lsblk: add --version switch

[kzak@redhat.com: - update usage() and man page]

Signed-off-by: Milan Broz <mbroz@redhat.com>
This commit is contained in:
Milan Broz 2012-03-05 22:07:10 +01:00 committed by Karel Zak
parent 24df2633d3
commit 5791238768
2 changed files with 13 additions and 5 deletions

View File

@ -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.

View File

@ -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);
}