From: Peter Rajnoha Date: Fri, 21 Sep 2012 12:23:32 +0000 (+0200) Subject: lsblk: fix reporting of 'part' type X-Git-Tag: v2.23-rc1~663 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d687180b2efc4331bb9ce3145c207de0606815e;p=thirdparty%2Futil-linux.git 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 --- 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);