cdown / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone
0e1b67
From afe6545483a881ccde41dcaa6718c71c74b38d7b Mon Sep 17 00:00:00 2001
0e1b67
From: Sven Wiltink <swiltink@transip.nl>
0e1b67
Date: Fri, 1 May 2020 16:35:40 +0200
0e1b67
Subject: [PATCH 46/55] lsblk: Fall back to ID_SERIAL
0e1b67
0e1b67
In some cases ID_SERIAL_SHORT isn't provided by libudev, but ID_SERIAL
0e1b67
is. An example of this are virtio devices. See the output of udevadm
0e1b67
info:
0e1b67
P: /devices/pci0000:00/0000:00:06.0/virtio2/block/vdb
0e1b67
N: vdb
0e1b67
S: disk/by-id/virtio-08491434ee711d3420e9
0e1b67
S: disk/by-path/pci-0000:00:06.0
0e1b67
S: disk/by-path/virtio-pci-0000:00:06.0
0e1b67
E: DEVLINKS=/dev/disk/by-id/virtio-08491434ee711d3420e9 /dev/disk/by-path/pci-0000:00:06.0 /dev/disk/by-path/virtio-pci-0000:00:06.0
0e1b67
E: DEVNAME=/dev/vdb
0e1b67
E: DEVPATH=/devices/pci0000:00/0000:00:06.0/virtio2/block/vdb
0e1b67
E: DEVTYPE=disk
0e1b67
E: ID_PATH=pci-0000:00:06.0
0e1b67
E: ID_PATH_TAG=pci-0000_00_06_0
0e1b67
E: ID_SERIAL=08491434ee711d3420e9
0e1b67
E: MAJOR=252
0e1b67
E: MINOR=16
0e1b67
E: SUBSYSTEM=block
0e1b67
E: TAGS=:systemd:
0e1b67
E: USEC_INITIALIZED=1403804
0e1b67
0e1b67
[RHEL-8 backport: add ID_SERIAL and also ID_SCSI_SERIAL to be compatible with upstream]
0e1b67
0e1b67
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1861670
0e1b67
Upstream: http://github.com/karelzak/util-linux/commit/e81d0f80068086147434fa947a4f723c00318772
0e1b67
Upstream: http://github.com/karelzak/util-linux/commit/de6c2a4aec140e6086e278688d97f4655ced1a9a
0e1b67
Signed-off-by: Karel Zak <kzak@redhat.com>
0e1b67
---
0e1b67
 misc-utils/lsblk.c | 8 +++++++-
0e1b67
 1 file changed, 7 insertions(+), 1 deletion(-)
0e1b67
0e1b67
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
0e1b67
index ae97f9f05..d0369d3e7 100644
0e1b67
--- a/misc-utils/lsblk.c
0e1b67
+++ b/misc-utils/lsblk.c
0e1b67
@@ -567,8 +567,14 @@ static int get_udev_properties(struct blkdev_cxt *cxt)
0e1b67
 		if (data)
0e1b67
 			cxt->wwn = xstrdup(data);
0e1b67
 
0e1b67
-		if ((data = udev_device_get_property_value(dev, "ID_SERIAL_SHORT")))
0e1b67
+		data = udev_device_get_property_value(dev, "ID_SCSI_SERIAL");
0e1b67
+		if (!data)
0e1b67
+			data = udev_device_get_property_value(dev, "ID_SERIAL_SHORT");
0e1b67
+		if (!data)
0e1b67
+			data = udev_device_get_property_value(dev, "ID_SERIAL");
0e1b67
+		if (data)
0e1b67
 			cxt->serial = xstrdup(data);
0e1b67
+
0e1b67
 		udev_device_unref(dev);
0e1b67
 		cxt->probed = 1;
0e1b67
 		DBG(DEV, ul_debugobj(cxt, "%s: found udev properties", cxt->name));
0e1b67
-- 
0e1b67
2.29.2
0e1b67