lsns: make --tree default, update man-page

* 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>
This commit is contained in:
Karel Zak 2021-04-28 13:04:16 +02:00
parent 179dd17a6a
commit 3387ad72a6
2 changed files with 12 additions and 8 deletions

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

View 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),