]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsns: make --tree default, update man-page
authorKarel Zak <kzak@redhat.com>
Wed, 28 Apr 2021 11:04:16 +0000 (13:04 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 24 May 2021 11:39:53 +0000 (13:39 +0200)
* make --tree=process default for 'lsns' and 'lsns <ns>'
* remove 'list' from struct lsns
* update man page

Addresses: https://github.com/karelzak/util-linux/pull/1281
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/lsns.8.adoc
sys-utils/lsns.c

index 6bfbdb644c912c572d66785a271396b7b4caa930..738f8710616ecbef7e0c570f1d4185cb811212c6 100644 (file)
@@ -23,7 +23,7 @@ lsns - list namespaces
 
 *lsns* lists information about all the currently accessible namespaces or about the given _namespace_. The _namespace_ identifier is an inode number.
 
-The default output is subject to change. So whenever possible, you should avoid using default outputs in your scripts. Always explicitly define expected columns by using the *--output* option together with a columns list in environments where a stable output is required.
+The default output is subject to change. So whenever possible, you should avoid using default outputs in your scripts. Always explicitly define expected output mode (*--tree* or *--list*) and columns by using the *--output* option together with a columns list in environments where a stable output is required.
 
 The *NSFS* column, printed when *net* is specified for the *--type* option, is special; it uses multi-line cells. Use the option *--nowrap* to switch to ","-separated single-line representation.
 
@@ -63,9 +63,9 @@ Do not truncate text in columns.
 *-W*, *--nowrap*::
 Do not use multi-line text in columns.
 
-*-T*, *--nstree* _rel_::
+*-T*, *--tree* _rel_::
 Use list output format.
-If *process* is gnve as _rel_, print proecss tree(s) in each name space.
+If *process* is given as _rel_, print proecss tree(s) in each name space. This is default when *--tree* is not specified.
 If *parent* is given, print tree(s) constructed by the parent/child relationship.
 If *owner* is given, print tree(s) constructed by the owner/owned relationship.
 *owner* is used as default when _rel_ is omitted.
index a8daab95e2c3ea313231a2a6c17f8568efeb6ba4..1ea2dd594648712c2385be244aedea36d2f4ff79 100644 (file)
@@ -183,7 +183,7 @@ struct lsns_process {
 
 
 enum {
-      LSNS_TREE_LIST,
+      LSNS_TREE_NONE,
       LSNS_TREE_PROCESS,
       LSNS_TREE_OWNER,
       LSNS_TREE_PARENT,
@@ -201,7 +201,6 @@ struct lsns {
        unsigned int raw        : 1,
                     json       : 1,
                     tree       : 2,
-                    list       : 1,
                     no_trunc   : 1,
                     no_headings: 1,
                     no_wrap    : 1;
@@ -1066,7 +1065,7 @@ static void __attribute__((__noreturn__)) usage(void)
 int main(int argc, char *argv[])
 {
        struct lsns ls;
-       int c;
+       int c, force_list = 0;
        int r = 0;
        char *outarg = NULL;
        enum {
@@ -1091,6 +1090,7 @@ int main(int argc, char *argv[])
 
        static const ul_excl_t excl[] = {       /* rows and cols in ASCII order */
                { 'J','r' },
+               { 'l','T' },
                { 0 }
        };
        int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
@@ -1118,7 +1118,7 @@ int main(int argc, char *argv[])
                        ls.json = 1;
                        break;
                case 'l':
-                       ls.list = 1;
+                       force_list = 1;
                        break;
                case 'o':
                        outarg = optarg;
@@ -1187,7 +1187,8 @@ int main(int argc, char *argv[])
                if (ls.fltr_pid)
                        errx(EXIT_FAILURE, _("--task is mutually exclusive with <namespace>"));
                ls.fltr_ns = strtou64_or_err(argv[optind], _("invalid namespace argument"));
-               ls.tree = ls.list ? LSNS_TREE_LIST : LSNS_TREE_PROCESS;
+               if (!ls.tree && !force_list)
+                       ls.tree = LSNS_TREE_PROCESS;
 
                if (!ncolumns) {
                        columns[ncolumns++] = COL_PID;
@@ -1208,6 +1209,9 @@ int main(int argc, char *argv[])
                        columns[ncolumns++] = COL_NSFS;
                }
                columns[ncolumns++] = COL_COMMAND;
+
+               if (!ls.tree && !force_list)
+                       ls.tree = LSNS_TREE_PROCESS;
        }
 
        if (outarg && string_add_to_idarray(outarg, columns, ARRAY_SIZE(columns),