]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsblk: fix reporting of 'part' type
authorPeter Rajnoha <prajnoha@redhat.com>
Fri, 21 Sep 2012 12:23:32 +0000 (14:23 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 2 Oct 2012 08:23:51 +0000 (10:23 +0200)
Partitions are incorrectly marked with 'disk' type on
lsblk output while it should be marked as 'part' type.

Before:
$ lsblk /dev/sda
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  128M  0 disk
`-sda1   8:1    0   64M  0 disk

With this patch applied:
$ lsblk /dev/sda
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  128M  0 disk
`-sda1   8:1    0   64M  0 part

Signed-off-by: Peter Rajnoha <prajnoha@redhat.com>
misc-utils/lsblk.c

index 2662460a4245bed09a42bfedacd47b4ef7dee145..26dfaf9f0c0277713062cefc4c7b8b1ffaa100d5 100644 (file)
@@ -556,12 +556,12 @@ static char *get_type(struct blkdev_cxt *cxt)
                res = md_level ? md_level : xstrdup("md");
 
        } else {
-               const char *type;
+               const char *type = NULL;
                int x = 0;
 
-               sysfs_read_int(&cxt->sysfs, "device/type", &x);
+               if (!sysfs_read_int(&cxt->sysfs, "device/type", &x))
+                       type = blkdev_scsi_type_to_name(x);
 
-               type = blkdev_scsi_type_to_name(x);
                if (!type)
                        type = cxt->partition ? "part" : "disk";
                res = xstrdup(type);