From 1edd8af70b4794c796d0faed0cf763ff3474b92e Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Mon, 11 Jun 2012 21:22:38 +0200 Subject: [PATCH] lsblk: use blkdev_scsi_type_to_name() Replace inline version of similar, but less complete, functionality with the lib/blkdev.c function. The function will inform if a type is unknown, which appears as hex string value. Signed-off-by: Sami Kerola --- misc-utils/Makefile.am | 4 +++- misc-utils/lsblk.c | 18 +----------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/misc-utils/Makefile.am b/misc-utils/Makefile.am index 9dd358365d..52d7e98648 100644 --- a/misc-utils/Makefile.am +++ b/misc-utils/Makefile.am @@ -56,9 +56,11 @@ dist_man_MANS += lsblk.8 lsblk_SOURCES = \ lsblk.c \ $(top_srcdir)/lib/at.c \ + $(top_srcdir)/lib/blkdev.c \ $(top_srcdir)/lib/canonicalize.c \ - $(top_srcdir)/lib/mbsalign.c \ + $(top_srcdir)/lib/linux_version.c \ $(top_srcdir)/lib/mangle.c \ + $(top_srcdir)/lib/mbsalign.c \ $(top_srcdir)/lib/strutils.c \ $(top_srcdir)/lib/sysfs.c \ $(top_srcdir)/lib/tt.c diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index 9e894ef27e..6746f85a11 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -512,24 +512,8 @@ static char *get_type(struct blkdev_cxt *cxt) } else { const char *type = cxt->partition ? "part" : "disk"; int x = 0; - sysfs_read_int(&cxt->sysfs, "device/type", &x); - - switch (x) { - case 0x0c: /* TYPE_RAID */ - type = "raid"; break; - case 0x01: /* TYPE_TAPE */ - type = "raid"; break; - case 0x04: /* TYPE_WORM */ - case 0x05: /* TYPE_ROM */ - type = "rom"; break; - case 0x07: /* TYPE_MOD */ - type = "mo-disk"; break; - case 0x0e: /* TYPE_RBC */ - type = "rbc"; break; - } - - res = xstrdup(type); + res = blkdev_scsi_type_to_name(x); } for (p = res; p && *p; p++) -- 2.47.2