Hello community,

here is the log from the commit of package lshw for openSUSE:Leap:15.2 checked 
in at 2020-03-18 00:36:46
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Leap:15.2/lshw (Old)
 and      /work/SRC/openSUSE:Leap:15.2/.lshw.new.3160 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "lshw"

Wed Mar 18 00:36:46 2020 rev:23 rq:785981 version:B.02.18+git.20191228

Changes:
--------
--- /work/SRC/openSUSE:Leap:15.2/lshw/lshw.changes      2020-02-22 
17:53:18.185875726 +0100
+++ /work/SRC/openSUSE:Leap:15.2/.lshw.new.3160/lshw.changes    2020-03-18 
00:36:51.549416163 +0100
@@ -1,0 +2,16 @@
+Mon Mar 16 12:14:54 UTC 2020 - Martin Pluskal <mplus...@suse.com>
+
+- Update to version B.02.18+git.20191228:
+  * fix #755: handle invalid FAT
+  * code clean-up
+  * volumes: Add support for detecting Apple APFS fstype
+  * partitions: Add Apple APFS GUID
+  * specfile: Fix version issue
+  * Do not show modified time with -notime option
+  * Update help message and man page
+- Drop upstreamed patches:
+  * lshw-help-man.patch
+  * lshw-modified-time.patch
+- Add lshw-nvme.patch to support nvme devices bsc#1161323
+
+-------------------------------------------------------------------

Old:
----
  lshw-B.02.18+git.20190613.tar.xz
  lshw-help-man.patch
  lshw-modified-time.patch

New:
----
  lshw-B.02.18+git.20191228.tar.xz
  lshw-nvme.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ lshw.spec ++++++
--- /var/tmp/diff_new_pack.Vtzx7o/_old  2020-03-18 00:36:52.057416483 +0100
+++ /var/tmp/diff_new_pack.Vtzx7o/_new  2020-03-18 00:36:52.061416485 +0100
@@ -18,7 +18,7 @@
 
 
 Name:           lshw
-Version:        B.02.18+git.20190613
+Version:        B.02.18+git.20191228
 Release:        0
 Summary:        HardWare LiSter
 License:        GPL-2.0-only
@@ -29,9 +29,8 @@
 Source2:        lshw.png
 # PATCH-FIX-UPSTREAM lshw-display-latest-version.patch lshw-help-man.patch 
lshw-modified-time.patch bsc##1130818
 Patch1:         lshw-display-latest-version.patch
-Patch2:         lshw-help-man.patch
-Patch3:         lshw-modified-time.patch
 Patch4:         lshw-add-notime-option-to-manpage.patch
+Patch5:         lshw-nvme.patch
 BuildRequires:  gcc-c++
 BuildRequires:  hicolor-icon-theme
 BuildRequires:  libpng-devel

++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.Vtzx7o/_old  2020-03-18 00:36:52.097416507 +0100
+++ /var/tmp/diff_new_pack.Vtzx7o/_new  2020-03-18 00:36:52.097416507 +0100
@@ -1,4 +1,4 @@
 <servicedata>
 <service name="tar_scm">
                 <param name="url">https://github.com/lyonel/lshw.git</param>
-              <param 
name="changesrevision">9567d10e4eb1c561030444dd3b7fe50ebb755f3e</param></service></servicedata>
\ No newline at end of file
+              <param 
name="changesrevision">89b3b6b9ed03f22ca98954712db5a90acf2c6755</param></service></servicedata>
\ No newline at end of file

++++++ lshw-B.02.18+git.20190613.tar.xz -> lshw-B.02.18+git.20191228.tar.xz 
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lshw-B.02.18+git.20190613/lshw.spec.in 
new/lshw-B.02.18+git.20191228/lshw.spec.in
--- old/lshw-B.02.18+git.20190613/lshw.spec.in  2019-06-13 22:23:04.000000000 
+0200
+++ new/lshw-B.02.18+git.20191228/lshw.spec.in  2019-12-28 00:02:44.000000000 
+0100
@@ -57,6 +57,7 @@
   SBINDIR="%{_sbindir}" \
   MANDIR="%{_mandir}" \
   DATADIR="%{_datadir}" \
