From 8d687180b2efc4331bb9ce3145c207de0606815e Mon Sep 17 00:00:00 2001 From: Peter Rajnoha Date: Fri, 21 Sep 2012 14:23:32 +0200 Subject: [PATCH] lsblk: fix reporting of 'part' type 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 --- misc-utils/lsblk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index 2662460a42..26dfaf9f0c 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -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); -- 2.47.3