]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lslocks: improve --list-columns
authorKarel Zak <kzak@redhat.com>
Wed, 6 Dec 2023 12:25:20 +0000 (13:25 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 7 Dec 2023 13:46:50 +0000 (14:46 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
bash-completion/lslocks
misc-utils/lslocks.8.adoc
misc-utils/lslocks.c

index fbe75fffadd9a1ff875b03d54b5dcce38c491132..2847d359626fd414ceb62918811d6407b100ad1b 100644 (file)
@@ -40,6 +40,7 @@ _lslocks_module()
                --pid
                --raw
                --notruncate
+               --list-columns
                --help
                --version
        "
index 1efdf7aefb60265bdf943567161aa562a14493a3..2084d96c051660581eba2e0c57dac9ccef5bac11 100644 (file)
@@ -35,7 +35,7 @@ lslocks - list local system locks
 include::man-common/in-bytes.adoc[]
 
 *-H*, *--list-columns*::
-List the available columns.
+List the available columns, use with *--json* or *--raw* to get output in machine-readable format.
 
 *-i*, *--noinaccessible*::
 Ignore lock files which are inaccessible for the current user.
index 2881855589b7f10eda1d9f5c379952cfabc578fe..2a88440b4468ed710334f90745531eab350e3b3a 100644 (file)
@@ -79,7 +79,7 @@ static struct colinfo infos[] = {
        [COL_SRC]  = { "COMMAND",15, 0, N_("command of the process holding the lock") },
        [COL_PID]  = { "PID",     5, SCOLS_FL_RIGHT, N_("PID of the process holding the lock") },
        [COL_TYPE] = { "TYPE",    5, SCOLS_FL_RIGHT, N_("kind of lock") },
-       [COL_SIZE] = { "SIZE",    4, SCOLS_FL_RIGHT, N_("size of the lock. Use <number> if -b/--bytes is given.") },
+       [COL_SIZE] = { "SIZE",    4, SCOLS_FL_RIGHT, N_("size of the lock, use <number> if --bytes is given") },
        [COL_INODE] = { "INODE",  5, SCOLS_FL_RIGHT, N_("inode number") },
        [COL_MAJMIN] = { "MAJ:MIN", 6, 0, N_("major:minor device number") },
        [COL_MODE] = { "MODE",    5, 0, N_("lock access mode") },
@@ -833,10 +833,10 @@ static void __attribute__((__noreturn__)) usage(void)
        exit(EXIT_SUCCESS);
 }
 
-static void __attribute__((__noreturn__)) list_colunms(const char *table_name,
-                                                      FILE *out)
+static void __attribute__((__noreturn__)) list_colunms(void)
 {
-       struct libscols_table *col_tb = xcolumn_list_table_new(table_name, out, raw, json);
+       struct libscols_table *col_tb = xcolumn_list_table_new(
+                                       "lslocks-columns", stdout, raw, json);
 
        for (size_t i = 0; i < ARRAY_SIZE(infos); i++) {
                if (i != COL_SIZE) {
@@ -941,7 +941,7 @@ int main(int argc, char *argv[])
        }
 
        if (collist)
-               list_colunms("lslocks-columns", stdout);        /* print end exit */
+               list_colunms(); /* print end exit */
 
        INIT_LIST_HEAD(&proc_locks);