+  VERSION="%{version}" \
   all
 %if %{!?_without_gui:1}0
 %{__make} %{?_smp_mflags} \
@@ -64,6 +65,7 @@
   SBINDIR="%{_sbindir}" \
   MANDIR="%{_mandir}" \
   DATADIR="%{_datadir}" \
+  VERSION="%{version}" \
   gui
 %endif
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lshw-B.02.18+git.20190613/src/core/fat.cc 
new/lshw-B.02.18+git.20191228/src/core/fat.cc
--- old/lshw-B.02.18+git.20190613/src/core/fat.cc       2019-06-13 
22:23:04.000000000 +0200
+++ new/lshw-B.02.18+git.20191228/src/core/fat.cc       2019-12-28 
00:02:44.000000000 +0100
@@ -186,11 +186,6 @@
        if (vs.heads == 0)
                return false;
 
-       /* cluster size check */
-       if (vs.sectors_per_cluster == 0 ||
-           (vs.sectors_per_cluster & (vs.sectors_per_cluster-1)))
-               return false;
-
        /* media check */
        if (vs.media < 0xf8 && vs.media != 0xf0)
                return false;
@@ -200,6 +195,11 @@
                return false;
 
 valid:
+       /* cluster size check */
+       if (vs.sectors_per_cluster == 0 ||
+           (vs.sectors_per_cluster & (vs.sectors_per_cluster-1)))
+               return false;
+
        /* sector size check */
        sector_size_bytes = le_short(&vs.sector_size_bytes);
        if (sector_size_bytes != 0x200 && sector_size_bytes != 0x400 &&
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lshw-B.02.18+git.20190613/src/core/partitions.cc 
new/lshw-B.02.18+git.20191228/src/core/partitions.cc
--- old/lshw-B.02.18+git.20190613/src/core/partitions.cc        2019-06-13 
22:23:04.000000000 +0200
+++ new/lshw-B.02.18+git.20191228/src/core/partitions.cc        2019-12-28 
00:02:44.000000000 +0100
@@ -845,6 +845,12 @@
         partition.setVendor("Mac OS X");
       }
       else
+      if(p.PartitionTypeGUID == "7C3457EF-0000-11AA-AA11-00306543ECAC")
+      {
+        partition.setDescription("Apple APFS partition");
+        partition.setVendor("Mac OS X");
+      }
+      else
       if(p.PartitionTypeGUID == "6A898CC3-1DD2-11B2-99A6-080020736631")
       {
         partition.setDescription("OS X ZFS partition or Solaris /usr 
partition");
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lshw-B.02.18+git.20190613/src/core/sysfs.cc 
new/lshw-B.02.18+git.20191228/src/core/sysfs.cc
--- old/lshw-B.02.18+git.20190613/src/core/sysfs.cc     2019-06-13 
22:23:04.000000000 +0200
+++ new/lshw-B.02.18+git.20191228/src/core/sysfs.cc     2019-12-28 
00:02:44.000000000 +0100
@@ -285,7 +285,7 @@
   delete This;
 }
 
-bool entry::hassubdir(const string & s)
+bool entry::hassubdir(const string & s) const
 {
   return exists(This->devpath + "/" + s);
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lshw-B.02.18+git.20190613/src/core/sysfs.h 
new/lshw-B.02.18+git.20191228/src/core/sysfs.h
--- old/lshw-B.02.18+git.20190613/src/core/sysfs.h      2019-06-13 
22:23:04.000000000 +0200
+++ new/lshw-B.02.18+git.20191228/src/core/sysfs.h      2019-12-28 
00:02:44.000000000 +0100
@@ -21,7 +21,7 @@
       entry(const entry &);
       ~entry();
 
-      bool hassubdir(const string &);
+      bool hassubdir(const string &) const;
       string name() const;
       string businfo() const;
       string driver() const;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lshw-B.02.18+git.20190613/src/core/volumes.cc 
new/lshw-B.02.18+git.20191228/src/core/volumes.cc
--- old/lshw-B.02.18+git.20190613/src/core/volumes.cc   2019-06-13 
22:23:04.000000000 +0200
+++ new/lshw-B.02.18+git.20191228/src/core/volumes.cc   2019-12-28 
00:02:44.000000000 +0100
@@ -39,6 +39,7 @@
 static bool detect_fat(hwNode & n, source & s);
 static bool detect_hfsx(hwNode & n, source & s);
 static bool detect_hfs(hwNode & n, source & s);
+static bool detect_apfs(hwNode & n, source & s);
 static bool detect_ntfs(hwNode & n, source & s);
 static bool detect_swap(hwNode & n, source & s);
 
@@ -69,6 +70,7 @@
   {"mfs", "MacOS MFS", "", NULL},
   {"hfsplus", "MacOS HFS+", "secure,journaled", detect_hfsx},
   {"hfs", "MacOS HFS", "", detect_hfs},
+  {"apfs", "MacOS APFS", "", detect_apfs},
   {"luks", "Linux Unified Key Setup", "encrypted", detect_luks},
   {"swap", "Linux swap", "", detect_swap},
   { NULL, NULL, NULL, NULL }
@@ -651,8 +653,10 @@
   wtime = (time_t)(be_long(&vol->modifyDate) - HFSTIMEOFFSET);
   n.setConfig("created", datetime(mkfstime, false));   // creation time uses 
local time
   if (enabled("output:time"))
+  {
     n.setConfig("checked", datetime(fscktime));
-  n.setConfig("modified", datetime(wtime));
+    n.setConfig("modified", datetime(wtime));
+  }
 
   return true;
 }
@@ -742,12 +746,83 @@
     n.setConfig("created", datetime(mkfstime - HFSTIMEOFFSET, false)); // all 
dates use local time
   if(dumptime)
     n.setConfig("backup", datetime(dumptime - HFSTIMEOFFSET, false));
-  if(wtime)
+  if(wtime && enabled("output:time"))
     n.setConfig("modified", datetime(wtime - HFSTIMEOFFSET, false));
 
   return true;
 }
 
