]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lslocks: support -o +<list> convention
authorKarel Zak <kzak@redhat.com>
Mon, 18 Feb 2013 12:21:42 +0000 (13:21 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 18 Feb 2013 12:21:42 +0000 (13:21 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/lslocks.8
misc-utils/lslocks.c

index 8881c8c571d072b6340ec46af10a7a07cc773b03..04ece38e4bf7145247ad6f7e80b6e3770841035e 100644 (file)
@@ -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 +<list> (e.g. lslocks -o +BLOCKER).
 .IP "\fB\-n, \-\-noheadings\fP"
 Do not print a header line.
 .IP "\fB\-u, \-\-notruncate\fP"
index 7c0637bf098062d103ac3af9caefff63686b4446..de3094a01850326f73abcd7afc032d9e00f8ac45 100644 (file)
@@ -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))