diff --git a/python-libmount.changes b/python-libmount.changes index 78edcf5..7abc36a 100644 --- a/python-libmount.changes +++ b/python-libmount.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Feb 9 15:08:22 CET 2018 - sbrabec@suse.com + +- Fix lsblk on NVMe + (bsc#1078662, util-linux-sysfs-nvme-devno.patch). + ------------------------------------------------------------------- Wed Jan 31 20:34:56 CET 2018 - sbrabec@suse.com diff --git a/python-libmount.spec b/python-libmount.spec index b16a042..1f09d10 100644 --- a/python-libmount.spec +++ b/python-libmount.spec @@ -170,6 +170,8 @@ Patch4: util_linux_bigendian.patch Patch5: util-linux-cramfs.patch # PATCH-FIX-UPSTREAM util-linux-fincore-count.patch sbrabec@suse.com -- Disable bad test fincore/count. Patch6: util-linux-fincore-count.patch +# PATCH-FIX-UPSTREAM util-linux-sysfs-nvme-devno.patch bsc1078662 sbrabec@suse.com -- Fix lsblk on NVMe. +Patch7: util-linux-sysfs-nvme-devno.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build # @@ -413,6 +415,7 @@ library. %patch4 -p1 %patch5 -p1 %patch6 -p1 +%patch7 -p1 # # setctsid cp -p %{S:22} %{S:23} . diff --git a/util-linux-sysfs-nvme-devno.patch b/util-linux-sysfs-nvme-devno.patch new file mode 100644 index 0000000..2f27cd0 --- /dev/null +++ b/util-linux-sysfs-nvme-devno.patch @@ -0,0 +1,157 @@ +From d51f05bfecb299a830897106460bf395be440c0a Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Fri, 9 Feb 2018 14:18:18 +0100 +Subject: [PATCH] lsblk: try device/dev to read devno + +Now sysfs_devname_to_devno() reads devno from /dev or +/sys/block//dev, but it seems that NVME uses +/sys/block//device/dev. + +Reported-by: Potnuri Bharat Teja +Signed-off-by: Karel Zak +--- + lib/sysfs.c | 97 ++++++++++++++++++++++++++++++++++--------------------------- + 1 file changed, 54 insertions(+), 43 deletions(-) + +diff --git a/lib/sysfs.c b/lib/sysfs.c +index e8125e511..b1b67c59f 100644 +--- a/lib/sysfs.c ++++ b/lib/sysfs.c +@@ -48,10 +48,28 @@ char *sysfs_devno_path(dev_t devno, char *buf, size_t bufsiz) + return sysfs_devno_attribute_path(devno, buf, bufsiz, NULL); + } + ++static dev_t read_devno(const char *path) ++{ ++ FILE *f; ++ int maj = 0, min = 0; ++ dev_t dev = 0; ++ ++ f = fopen(path, "r" UL_CLOEXECSTR); ++ if (!f) ++ return 0; ++ ++ if (fscanf(f, "%d:%d", &maj, &min) == 2) ++ dev = makedev(maj, min); ++ fclose(f); ++ return dev; ++} ++ + dev_t sysfs_devname_to_devno(const char *name, const char *parent) + { +- char buf[PATH_MAX], *path = NULL; ++ char buf[PATH_MAX]; ++ char *_name = NULL; /* name as encoded in sysfs */ + dev_t dev = 0; ++ int len; + + if (strncmp("/dev/", name, 5) == 0) { + /* +@@ -59,69 +77,62 @@ dev_t sysfs_devname_to_devno(const char *name, const char *parent) + */ + struct stat st; + +- if (stat(name, &st) == 0) ++ if (stat(name, &st) == 0) { + dev = st.st_rdev; +- else +- name += 5; /* unaccesible, or not node in /dev */ ++ goto done; ++ } ++ name += 5; /* unaccesible, or not node in /dev */ + } + +- if (!dev && parent && strncmp("dm-", name, 3)) { ++ _name = strdup(name); ++ if (!_name) ++ goto done; ++ sysfs_devname_dev_to_sys(_name); ++ ++ if (parent && strncmp("dm-", name, 3)) { + /* + * Create path to /sys/block///dev + */ +- char *_name = strdup(name), *_parent = strdup(parent); +- int len; ++ char *_parent = strdup(parent); + +- if (!_name || !_parent) { +- free(_name); ++ if (!_parent) { + free(_parent); +- return 0; ++ goto done; + } +- sysfs_devname_dev_to_sys(_name); + sysfs_devname_dev_to_sys(_parent); + + len = snprintf(buf, sizeof(buf), + _PATH_SYS_BLOCK "/%s/%s/dev", _parent, _name); +- free(_name); + free(_parent); + if (len < 0 || (size_t) len >= sizeof(buf)) +- return 0; +- path = buf; ++ goto done; + +- } else if (!dev) { +- /* +- * Create path to /sys/block//dev +- */ +- char *_name = strdup(name); +- int len; +- +- if (!_name) +- return 0; +- +- sysfs_devname_dev_to_sys(_name); +- len = snprintf(buf, sizeof(buf), +- _PATH_SYS_BLOCK "/%s/dev", _name); +- free(_name); +- if (len < 0 || (size_t) len >= sizeof(buf)) +- return 0; +- path = buf; ++ /* don't try anything else for dm-* */ ++ dev = read_devno(buf); ++ goto done; + } + +- if (path) { ++ /* ++ * Read from /sys/block//dev ++ */ ++ len = snprintf(buf, sizeof(buf), ++ _PATH_SYS_BLOCK "/%s/dev", _name); ++ if (len < 0 || (size_t) len >= sizeof(buf)) ++ goto done; ++ dev = read_devno(buf); ++ ++ if (!dev) { + /* +- * read devno from sysfs ++ * Read from /sys/block//device/dev + */ +- FILE *f; +- int maj = 0, min = 0; +- +- f = fopen(path, "r" UL_CLOEXECSTR); +- if (!f) +- return 0; +- +- if (fscanf(f, "%d:%d", &maj, &min) == 2) +- dev = makedev(maj, min); +- fclose(f); ++ len = snprintf(buf, sizeof(buf), ++ _PATH_SYS_BLOCK "/%s/device/dev", _name); ++ if (len < 0 || (size_t) len >= sizeof(buf)) ++ goto done; ++ dev = read_devno(buf); + } ++done: ++ free(_name); + return dev; + } + +-- +2.16.1 + diff --git a/util-linux-systemd.changes b/util-linux-systemd.changes index 78edcf5..7abc36a 100644 --- a/util-linux-systemd.changes +++ b/util-linux-systemd.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Feb 9 15:08:22 CET 2018 - sbrabec@suse.com + +- Fix lsblk on NVMe + (bsc#1078662, util-linux-sysfs-nvme-devno.patch). + ------------------------------------------------------------------- Wed Jan 31 20:34:56 CET 2018 - sbrabec@suse.com diff --git a/util-linux-systemd.spec b/util-linux-systemd.spec index 10e20c1..2064775 100644 --- a/util-linux-systemd.spec +++ b/util-linux-systemd.spec @@ -170,6 +170,8 @@ Patch4: util_linux_bigendian.patch Patch5: util-linux-cramfs.patch # PATCH-FIX-UPSTREAM util-linux-fincore-count.patch sbrabec@suse.com -- Disable bad test fincore/count. Patch6: util-linux-fincore-count.patch +# PATCH-FIX-UPSTREAM util-linux-sysfs-nvme-devno.patch bsc1078662 sbrabec@suse.com -- Fix lsblk on NVMe. +Patch7: util-linux-sysfs-nvme-devno.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build # @@ -413,6 +415,7 @@ library. %patch4 -p1 %patch5 -p1 %patch6 -p1 +%patch7 -p1 # # setctsid cp -p %{S:22} %{S:23} . diff --git a/util-linux.changes b/util-linux.changes index 78edcf5..7abc36a 100644 --- a/util-linux.changes +++ b/util-linux.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Feb 9 15:08:22 CET 2018 - sbrabec@suse.com + +- Fix lsblk on NVMe + (bsc#1078662, util-linux-sysfs-nvme-devno.patch). + ------------------------------------------------------------------- Wed Jan 31 20:34:56 CET 2018 - sbrabec@suse.com diff --git a/util-linux.spec b/util-linux.spec index e91bfd3..1992c3e 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -170,6 +170,8 @@ Patch4: util_linux_bigendian.patch Patch5: util-linux-cramfs.patch # PATCH-FIX-UPSTREAM util-linux-fincore-count.patch sbrabec@suse.com -- Disable bad test fincore/count. Patch6: util-linux-fincore-count.patch +# PATCH-FIX-UPSTREAM util-linux-sysfs-nvme-devno.patch bsc1078662 sbrabec@suse.com -- Fix lsblk on NVMe. +Patch7: util-linux-sysfs-nvme-devno.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build # @@ -413,6 +415,7 @@ library. %patch4 -p1 %patch5 -p1 %patch6 -p1 +%patch7 -p1 # # setctsid cp -p %{S:22} %{S:23} .