From: Karel Zak Date: Tue, 1 Dec 2015 11:31:30 +0000 (+0100) Subject: lsns: sort namespaces, avoid duplicate entries in tree output X-Git-Tag: v2.28-rc1~253 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1880a5781f29d9a0d5bcce76a35c19b2363e0c68;p=thirdparty%2Futil-linux.git lsns: sort namespaces, avoid duplicate entries in tree output Signed-off-by: Karel Zak --- diff --git a/sys-utils/lsns.c b/sys-utils/lsns.c index df3b7def8b..c1d649ae44 100644 --- a/sys-utils/lsns.c +++ b/sys-utils/lsns.c @@ -379,6 +379,15 @@ static int add_process_to_namespace(struct lsns *ls, struct lsns_namespace *ns, return 0; } +static int cmp_namespaces(struct list_head *a, struct list_head *b, + __attribute__((__unused__)) void *data) +{ + struct lsns_namespace *xa = list_entry(a, struct lsns_namespace, namespaces), + *xb = list_entry(b, struct lsns_namespace, namespaces); + + return cmp_numbers(xa->id, xb->id); +} + static int read_namespaces(struct lsns *ls) { struct list_head *p; @@ -402,6 +411,8 @@ static int read_namespaces(struct lsns *ls) } } + list_sort(&ls->namespaces, cmp_namespaces, NULL); + return 0; } @@ -556,7 +567,9 @@ static int show_namespace_processes(struct lsns *ls, struct lsns_namespace *ns) list_for_each(p, &ns->processes) { struct lsns_process *proc = list_entry(p, struct lsns_process, ns_siblings[ns->type]); - show_process(ls, tab, proc, ns); + + if (!proc->outline) + show_process(ls, tab, proc, ns); }