]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsblk: use blkdev_scsi_type_to_name()
authorSami Kerola <kerolasa@iki.fi>
Mon, 11 Jun 2012 19:22:38 +0000 (21:22 +0200)
committerSami Kerola <kerolasa@iki.fi>
Mon, 11 Jun 2012 20:06:06 +0000 (22:06 +0200)
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 <kerolasa@iki.fi>
misc-utils/Makefile.am
misc-utils/lsblk.c

index 9dd358365d246021539f0ada206baf88641471d6..52d7e98648daf2156b01fabdcd05bdba9ed1f636 100644 (file)
@@ -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
index 9e894ef27e26209df4f4dde4ff2406bf0fef0557..6746f85a113a5ff3da2b0e9e4bcd1aa9cbcf775b 100644 (file)
@@ -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++)