+#define APFS_CONTAINER_SUPERBLOCK_TYPE 1
+#define APFS_CONTAINER_SUPERBLOCK_SUBTYPE 0
+#define APFS_STANDARD_BLOCK_SIZE 4096
+
+/*
+ * This struct is much longer than this, but this seems
+ * to contain the useful bits (for now).
+ *
+ * All values are little-endian.
+ */
+struct apfs_super_block {
+  // Generic part to all APFS objects
+  uint64_t checksum;
+  uint64_t oid;
+  uint64_t xid;
+  uint16_t type;
+  uint16_t flags;
+  uint16_t subtype;
+  uint16_t pad;
+
+  // Specific to container header
+  uint32_t magic; // 'NXSB'
+  uint32_t block_size;
+  uint64_t block_count;
+  uint64_t features;
+  uint64_t read_only_features;
+  uint64_t incompatible_features;
+  uint8_t uuid[16];
+};
+
+static bool detect_apfs(hwNode & n, source & s)
+{
+  static char buffer[sizeof(apfs_super_block)];
+  source apfsvolume;
+  apfs_super_block *sb = (apfs_super_block*)buffer;
+  unsigned long block_size;
+
+  apfsvolume = s;
+
+  if(readlogicalblocks(apfsvolume, buffer, 0, 1)!=1)
+    return false;
+
+  if(le_long(&sb->magic) != 0x4253584eu) // 'NXSB'
+    return false;
+
+  if(le_short(&sb->type) != APFS_CONTAINER_SUPERBLOCK_TYPE)
+    return false;
+
+  if(le_short(&sb->subtype) != APFS_CONTAINER_SUPERBLOCK_SUBTYPE)
+    return false;
+
+  if(le_short(&sb->pad) != 0)
+    return false;
+
+  /*
+    * This check is pretty draconian, but should avoid false
+    * positives. Can be improved as more APFS documentation
+    * is published.
+  */
+  block_size = le_long(&sb->block_size);
+  if(block_size != APFS_STANDARD_BLOCK_SIZE)
+    return false;
+  
+  apfsvolume.blocksize = block_size;
+
+  n.setSize((unsigned long long)block_size * le_longlong(&sb->block_count));
+
+  // TODO: APFS contains many volumes and scanning these would be a further 
job.
+  return true;
+}
+
 struct mft_entry
 {
   char magic[4];
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lshw-B.02.18+git.20190613/src/lshw.1 
new/lshw-B.02.18+git.20191228/src/lshw.1
--- old/lshw-B.02.18+git.20190613/src/lshw.1    2019-06-13 22:23:04.000000000 
+0200
+++ new/lshw-B.02.18+git.20191228/src/lshw.1    2019-12-28 00:02:44.000000000 
+0100
@@ -53,7 +53,7 @@
 Outputs the device list showing bus information, detailing SCSI, USB, IDE and 
PCI addresses.
 .TP
 \fB-dump \fIfilename\fB\fR
-Dump collected information into a file (SQLite database).
+Display output and dump collected information into a file (SQLite database).
 .TP
 \fB-class \fIclass\fB\fR
 Only show the given class of hardware. \fIclass\fR can be found using \fBlshw 
-short\fR or \fBlshw -businfo\fR\&.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lshw-B.02.18+git.20190613/src/lshw.cc 
new/lshw-B.02.18+git.20191228/src/lshw.cc
--- old/lshw-B.02.18+git.20190613/src/lshw.cc   2019-06-13 22:23:04.000000000 
+0200
+++ new/lshw-B.02.18+git.20191228/src/lshw.cc   2019-12-28 00:02:44.000000000 
+0100
@@ -35,7 +35,7 @@
     fprintf(stderr, _("\t-X              use graphical interface\n"));
   fprintf(stderr, _("\noptions can be\n"));
 #ifdef SQLITE
-  fprintf(stderr, _("\t-dump OUTFILE   save hardware tree to a file\n"));
+  fprintf(stderr, _("\t-dump filename  displays output and dump collected 
information into a file (SQLite database)\n"));
 #endif
   fprintf(stderr, _("\t-class CLASS    only show a certain class of 
hardware\n"));
   fprintf(stderr, _("\t-C CLASS        same as '-class CLASS'\n"));

++++++ lshw-add-notime-option-to-manpage.patch ++++++
--- /var/tmp/diff_new_pack.Vtzx7o/_old  2020-03-18 00:36:52.557416797 +0100
+++ /var/tmp/diff_new_pack.Vtzx7o/_new  2020-03-18 00:36:52.557416797 +0100
@@ -13,20 +13,20 @@
  src/lshw.1 | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
 
-diff --git a/src/lshw.1 b/src/lshw.1
-index 79c3619..31ff77f 100644
---- a/src/lshw.1
-+++ b/src/lshw.1
+Index: lshw-B.02.18+git.20191228/src/lshw.1
+===================================================================
+--- lshw-B.02.18+git.20191228.orig/src/lshw.1
++++ lshw-B.02.18+git.20191228/src/lshw.1
 @@ -10,7 +10,7 @@ lshw \- list hardware
  .sp
  \fBlshw\fR [ \fB-X\fR ] 
  .sp
 -\fBlshw\fR [ \fB [ -html ]  [ -short ]  [ -xml ]  [ -json ]  [ -businfo ] \fR 
]  [ \fB-dump \fIfilename\fB\fR ]  [ \fB-class \fIclass\fB\fR\fI...\fR ]  [ 
\fB-disable \fItest\fB\fR\fI...\fR ]  [ \fB-enable \fItest\fB\fR\fI...\fR ]  [ 
\fB-sanitize\fR ]  [ \fB-numeric\fR ]  [ \fB-quiet\fR ] 
-+\fBlshw\fR [ \fB [ -html ]  [ -short ]  [ -xml ]  [ -json ]  [ -businfo ] \fR 
]  [ \fB-dump \fIfilename\fB\fR ]  [ \fB-class \fIclass\fB\fR\fI...\fR ]  [ 
\fB-disable \fItest\fB\fR\fI...\fR ]  [ \fB-enable \fItest\fB\fR\fI...\fR ]  [ 
\fB-sanitize\fR ]  [ \fB-numeric\fR ]  [ \fB-notime\fR ]  [ \fB-quiet\fR ] 
++\fBlshw\fR [ \fB [ -html ]  [ -short ]  [ -xml ]  [ -json ]  [ -businfo ] \fR 
]  [ \fB-dump \fIfilename\fB\fR ]  [ \fB-class \fIclass\fB\fR\fI...\fR ]  [ 
\fB-disable \fItest\fB\fR\fI...\fR ]  [ \fB-enable \fItest\fB\fR\fI...\fR ]  [ 
\fB-sanitize\fR ]  [ \fB-numeric\fR ]  [ \fB-notime\fR ]  [ \fB-quiet\fR ]
  .SH "DESCRIPTION"
  .PP
  
-@@ -74,6 +74,8 @@ Remove potentially sensitive information from output (IP 
addresses, serial numbe
+@@ -74,6 +74,8 @@ Remove potentially sensitive information
  .TP
  \fB-numeric\fR
  Also display numeric IDs (for PCI and USB devices).
@@ -35,5 +35,3 @@
  .SH "BUGS"
  .PP
  \fBlshw\fR currently does not detect 
--- 
-2.18.1

++++++ lshw-display-latest-version.patch ++++++
--- /var/tmp/diff_new_pack.Vtzx7o/_old  2020-03-18 00:36:52.565416802 +0100
+++ /var/tmp/diff_new_pack.Vtzx7o/_new  2020-03-18 00:36:52.565416802 +0100
@@ -14,10 +14,10 @@
  src/lshw.cc | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
-Index: lshw-B.02.18+git.20190613/src/lshw.cc
+Index: lshw-B.02.18+git.20191228/src/lshw.cc
 ===================================================================
---- lshw-B.02.18+git.20190613.orig/src/lshw.cc
-+++ lshw-B.02.18+git.20190613/src/lshw.cc
+--- lshw-B.02.18+git.20191228.orig/src/lshw.cc
++++ lshw-B.02.18+git.20191228/src/lshw.cc
 @@ -121,7 +121,7 @@ char **argv)
        printf("%s\n", getpackageversion());
        if(latest)

++++++ lshw-nvme.patch ++++++
>From 7b1863bd61c1751a67b020820f4243a4df4b379a Mon Sep 17 00:00:00 2001
From: Harry Mallon <harry.mallon@codex.online>
Date: Mon, 25 Mar 2019 19:44:14 +0000
Subject: [PATCH] add support for /dev/nvmeX NVMe controllers

* Added nvme scanning for controllers /dev/nvme[0-9]+
* Added nvme scanning for namespaces /dev/nvme[0-9]+n[0-9]+
* Fill in namespaces as disks
* Teach partition scanning about nvme partitions /dev/nvme[0-9]+n[0-9]+p[0-9]+
---
 src/core/Makefile      |   5 +-
 src/core/main.cc       |   4 ++
 src/core/nvme.cc       | 156 +++++++++++++++++++++++++++++++++++++++++
 src/core/nvme.h        |   7 ++
 src/core/partitions.cc |  17 +++--
 src/core/sysfs.cc      |  15 ++++
 src/core/sysfs.h       |   3 +
 7 files changed, 199 insertions(+), 8 deletions(-)
 create mode 100644 src/core/nvme.cc
 create mode 100644 src/core/nvme.h

Index: lshw-B.02.18+git.20191228/src/core/Makefile
===================================================================
--- lshw-B.02.18+git.20191228.orig/src/core/Makefile
+++ lshw-B.02.18+git.20191228/src/core/Makefile
@@ -8,7 +8,7 @@ LDFLAGS=
 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 nvme.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
 ifeq ($(SQLITE), 1)
        OBJS+= db.o
 endif
@@ -23,7 +23,7 @@ lib$(PACKAGENAME).a: $(OBJS)
        $(AR) rs $@ $^
 
 install: all
-       
+
 clean:
        rm -f $(OBJS) lib$(PACKAGENAME).a
 
@@ -51,6 +51,7 @@ ide.o: version.h cpuinfo.h hw.h osutils.
 cdrom.o: version.h cdrom.h hw.h partitions.h
 pcmcia-legacy.o: version.h pcmcia-legacy.h hw.h osutils.h
 scsi.o: version.h mem.h hw.h cdrom.h disk.h osutils.h heuristics.h sysfs.h
+nvme.o: version.h hw.h disk.h osutils.h sysfs.h
 disk.o: version.h disk.h hw.h osutils.h heuristics.h partitions.h
 spd.o: version.h spd.h hw.h osutils.h
 network.o: version.h config.h network.h hw.h osutils.h sysfs.h options.h
Index: lshw-B.02.18+git.20191228/src/core/main.cc
===================================================================
--- lshw-B.02.18+git.20191228.orig/src/core/main.cc
+++ lshw-B.02.18+git.20191228/src/core/main.cc
@@ -29,6 +29,7 @@
 #include "pcmcia-legacy.h"
 #include "ide.h"
 #include "scsi.h"
+#include "nvme.h"
 #include "spd.h"
 #include "network.h"
 #include "isapnp.h"
@@ -132,6 +133,9 @@ bool scan_system(hwNode & system)
     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);
Index: lshw-B.02.18+git.20191228/src/core/nvme.cc
===================================================================
--- /dev/null
+++ lshw-B.02.18+git.20191228/src/core/nvme.cc
@@ -0,0 +1,156 @@
+#include "version.h"
+#include "disk.h"
+#include "osutils.h"
+#include "sysfs.h"
+#include "hw.h"
+#include <glob.h>
+#include <libgen.h>
+
+#include <string>
+
+__ID("@(#) $Id$");
+
+#define CLASS_NVME "nvme"
+#define NVMEX "/dev/nvme[0-9]*"
+#define NVMEXNX "/dev/nvme[0-9]*n[0-9]*"
+
+static void scan_controllers(hwNode & n)
+{
+  glob_t entries;
+  size_t j;
+
+  if(glob(NVMEX, 0, NULL, &entries) == 0)
+  {
+    for(j=0; j < entries.gl_pathc; j++)
+    {
+      if(matches(entries.gl_pathv[j], "^/dev/nvme[[:digit:]]+$"))
+      {
+        string businfo = "";
+        string logicalname = "";
+        hwNode *device = NULL;
+
+        logicalname = basename(entries.gl_pathv[j]);
+        if (logicalname.empty())
+          continue;
+
+        businfo = sysfs::entry::byClass(CLASS_NVME, logicalname).businfo();
+
+        if (!businfo.empty())
+          device = n.findChildByBusInfo(businfo);
+
+        if (!device)
+          device = n.findChildByLogicalName(logicalname);
+
+        if (!device)
+        {
+          hwNode *core = n.getChild("core");
+
+          if (core)
+            device = n.getChild("nvme");
+
+          if (core && !device)
+            device = core->addChild(hwNode("nvme", hw::storage));
+        }
+
+        if (!device)
+          device = n.addChild(hwNode("nvme", hw::storage));
+
+        if (device)
+        {
+          if(device->getBusInfo().empty())
+            device->setBusInfo(businfo);
+          device->setLogicalName(logicalname);
+          device->claim();
+        }
+      }
+    }
+
+    globfree(&entries);
+  }
+}
+
+static void scan_namespaces(hwNode & n)
+{
+  glob_t entries;
+  size_t j;
+
+  if(glob(NVMEXNX, 0, NULL, &entries) == 0)
+  {
+    for(j=0; j < entries.gl_pathc; j++)
+    {
+      if(matches(entries.gl_pathv[j], "^/dev/nvme[[:digit:]]+n[[:digit:]]+$"))
+      {
+        // We get this information from sysfs rather than doing an NVMe 
Identify command
+        // so they may not all be available from all kernels.
+        string path = entries.gl_pathv[j];
+        string logicalname = "";
+        string parentlogicalname = "";
+        string model;
+        string serial;
+        string firmware_rev;
+        hwNode *parent = NULL;
+        hwNode device = hwNode("disk", hw::disk);
+
+        logicalname = basename(entries.gl_pathv[j]);
+        if (logicalname.empty())
+          continue;
+
+        parentlogicalname = path.substr(0, path.find_last_of("n"));
+
+        sysfs::entry e = sysfs::entry::byClass("block", logicalname);
+
+        model = e.model();
+        serial = e.serial();
+        firmware_rev = e.firmware_rev();
+
+        device.setDescription("NVMe disk");
+        device.setLogicalName(logicalname);
+        device.claim();
+
+        if (!model.empty())
+          device.setProduct(model);
+        if (!serial.empty())
+          device.setSerial(serial);
+        if (!firmware_rev.empty())
+          device.setVersion(firmware_rev);
+
+        scan_disk(device);
+
+        if (!parentlogicalname.empty())
+          parent = n.findChildByLogicalName(parentlogicalname);
+
+        if (!parent)
+        {
+          hwNode *core = n.getChild("core");
+
+          if (core)
+            parent = n.getChild("nvme");
+
+          if (core && !parent)
+            parent = core->addChild(hwNode("nvme", hw::storage));
+        }
+
+        if (!parent)
+          parent = n.addChild(hwNode("nvme", hw::storage));
+
+        if (parent)
+        {
+          parent->addChild(device);
+          parent->claim();
+        }
+      }
+    }
+
+    globfree(&entries);
+  }
+
+}
+
+bool scan_nvme(hwNode & n)
+{
+  scan_controllers(n);
+
+  scan_namespaces(n);
+
+  return false;
+}
Index: lshw-B.02.18+git.20191228/src/core/nvme.h
===================================================================
--- /dev/null
+++ lshw-B.02.18+git.20191228/src/core/nvme.h
@@ -0,0 +1,7 @@
+#ifndef _NVME_H_
+#define _NVME_H_
+
+#include "hw.h"
+
+bool scan_nvme(hwNode & n);
+#endif
Index: lshw-B.02.18+git.20191228/src/core/partitions.cc
===================================================================
--- lshw-B.02.18+git.20191228.orig/src/core/partitions.cc
+++ lshw-B.02.18+git.20191228/src/core/partitions.cc
@@ -295,6 +295,7 @@ static bool guess_logicalname(source & s
   struct stat buf;
   char name[10];
   int dev = 0;
+  string devname;
 
   snprintf(name, sizeof(name), "%d", n);
   if(disk.getBusInfo()!="")
@@ -304,9 +305,16 @@ static bool guess_logicalname(source & s
   if(!S_ISBLK(buf.st_mode)) return false;
 
   if(s.diskname!="")
-    dev = open_dev(buf.st_rdev + n, S_IFBLK, s.diskname+string(name));
+    devname = s.diskname;
   else
-    dev = open_dev(buf.st_rdev + n, S_IFBLK, 
disk.getLogicalName()+string(name));
+    devname = disk.getLogicalName();
+
+  // NVMe partitions are like /dev/nvme0n1p2
+  if(matches(devname, "^/dev/nvme[[:digit:]]+n[[:digit:]]+$"))
+    devname += "p";
+  devname += string(name);
+
+  dev = open_dev(buf.st_rdev + n, S_IFBLK, devname);
 
   if(dev>=0)
   {
@@ -330,10 +338,7 @@ static bool guess_logicalname(source & s
     if(memcmp(buffer1, buffer2, BLOCKSIZE)==0)
     {
       partition.claim();
-      if(s.diskname!="")
-        partition.setLogicalName(s.diskname+string(name));
-      else
-        partition.setLogicalName(disk.getLogicalName()+string(name));
+      partition.setLogicalName(devname);
       return true;
     }
   }
Index: lshw-B.02.18+git.20191228/src/core/sysfs.cc
===================================================================
--- lshw-B.02.18+git.20191228.orig/src/core/sysfs.cc
+++ lshw-B.02.18+git.20191228/src/core/sysfs.cc
@@ -368,6 +368,21 @@ string entry::vendor() const
   return get_string(This->devpath+"/vendor");
 }
 
+string entry::model() const
+{
+  return get_string(This->devpath+"/model");
+}
+
+string entry::serial() const
+{
+  return get_string(This->devpath+"/serial");
+}
+
+string entry::firmware_rev() const
+{
+  return get_string(This->devpath+"/firmware_rev");
+}
+
 vector < entry > sysfs::entries_by_bus(const string & busname)
 {
   vector < entry > result;
Index: lshw-B.02.18+git.20191228/src/core/sysfs.h
===================================================================
--- lshw-B.02.18+git.20191228.orig/src/core/sysfs.h
+++ lshw-B.02.18+git.20191228/src/core/sysfs.h
@@ -28,6 +28,9 @@ namespace sysfs
       string modalias() const;
       string device() const;
       string vendor() const;
+      string model() const;
+      string serial() const;
+      string firmware_rev() const;
       entry parent() const;
       string name_in_class(const string &) const;
       string string_attr(const string & name, const string & def = "") const;


Reply via email to