From: Karel Zak Date: Mon, 18 Feb 2013 12:21:42 +0000 (+0100) Subject: lslocks: support -o + convention X-Git-Tag: v2.23-rc1~209 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e68948e1462d7c86477820b74789c654333007b8;p=thirdparty%2Futil-linux.git lslocks: support -o + convention Signed-off-by: Karel Zak --- diff --git a/misc-utils/lslocks.8 b/misc-utils/lslocks.8 index 8881c8c571..04ece38e4b 100644 --- a/misc-utils/lslocks.8 +++ b/misc-utils/lslocks.8 @@ -23,6 +23,9 @@ Print a help text and exit. Specify which output columns to print. Use .B "--help" to get a list of all supported columns. + +The default list of the columns maybe be extended if the \fIlist\fP is +specified in format + (e.g. lslocks -o +BLOCKER). .IP "\fB\-n, \-\-noheadings\fP" Do not print a header line. .IP "\fB\-u, \-\-notruncate\fP" diff --git a/misc-utils/lslocks.c b/misc-utils/lslocks.c index 7c0637bf09..de3094a018 100644 --- a/misc-utils/lslocks.c +++ b/misc-utils/lslocks.c @@ -521,6 +521,7 @@ int main(int argc, char *argv[]) { int c, tt_flags = 0, rc = 0; struct list_head locks; + char *outarg = NULL; static const struct option long_opts[] = { { "pid", required_argument, NULL, 'p' }, { "help", no_argument, NULL, 'h' }, @@ -545,11 +546,7 @@ int main(int argc, char *argv[]) pid = strtos32_or_err(optarg, _("invalid PID argument")); break; case 'o': - ncolumns = string_to_idarray(optarg, - columns, ARRAY_SIZE(columns), - column_name_to_id); - if (ncolumns < 0) - return EXIT_FAILURE; + outarg = optarg; break; case 'V': printf(UTIL_LINUX_VERSION); @@ -586,6 +583,10 @@ int main(int argc, char *argv[]) columns[ncolumns++] = COL_PATH; } + if (outarg && string_add_to_idarray(outarg, columns, ARRAY_SIZE(columns), + &ncolumns, column_name_to_id) < 0) + return EXIT_FAILURE; + rc = get_local_locks(&locks); if (!rc && !list_empty(&locks))