summaryrefslogtreecommitdiffstats
path: root/sys-utils/lsns.c
diff options
context:
space:
mode:
authorKarel Zak2015-12-01 12:31:30 +0100
committerKarel Zak2015-12-01 12:31:40 +0100
commit1880a5781f29d9a0d5bcce76a35c19b2363e0c68 (patch)
tree0f88ad8b7502dbbe5d97c374ca2dd56a8ab05e21 /sys-utils/lsns.c
parentlsns: remove unwanted comment (diff)
downloadkernel-qcow2-util-linux-1880a5781f29d9a0d5bcce76a35c19b2363e0c68.tar.gz
kernel-qcow2-util-linux-1880a5781f29d9a0d5bcce76a35c19b2363e0c68.tar.xz
kernel-qcow2-util-linux-1880a5781f29d9a0d5bcce76a35c19b2363e0c68.zip
lsns: sort namespaces, avoid duplicate entries in tree output
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/lsns.c')
-rw-r--r--sys-utils/lsns.c15
1 files changed, 14 insertions, 1 deletions
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);
}