From 1880a5781f29d9a0d5bcce76a35c19b2363e0c68 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 1 Dec 2015 12:31:30 +0100 Subject: lsns: sort namespaces, avoid duplicate entries in tree output Signed-off-by: Karel Zak --- sys-utils/lsns.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'sys-utils/lsns.c') diff --git a/sys-utils/lsns.c b/sys-utils/lsns.c index df3b7def8..c1d649ae4 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); } -- cgit v1.2.3-55-g7522