]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsblk: show all empty, except loopdevs
authorKarel Zak <kzak@redhat.com>
Wed, 9 Sep 2020 12:50:02 +0000 (14:50 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 9 Sep 2020 12:50:02 +0000 (14:50 +0200)
This patch improves the previous commit to accept also another empty devices.

Addresses: https://github.com/karelzak/util-linux/issues/1118
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/lsblk.c

index 82eae6bad883aca669248e8962f565ea12d40fb3..1c4bae5bf37d564a0ab009cbeb7dc36067c36709 100644 (file)
@@ -1152,11 +1152,16 @@ static void devtree_to_scols(struct lsblk_devtree *tr, struct libscols_table *ta
 
 static int ignore_empty(struct lsblk_device *dev)
 {
-       if (dev->size != 0)
+       /* show all non-empty devices */
+       if (dev->size)
                return 0;
-       if (dev->maj == LOOPDEV_MAJOR && loopdev_has_backing_file(dev->filename))
-               return 0;
-       return 1;
+
+       /* ignore empty loop devices without backing file */
+       if (dev->maj == LOOPDEV_MAJOR &&
+           !loopdev_has_backing_file(dev->filename))
+               return 1;
+
+       return 0;
 }
 
 /*