diff -Nru lshw-02.18.85/debian/changelog lshw-02.18.85/debian/changelog --- lshw-02.18.85/debian/changelog 2020-03-21 13:28:51.000000000 +0100 +++ lshw-02.18.85/debian/changelog 2020-12-17 10:34:41.000000000 +0100 @@ -1,3 +1,13 @@ +lshw (02.18.85-0.3ubuntu2.20.10.1) groovy; urgency=medium + + * Add cherry-picked patches for NMVe support (LP: #1826737): + - d/p/lp1826737-code-clean-up.patch + - d/p/lp1826737-implement-NVMe-scanning.patch + - d/p/lp1826737-align-physical-ID-with-NVMe-namespace.patch + - d/p/lp1826737-treat-NVMe-namespaces-like-disks.patch + + -- Victor Manuel Tapia King Thu, 17 Dec 2020 10:34:41 +0100 + lshw (02.18.85-0.3ubuntu2) focal; urgency=medium * No-change rebuild for libgcc-s1 package name change. diff -Nru lshw-02.18.85/debian/patches/lp1826737-align-physical-ID-with-NVMe-namespace.patch lshw-02.18.85/debian/patches/lp1826737-align-physical-ID-with-NVMe-namespace.patch --- lshw-02.18.85/debian/patches/lp1826737-align-physical-ID-with-NVMe-namespace.patch 1970-01-01 01:00:00.000000000 +0100 +++ lshw-02.18.85/debian/patches/lp1826737-align-physical-ID-with-NVMe-namespace.patch 2020-12-17 10:34:41.000000000 +0100 @@ -0,0 +1,25 @@ +From 9d5eb0dcbe814f4d55f2718b039b4bdc024ac0e4 Mon Sep 17 00:00:00 2001 +From: Lyonel Vincent +Date: Wed, 18 Mar 2020 15:22:37 +0100 +Subject: [PATCH] align physical ID with NVMe namespace + +Bug-Ubuntu: https://launchpad.net/bugs/1826737 +--- + src/core/nvme.cc | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/core/nvme.cc b/src/core/nvme.cc +index 89a3808..aec4420 100644 +--- a/src/core/nvme.cc ++++ b/src/core/nvme.cc +@@ -38,6 +38,7 @@ bool scan_nvme(hwNode & n) + for(unsigned long long i=1; e.hassubdir(e.name()+"n"+tostring(i)); i++) { + hwNode ns("namespace", hw::disk); + ns.claim(); ++ ns.setPhysId(i); + ns.setLogicalName(e.name()+"n"+tostring(i)); + scan_partitions(ns); + device.addChild(ns); +-- +2.25.1 + diff -Nru lshw-02.18.85/debian/patches/lp1826737-code-clean-up.patch lshw-02.18.85/debian/patches/lp1826737-code-clean-up.patch --- lshw-02.18.85/debian/patches/lp1826737-code-clean-up.patch 1970-01-01 01:00:00.000000000 +0100 +++ lshw-02.18.85/debian/patches/lp1826737-code-clean-up.patch 2020-12-17 10:34:41.000000000 +0100 @@ -0,0 +1,40 @@ +From 45db7ddd50b9d4197c82c49d0c1c32f616539a83 Mon Sep 17 00:00:00 2001 +From: Lyonel Vincent +Date: Thu, 26 Dec 2019 00:04:17 +0100 +Subject: [PATCH] code clean-up + +Bug-Ubuntu: https://launchpad.net/bugs/1826737 +--- + src/core/sysfs.cc | 2 +- + src/core/sysfs.h | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/core/sysfs.cc b/src/core/sysfs.cc +index 06bce8e..f9ff650 100644 +--- a/src/core/sysfs.cc ++++ b/src/core/sysfs.cc +@@ -285,7 +285,7 @@ entry::~entry() + delete This; + } + +-bool entry::hassubdir(const string & s) ++bool entry::hassubdir(const string & s) const + { + return exists(This->devpath + "/" + s); + } +diff --git a/src/core/sysfs.h b/src/core/sysfs.h +index 5f28d0c..c93f316 100644 +--- a/src/core/sysfs.h ++++ b/src/core/sysfs.h +@@ -21,7 +21,7 @@ namespace sysfs + entry(const entry &); + ~entry(); + +- bool hassubdir(const string &); ++ bool hassubdir(const string &) const; + string name() const; + string businfo() const; + string driver() const; +-- +2.25.1 + diff -Nru lshw-02.18.85/debian/patches/lp1826737-implement-NVMe-scanning.patch lshw-02.18.85/debian/patches/lp1826737-implement-NVMe-scanning.patch --- lshw-02.18.85/debian/patches/lp1826737-implement-NVMe-scanning.patch 1970-01-01 01:00:00.000000000 +0100 +++ lshw-02.18.85/debian/patches/lp1826737-implement-NVMe-scanning.patch 2020-12-17 10:34:41.000000000 +0100 @@ -0,0 +1,265 @@ +From 68ebc7d3d201cfeebf8063522d38209f482cade5 Mon Sep 17 00:00:00 2001 +From: Lyonel Vincent +Date: Wed, 18 Mar 2020 15:17:28 +0100 +Subject: [PATCH] implement NVMe scanning + +Bug-Ubuntu: https://launchpad.net/bugs/1826737 +--- + src/core/Makefile | 2 +- + src/core/main.cc | 4 ++++ + src/core/network.cc | 4 ++-- + src/core/nvme.cc | 53 ++++++++++++++++++++++++++++++++++++++++++ + src/core/nvme.h | 8 +++++++ + src/core/partitions.cc | 21 +++++++++++------ + src/core/sysfs.cc | 27 ++++++++++++++++++++- + src/core/sysfs.h | 3 +++ + 8 files changed, 111 insertions(+), 11 deletions(-) + create mode 100644 src/core/nvme.cc + create mode 100644 src/core/nvme.h + +--- a/src/core/Makefile ++++ b/src/core/Makefile +@@ -8,7 +8,7 @@ + LDSTATIC= + LIBS= + +-OBJS = hw.o main.o print.o mem.o dmi.o device-tree.o cpuinfo.o osutils.o pci.o version.o cpuid.o ide.o cdrom.o pcmcia-legacy.o scsi.o s390.o disk.o spd.o network.o isapnp.o pnp.o fb.o options.o usb.o sysfs.o display.o heuristics.o parisc.o cpufreq.o partitions.o blockio.o lvm.o ideraid.o pcmcia.o volumes.o mounts.o smp.o abi.o jedec.o dump.o fat.o virtio.o vio.o ++OBJS = hw.o main.o print.o mem.o dmi.o device-tree.o cpuinfo.o osutils.o pci.o version.o cpuid.o ide.o cdrom.o pcmcia-legacy.o scsi.o s390.o disk.o spd.o network.o isapnp.o pnp.o fb.o options.o usb.o sysfs.o display.o heuristics.o parisc.o cpufreq.o partitions.o blockio.o lvm.o ideraid.o pcmcia.o volumes.o mounts.o smp.o abi.o jedec.o dump.o fat.o virtio.o vio.o nvme.o + ifeq ($(SQLITE), 1) + OBJS+= db.o + endif +--- a/src/core/main.cc ++++ b/src/core/main.cc +@@ -43,6 +43,7 @@ + #include "mounts.h" + #include "virtio.h" + #include "vio.h" ++#include "nvme.h" + #include "smp.h" + #include "abi.h" + #include "s390.h" +@@ -132,6 +133,9 @@ + status("SCSI"); + if (enabled("scsi")) + scan_scsi(computer); ++ status("NVMe"); ++ if (enabled("nvme")) ++ scan_nvme(computer); + status("S/390 devices"); + if (enabled("s390")) + scan_s390_devices(computer); +--- a/src/core/network.cc ++++ b/src/core/network.cc +@@ -372,10 +372,10 @@ + interface.claim(); + interface.addHint("icon", string("network")); + +- string businfo = sysfs::entry::byClass("net", interface.getLogicalName()).businfo(); ++ string businfo = sysfs::entry::byClass("net", interface.getLogicalName()).leaf().businfo(); + if (businfo!="") + interface.setBusInfo(businfo); +- interface.setModalias(sysfs::entry::byClass("net", interface.getLogicalName()).modalias()); ++ interface.setModalias(sysfs::entry::byClass("net", interface.getLogicalName()).leaf().modalias()); + + //scan_mii(fd, interface); + scan_ip(interface); +--- /dev/null ++++ b/src/core/nvme.cc +@@ -0,0 +1,53 @@ ++#include "version.h" ++#include "hw.h" ++#include "sysfs.h" ++#include "osutils.h" ++#include "nvme.h" ++#include "partitions.h" ++ ++#include ++#include ++ ++__ID("@(#) $Id$"); ++ ++using namespace std; ++ ++bool scan_nvme(hwNode & n) ++{ ++ vector < sysfs::entry > entries = sysfs::entries_by_class("nvme"); ++ ++ if (entries.empty()) ++ return false; ++ ++ for (vector < sysfs::entry >::iterator it = entries.begin(); ++ it != entries.end(); ++it) ++ { ++ const sysfs::entry & e = *it; ++ ++ hwNode device(e.name(), hw::storage); ++ device.claim(); ++ device.setLogicalName(e.name()); ++ device.setDescription("NVMe device"); ++ device.setProduct(e.string_attr("model")); ++ device.setSerial(e.string_attr("serial")); ++ device.setVersion(e.string_attr("firmware_rev")); ++ device.setConfig("nqn",e.string_attr("subsysnqn")); ++ device.setConfig("state",e.string_attr("state")); ++ device.setModalias(e.modalias()); ++ ++ for(unsigned long long i=1; e.hassubdir(e.name()+"n"+tostring(i)); i++) { ++ hwNode ns("namespace", hw::disk); ++ ns.claim(); ++ ns.setLogicalName(e.name()+"n"+tostring(i)); ++ scan_partitions(ns); ++ device.addChild(ns); ++ } ++ ++ if(hwNode *child = n.findChildByBusInfo(e.leaf().businfo())) { ++ child->addChild(device); ++ } else ++ n.addChild(device); ++ } ++ ++ return true; ++} +--- /dev/null ++++ b/src/core/nvme.h +@@ -0,0 +1,8 @@ ++#ifndef _NVME_H_ ++#define _NVME_H_ ++ ++#include "hw.h" ++ ++bool scan_nvme(hwNode &); ++ ++#endif +--- a/src/core/partitions.cc ++++ b/src/core/partitions.cc +@@ -30,6 +30,7 @@ + #include + #include + #include ++#include + + __ID("@(#) $Id$"); + +@@ -292,23 +293,29 @@ + + static unsigned int lastlogicalpart = 5; + ++static string partitionname(string disk, unsigned int n) ++{ ++ if(isdigit(disk[disk.length()-1])) ++ return disk+"p"+tostring(n); ++ else ++ return disk+tostring(n); ++} ++ + static bool guess_logicalname(source & s, const hwNode & disk, unsigned int n, hwNode & partition) + { + struct stat buf; +- char name[10]; + int dev = 0; + +- snprintf(name, sizeof(name), "%d", n); + if(disk.getBusInfo()!="") +- partition.setBusInfo(disk.getBusInfo()+string(",")+string(name)); ++ partition.setBusInfo(disk.getBusInfo()+string(",")+tostring(n)); + + if(fstat(s.fd, &buf)!=0) return false; + if(!S_ISBLK(buf.st_mode)) return false; + + if(s.diskname!="") +- dev = open_dev(buf.st_rdev + n, S_IFBLK, s.diskname+string(name)); ++ dev = open_dev(buf.st_rdev + n, S_IFBLK, partitionname(s.diskname, n)); + else +- dev = open_dev(buf.st_rdev + n, S_IFBLK, disk.getLogicalName()+string(name)); ++ dev = open_dev(buf.st_rdev + n, S_IFBLK, partitionname(disk.getLogicalName(), n)); + + if(dev>=0) + { +@@ -333,9 +340,9 @@ + { + partition.claim(); + if(s.diskname!="") +- partition.setLogicalName(s.diskname+string(name)); ++ partition.setLogicalName(partitionname(s.diskname,n)); + else +- partition.setLogicalName(disk.getLogicalName()+string(name)); ++ partition.setLogicalName(partitionname(disk.getLogicalName(),n)); + return true; + } + } +--- a/src/core/sysfs.cc ++++ b/src/core/sysfs.cc +@@ -17,6 +17,7 @@ + #include + #include + ++ + __ID("@(#) $Id$"); + + using namespace sysfs; +@@ -226,6 +227,13 @@ + return result; + } + ++entry entry::leaf() const ++{ ++ if (hassubdir("device")) ++ return entry(This->devpath+"/device"); ++ ++ return entry(This->devpath); ++} + + string entry::driver() const + { +@@ -245,7 +253,7 @@ + + entry entry::byClass(string devclass, string devname) + { +- entry e(fs.path + "/class/" + devclass + "/" + devname + "/device"); ++ entry e(fs.path + "/class/" + devclass + "/" + devname); + return e; + } + +@@ -386,6 +394,23 @@ + return result; + } + ++vector < entry > sysfs::entries_by_class(const string & classname) ++{ ++ vector < entry > result; ++ ++ if (!pushd(fs.path + "/class/" + classname)) ++ return result; ++ ++ struct dirent **namelist; ++ int count; ++ count = scandir(".", &namelist, selectlink, alphasort); ++ for (int i = 0; i < count; i ++) ++ { ++ entry e = sysfs::entry::byClass(classname, namelist[i]->d_name); ++ result.push_back(e); ++ } ++ return result; ++} + + bool scan_sysfs(hwNode & n) + { +--- a/src/core/sysfs.h ++++ b/src/core/sysfs.h +@@ -21,6 +21,8 @@ + entry(const entry &); + ~entry(); + ++ entry leaf() const; ++ + bool hassubdir(const string &) const; + string name() const; + string businfo() const; +@@ -42,6 +44,7 @@ + }; + + vector < entry > entries_by_bus(const string & busname); ++ vector < entry > entries_by_class(const string & classname); + + } // namespace sysfs + diff -Nru lshw-02.18.85/debian/patches/lp1826737-treat-NVMe-namespaces-like-disks.patch lshw-02.18.85/debian/patches/lp1826737-treat-NVMe-namespaces-like-disks.patch --- lshw-02.18.85/debian/patches/lp1826737-treat-NVMe-namespaces-like-disks.patch 1970-01-01 01:00:00.000000000 +0100 +++ lshw-02.18.85/debian/patches/lp1826737-treat-NVMe-namespaces-like-disks.patch 2020-12-17 10:34:41.000000000 +0100 @@ -0,0 +1,37 @@ +From 5dd11ac1ffc0262468f3efdb65005c960b7afa60 Mon Sep 17 00:00:00 2001 +From: Lyonel Vincent +Date: Wed, 18 Mar 2020 15:56:15 +0100 +Subject: [PATCH] treat NVMe namespaces like disks + +Bug-Ubuntu: https://launchpad.net/bugs/1826737 +--- + src/core/nvme.cc | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/core/nvme.cc b/src/core/nvme.cc +index aec4420..2697da7 100644 +--- a/src/core/nvme.cc ++++ b/src/core/nvme.cc +@@ -3,7 +3,7 @@ + #include "sysfs.h" + #include "osutils.h" + #include "nvme.h" +-#include "partitions.h" ++#include "disk.h" + + #include + #include +@@ -39,8 +39,9 @@ bool scan_nvme(hwNode & n) + hwNode ns("namespace", hw::disk); + ns.claim(); + ns.setPhysId(i); ++ ns.setDescription("NVMe namespace"); + ns.setLogicalName(e.name()+"n"+tostring(i)); +- scan_partitions(ns); ++ scan_disk(ns); + device.addChild(ns); + } + +-- +2.25.1 + diff -Nru lshw-02.18.85/debian/patches/series lshw-02.18.85/debian/patches/series --- lshw-02.18.85/debian/patches/series 2020-03-21 13:28:51.000000000 +0100 +++ lshw-02.18.85/debian/patches/series 2020-12-17 10:34:41.000000000 +0100 @@ -10,3 +10,7 @@ add-missing-ethlink-standards.patch cross.patch 82393aa9b59307a443677df7340a1dd38847a5ef.patch +lp1826737-code-clean-up.patch +lp1826737-implement-NVMe-scanning.patch +lp1826737-align-physical-ID-with-NVMe-namespace.patch +lp1826737-treat-NVMe-namespaces-like-disks.patch