]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsblk: follow kernel for inverse tree
authorKarel Zak <kzak@redhat.com>
Wed, 1 Apr 2015 10:06:41 +0000 (12:06 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 1 Apr 2015 10:06:41 +0000 (12:06 +0200)
For multi-path devices kernel defines dependence between the device
and whole-list:

$ ls /sys/block/dm-0/slaves/
sdb

but lsblk inserts partition into the tree:

$ lsblk -s -oNAME,KNAME /dev/dm-1
mpatha1   dm-1
└─mpatha  dm-0
  └─sdb1  sdb1     <--- !
    └─sdb sdb

Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/lsblk.c

index 62540739e28f06ef27278115416de0d341d577eb..8781b96cd91c556aa104f275422b8e12abbc1d53 100644 (file)
@@ -1371,7 +1371,9 @@ static int list_deps(struct blkdev_cxt *cxt)
                else if (!set_cxt(&dep, cxt, NULL, d->d_name)) {
                        DBG(CXT, ul_debugobj(cxt, "%s: %s: dependence is whole-disk",
                                                                cxt->name, d->d_name));
-                       process_blkdev(&dep, cxt, 1, NULL);
+                       /* For inverse tree we don't want to show partitions
+                        * if the dependence is pn whle-disk */
+                       process_blkdev(&dep, cxt, lsblk->inverse ? 0 : 1, NULL);
                }
                reset_blkdev_cxt(&dep);
        }