Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package lsvpd for openSUSE:Factory checked in at 2021-09-21 21:12:50 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/lsvpd (Old) and /work/SRC/openSUSE:Factory/.lsvpd.new.1899 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "lsvpd" Tue Sep 21 21:12:50 2021 rev:58 rq:920537 version:1.7.13 Changes: -------- --- /work/SRC/openSUSE:Factory/lsvpd/lsvpd.changes 2021-08-12 09:02:24.114080946 +0200 +++ /work/SRC/openSUSE:Factory/.lsvpd.new.1899/lsvpd.changes 2021-09-21 21:13:41.370675741 +0200 @@ -1,0 +2,7 @@ +Mon Sep 20 12:55:42 UTC 2021 - Michal Suchanek <msucha...@suse.com> + +- Update to version 1.7.13 (jsc#SLE-18188). + - Fix support for SCSI loc code +- Remove obsolete BuildRoot and defattr + +------------------------------------------------------------------- Old: ---- lsvpd-1.7.12.tar.gz New: ---- lsvpd-1.7.13.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ lsvpd.spec ++++++ --- /var/tmp/diff_new_pack.oKPGq0/_old 2021-09-21 21:13:41.834676265 +0200 +++ /var/tmp/diff_new_pack.oKPGq0/_new 2021-09-21 21:13:41.834676265 +0200 @@ -17,7 +17,7 @@ Name: lsvpd -Version: 1.7.12 +Version: 1.7.13 Release: 0 Summary: VPD Hardware Inventory Utilities for Linux License: GPL-2.0-or-later @@ -33,7 +33,6 @@ BuildRequires: zlib-devel Requires: /bin/sed Recommends: hwdata -BuildRoot: %{_tmppath}/%{name}-%{version}-build ExclusiveArch: ppc ppc64 ppc64le %description @@ -83,7 +82,6 @@ exit 0 %files -%defattr(-,root,root) %license COPYING %doc README NEWS %dir %{_sysconfdir}/lsvpd ++++++ lsvpd-1.7.12.tar.gz -> lsvpd-1.7.13.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lsvpd-1.7.12/ChangeLog new/lsvpd-1.7.13/ChangeLog --- old/lsvpd-1.7.12/ChangeLog 2021-05-13 07:37:19.000000000 +0200 +++ new/lsvpd-1.7.13/ChangeLog 2021-09-09 08:30:34.000000000 +0200 @@ -1,3 +1,6 @@ +1.7.13: Vasant Hegde <hegdevas...@linux.vnet.ibm.com> - Thu Sep 9 2021 +- Add support for SCSI loc code + 1.7.12: Vasant Hegde <hegdevas...@linux.vnet.ibm.com> - Thu May 13 2021 - sysvpd: Add UUID property - nvme: Populate NVMe firmware version diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lsvpd-1.7.12/configure.ac new/lsvpd-1.7.13/configure.ac --- old/lsvpd-1.7.12/configure.ac 2021-05-13 07:37:19.000000000 +0200 +++ new/lsvpd-1.7.13/configure.ac 2021-09-09 08:30:34.000000000 +0200 @@ -3,7 +3,7 @@ AC_PREREQ([2.69]) #base -AC_INIT([lsvpd],[1.7.12],[hegdevas...@linux.vnet.ibm.com, kamal...@linux.vnet.ibm.com]) +AC_INIT([lsvpd],[1.7.13],[hegdevas...@linux.vnet.ibm.com, kamal...@linux.vnet.ibm.com]) AC_CONFIG_HEADER([config/config.h]) AC_SUBST(DATE, [`date`]) AC_CONFIG_MACRO_DIR([m4]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lsvpd-1.7.12/lsvpd.spec.in new/lsvpd-1.7.13/lsvpd.spec.in --- old/lsvpd-1.7.12/lsvpd.spec.in 2021-05-13 07:37:19.000000000 +0200 +++ new/lsvpd-1.7.13/lsvpd.spec.in 2021-09-09 08:30:34.000000000 +0200 @@ -79,6 +79,9 @@ %changelog +* Thu Sep 9 2021 - Vasant Hegde <hegdevas...@linux.vnet.ibm.com> - 1.7.13 +- Add support for SCSI loc code + * Thu May 13 2021 - Vasant Hegde <hegdevas...@linux.vnet.ibm.com> - 1.7.12 - sysvpd: Add UUID property - nvme: Populate NVMe firmware version diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lsvpd-1.7.12/src/include/devicetreecollector.hpp new/lsvpd-1.7.13/src/include/devicetreecollector.hpp --- old/lsvpd-1.7.12/src/include/devicetreecollector.hpp 2021-05-13 07:37:19.000000000 +0200 +++ new/lsvpd-1.7.13/src/include/devicetreecollector.hpp 2021-09-09 08:30:34.000000000 +0200 @@ -206,6 +206,10 @@ Component * findSCSIParent(Component *fillMe, vector<Component*> devs); + + string fillLocCode(Component *gParent, Component *gGParent, + Component *gGGParent); + void buildSCSILocCode(Component *fillMe, vector<Component*> devs); void getComponentsVector( vector<Component*>& devs ); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lsvpd-1.7.12/src/internal/sys_interface/devicetreecollector.cpp new/lsvpd-1.7.13/src/internal/sys_interface/devicetreecollector.cpp --- old/lsvpd-1.7.12/src/internal/sys_interface/devicetreecollector.cpp 2021-05-13 07:37:19.000000000 +0200 +++ new/lsvpd-1.7.13/src/internal/sys_interface/devicetreecollector.cpp 2021-09-09 08:30:34.000000000 +0200 @@ -42,6 +42,7 @@ #include <fcntl.h> #include <string> #include <unistd.h> +#include <libgen.h> #include <cstdlib> #include <cstring> #include <cerrno> @@ -735,7 +736,9 @@ int loc; devSpecific = fillMe->getDeviceSpecific("XB"); - if (devSpecific != NULL) { + if (devSpecific != NULL || + fillMe->devBus.dataValue == "scsi" || + fillMe->devBus.dataValue == "usb" ) { sysDev = fillMe->sysFsLinkTarget.dataValue; while (sysDev.length() > 1) { if ((loc = sysDev.rfind("/", sysDev.length())) != (int) string::npos ) @@ -752,6 +755,152 @@ return NULL; } + /* + * @brief fillLocCode tries to parse the device-tree and find + * the loc-code based on port numbers. + * @args: + * gParent: two level higher in the sysfs path of the device (required for + * finding devices in the same root hub USB 2.0) + * gGParent: three level higher in the sysfs path of the device (required to + * calculate raw port number) + * gGGParent: Four level higher in the sysfs path of the device (required for + * findging devices in the sibling root hub USB 3.0) + * + * Example: + * + * device: /sys/devices/pci0019:01/0019:01:00.0/usb2/2-2/2-2:1.0/host0/target0:0:0/0:0:0:0 + * parent: /sys/devices/pci0019:01/0019:01:00.0/usb2/2-2/2-2:1.0/host0 + * gParent: /sys/devices/pci0019:01/0019:01:00.0/usb2/2-2/2-2:1.0 + * gGparent: /sys/devices/pci0019:01/0019:01:00.0/usb2/2-2 + * gGGparent: /sys/devices/pci0019:01/0019:01:00.0/usb2 + + */ + string DeviceTreeCollector::fillLocCode(Component *gParent, Component *gGParent, + Component *gGGParent) + { + string devTreeDir, devName, rawPortS, locCode; + vector<string> listing, list; + char busNum[10], portNum[10]; + int maxChild, rawPort = 0; + FSWalk fsw = FSWalk(); + char *baseName; + int i = 0, j; + + /* + * First part of this function, tries to find the port + * number assigned to the device under the USB + * controller. The algorithm used to construct the + * rawport (the term used in the Linux Kernel USB device + * driver code) is the parse the bus and port number + * from the last directory level of the device sysfs path + * and then find the maximum number of ports available + * under the USB hub, to connect devices in the hub. + * Applying the formula: + * - bus number * child of all the hubs, with bus number + * lesser than the current bus + current device port + * number. + * i.e., if the device gets assigned to port 2 of the + * root hub number 2, here 2 is the bus number, assigned + * by the USB controller and as maxchild of 4 or in other + * words maximum available ports on the root hub is 4. + * We assume that the same USB controller will host 4 + * ports for both root hubs (USB 2.0 and USB 3.0). + * When the algorithm is applied to the above example: + * bus number (2) * (1 * 4) (1 is bus lesser than current + * one and 4 is maxchild/ports available) = port number 6. + * We need to search for devices ending with @6, under the + * root hub to find the location code. + */ + baseName = basename((char *)(string(gGParent->sysFsNode.dataValue).c_str())); + if (baseName == NULL) + return string(""); + + for (i = 0; baseName[i] != '\0' && baseName[i] != '-'; i++) + busNum[i] = baseName[i]; + busNum[i] = '\0'; + + if (strlen(busNum) == 0) + return string(""); + + for (i+=1, j=0; baseName[i] != '\0'; i++, j++) + portNum[j] = baseName[i]; + portNum[j] = '\0'; + + if (strlen(portNum) == 0) + return string(""); + + maxChild = atoi(string(getAttrValue + ( gGGParent->sysFsNode.dataValue.c_str(), "/maxchild")).c_str()); + + i = atoi(busNum); + if ( i > 1 ) { + rawPort = i - 1; + rawPort *= maxChild; + } + rawPort += atoi(portNum); + rawPortS = "@" + to_string(rawPort); + + /* + * for the USB 2.0 devices, device-tree association of root + * hub under which they are connected, is read from devspec + * or of_node in the sysfs path of the /sys/devices/. So we + * just search for the devices ending with the port number + * calculated above in the device (root hub) device-tree + * node. + */ + fsw.fs_getDirContents(gParent->deviceTreeNode.dataValue, 'd', listing); + while (listing.size() > 0) { + + string devDir = listing.back(); + if (devDir.compare(devDir.length() - rawPortS.length(), + rawPortS.length(), rawPortS) == 0) { + + devTreeDir = gParent->deviceTreeNode.dataValue + "/" + listing.back(); + locCode = getAttrValue( devTreeDir.c_str(), "/ibm,loc-code"); + return locCode; + } + listing.pop_back(); + } + + /* + * this logic is same as above but we are searching one + * level higher in the /proc/device-tree hierarchy, the + * search path includes all of the root hubs connected to + * this USB controller and use the same logic as above to + * find the device ending with the @portnumber in every + * root hub. + */ + fsw.fs_getDirContents(gGGParent->deviceTreeNode.dataValue, 'd', listing); + while (listing.size() > 0) { + + devTreeDir = gGGParent->deviceTreeNode.dataValue + "/" + listing.back(); + devName = getAttrValue( devTreeDir.c_str(), "/name"); + + if (devName.compare("hub") == 0) { + + fsw.fs_getDirContents(devTreeDir.c_str(), 'd', list); + while (list.size() > 0) { + + string devDir = list.back(); + string _devTreeDir; + + if ( devDir.compare(devDir.length() - rawPortS.length(), + rawPortS.length(), rawPortS) == 0) { + + _devTreeDir = devTreeDir + "/" + list.back(); + locCode = getAttrValue( _devTreeDir.c_str(), + "/ibm,loc-code"); + return locCode; + } + list.pop_back(); + } + } + listing.pop_back(); + } + + return string(""); +} + /* @brief Collect Location Code information for devices that do not * give us a nice ibm,loc-code * @arg devs - device tree discovered devices @@ -763,39 +912,107 @@ void DeviceTreeCollector::buildSCSILocCode(Component *fillMe, vector<Component*> devs) { - Component *parent; - ostringstream val; + Component *parent, *gParent, *gGParent, *gGGParent; const DataItem *target, *lun, *bus, *host; + ostringstream val; + string locCode; /* Build up a distinct YL based on parents YL - for device such as * scsi, ide, usb, etc that do not generate ibm,loc-code * files for easy grabbing */ - if (fillMe->devBus.dataValue == "scsi") { - parent = findSCSIParent(fillMe, devs); + if (fillMe->devBus.dataValue != "scsi") + return; + + parent = findSCSIParent(fillMe, devs); + if (parent == NULL) + return; + + target = fillMe->getDeviceSpecific("XT"); + lun = fillMe->getDeviceSpecific("XL"); + bus = fillMe->getDeviceSpecific("XB"); + host = fillMe->getDeviceSpecific("XH"); + if (host == NULL || target == NULL || lun == NULL || bus == NULL) + return; + + if (fillMe->mPhysicalLocation.dataValue != "") + val << fillMe->mPhysicalLocation.dataValue; + else if (parent->mPhysicalLocation.dataValue != "") + val << parent->mPhysicalLocation.dataValue; + else + val << getAttrValue( parent->deviceTreeNode.dataValue, + "ibm,loc-code" ); + + /* + * fillQuickVPD failure, doesn't always attribute to the missing + * device-tree entry associated with the sysfs device path. + * There are also configurations like USB hubs, to which the + * SCSI devices gets connected with special device-tree layout. + * A USB controller, that supports both USB 3.0 and USB 2.0 + * devices will create two USB hubs for communicating with + * devices. Where one hub controllers devices with speeds + * ranging upto 480M (USB 2.0) and another for devices operating + * at the 5000M (USB 3.0). The layout might be little complex + * when the USB 3.0 devices are internal on board ones and 2.0 + * is an external device. + * + * root hub + * / \ + * USB hub 1 USB hub 2 + * (2.0) (3.0) + * | / \ + * External Internal Internal + * device device1 device2 + * + * the populated device-tree adds both of the internal devices + * under the hub1, that hosts the slower external device, with + * the layout: + * usb@1 + * |_ hub@1 + * |_ cdrom@1 (USB 2.0) + * |_ usb-scsi@6 (USB 3.0, internal device 1) + * |_ usb-scsi@8 (USB 3.0, internal device 2) + * + * the logic below finds the location code for such SCSI devices + * connected to USB hubs in a mix and match of external and + * internal devices. + */ + gParent = findSCSIParent(parent, devs); + if (gParent != NULL) { + + gGParent = findSCSIParent(gParent, devs); + if (gGParent != NULL) { - if (parent != NULL) { - target = fillMe->getDeviceSpecific("XT"); - lun = fillMe->getDeviceSpecific("XL"); - bus = fillMe->getDeviceSpecific("XB"); - host = fillMe->getDeviceSpecific("XH"); - if (host != NULL && target != NULL && - lun != NULL && bus != NULL) { - if (fillMe->mPhysicalLocation.dataValue != "") - val << fillMe->mPhysicalLocation.dataValue; - else if - (parent->mPhysicalLocation.dataValue != "") - val << parent->mPhysicalLocation.dataValue; - else - val << getAttrValue( parent->deviceTreeNode.dataValue, - "ibm,loc-code" ); - val << "H" << host->dataValue << "-B" << bus->dataValue - << "-T" << target->dataValue << "-L" << lun->dataValue; - fillMe->mPhysicalLocation.setValue( val.str( ), 60 , - __FILE__, __LINE__ ); + gGGParent = findSCSIParent(gGParent, devs); + if (gGGParent != NULL && + gGGParent->devBus.dataValue == "usb" ) { + + /* + * walk up to the hub controller sysfs + * directory to find the device-tree + * association. + */ + locCode = fillLocCode + (gParent, gGParent, gGGParent); } } } + + if (locCode.length() > 0) { + fillMe->mPhysicalLocation.setValue( locCode.c_str( ), 60 , + __FILE__, __LINE__ ); + return; + } + + /* + * if we fail to find the loation code, then fallback to old + * method of constructing an unique code. + */ + val << "H" << host->dataValue << "-B" << bus->dataValue + << "-T" << target->dataValue << "-L" << lun->dataValue; + + fillMe->mPhysicalLocation.setValue( val.str( ), 60 , + __FILE__, __LINE__ ); } void DeviceTreeCollector::getRtasSystemParams(vector<Component*>& devs) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lsvpd-1.7.12/src/internal/sys_interface/gatherer.cpp new/lsvpd-1.7.13/src/internal/sys_interface/gatherer.cpp --- old/lsvpd-1.7.12/src/internal/sys_interface/gatherer.cpp 2021-05-13 07:37:19.000000000 +0200 +++ new/lsvpd-1.7.13/src/internal/sys_interface/gatherer.cpp 2021-09-09 08:30:34.000000000 +0200 @@ -378,7 +378,7 @@ } /** - * Contruct complete collection of devices on system, + * Construct complete collection of devices on system, * by calling 'getComponents()' on each specific collector type * * @arg devs: a Component* vector, which will be filled with the diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lsvpd-1.7.12/src/internal/sys_interface/sysfstreecollector.cpp new/lsvpd-1.7.13/src/internal/sys_interface/sysfstreecollector.cpp --- old/lsvpd-1.7.12/src/internal/sys_interface/sysfstreecollector.cpp 2021-05-13 07:37:19.000000000 +0200 +++ new/lsvpd-1.7.13/src/internal/sys_interface/sysfstreecollector.cpp 2021-09-09 08:30:34.000000000 +0200 @@ -957,15 +957,42 @@ */ string SysFSTreeCollector::getDevTreePath(string sysPath) { + string sysFsPath, procDtPath, firmwareDtBase; struct stat astats; const char *buf; - char buf2[512]; + char buf2[PATH_MAX]; FILE *fi; HelperFunctions::fs_fixPath(sysPath); - sysPath += "/devspec"; + sysFsPath = sysPath + "/devspec"; + procDtPath = sysPath + "/of_node"; + firmwareDtBase = "/sys/firmware/devicetree/base"; + + /* + * Check for existence of of_node symlink and return the path it + * points to. devspec is obsolete now, most of the devices + * populate of_node and devspec too. Prefer of_node over + * devspec, where it exist and fall back to older logic, in case + * of of_node not populated. + */ + buf = procDtPath.c_str(); + if ((lstat(buf, &astats)) == 0) { + // of_node is symlink, follow the link + if ( realpath( buf, buf2 ) == NULL ) { + return string (""); + } + + /* + * Trim the leading "/sys/firmware/devicetree/base" from the real + * path to match the assumption from devspec format, while used + * with /proc/devicetree. + */ + procDtPath = string(buf2); + procDtPath.replace(0, firmwareDtBase.length(), ""); + return procDtPath; + } - buf = sysPath.c_str(); + buf = sysFsPath.c_str(); if ((lstat(buf, &astats)) != 0) { return string(""); } @@ -985,7 +1012,10 @@ fclose(fi); // cleanup - return string(buf2); + if (strcmp(buf2, "(null)")) + return string(buf2); + + return string(""); } /* Collects devices on system, then returns how many were found. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lsvpd-1.7.12/src/output/lsmcode.cpp new/lsvpd-1.7.13/src/output/lsmcode.cpp --- old/lsvpd-1.7.12/src/output/lsmcode.cpp 2021-05-13 07:37:19.000000000 +0200 +++ new/lsvpd-1.7.13/src/output/lsmcode.cpp 2021-09-09 08:30:34.000000000 +0200 @@ -178,7 +178,7 @@ try { attrIn.open( fullPath.c_str( ) ); } - catch (std::ifstream::failure e) { + catch (std::ifstream::failure &e) { ostringstream os; os << "Error opening " << fullPath; Logger().log(os.str( ), LOG_WARNING);