Blame SOURCES/0013-make-modalias-an-optional-attribute-only-reported-in.patch

21ef37
From 5c3a4d5e7548bbf215eae4524ec0fb7fe5bf5634 Mon Sep 17 00:00:00 2001
21ef37
From: Lyonel Vincent <lyonel@ezix.org>
21ef37
Date: Wed, 17 Aug 2016 17:09:04 +0200
21ef37
Subject: [PATCH 13/43] make `modalias` an (optional) attribute only reported
21ef37
 in XML for now
21ef37
21ef37
---
21ef37
 docs/lshw.xsd       |  1 +
21ef37
 src/core/hw.cc      | 21 +++++++++++++++++++--
21ef37
 src/core/hw.h       |  3 +++
21ef37
 src/core/network.cc |  4 +---
21ef37
 src/core/pci.cc     |  4 +---
21ef37
 5 files changed, 25 insertions(+), 8 deletions(-)
21ef37
21ef37
diff --git a/docs/lshw.xsd b/docs/lshw.xsd
21ef37
index b46a33e..b513fa2 100644
21ef37
--- a/docs/lshw.xsd
21ef37
+++ b/docs/lshw.xsd
21ef37
@@ -33,6 +33,7 @@
21ef37
     <xs:attribute name="class" type="xs:string" minOccurs="0" />
21ef37
     <xs:attribute name="claimed" type="xs:boolean" minOccurs="0" />
21ef37
     <xs:attribute name="disabled" type="xs:boolean" minOccurs="0" />
21ef37
+    <xs:attribute name="modalias" type="xs:string" minOccurs="0" />
21ef37
   </xs:complexType>
21ef37
 
21ef37
   <xs:complexType name="measured">
21ef37
diff --git a/src/core/hw.cc b/src/core/hw.cc
21ef37
index e2559ff..68e5912 100644
21ef37
--- a/src/core/hw.cc
21ef37
+++ b/src/core/hw.cc
21ef37
@@ -28,7 +28,7 @@ struct hwNode_i
21ef37
 {
21ef37
   hwClass deviceclass;
21ef37
   string id, vendor, product, version, date, serial, slot, handle, description,
21ef37
-    businfo, physid, dev;
21ef37
+    businfo, physid, dev, modalias;
21ef37
   bool enabled;
21ef37
   bool claimed;
21ef37
   unsigned long long start;
21ef37
@@ -478,6 +478,22 @@ void hwNode::setSlot(const string & slot)
21ef37
 }
21ef37
 
21ef37
 
21ef37
+string hwNode::getModalias() const
21ef37
+{
21ef37
+  if (This)
21ef37
+    return This->modalias;
21ef37
+  else
21ef37
+    return "";
21ef37
+}
21ef37
+
21ef37
+
21ef37
+void hwNode::setModalias(const string & modalias)
21ef37
+{
21ef37
+  if (This)
21ef37
+    This->modalias = strip(modalias);
21ef37
+}
21ef37
+
21ef37
+
21ef37
 unsigned long long hwNode::getStart() const
21ef37
 {
21ef37
   if (This)
21ef37
@@ -1670,7 +1686,8 @@ string hwNode::asXML(unsigned level)
21ef37
       out << " claimed=\"true\"";
21ef37
 
21ef37
     out << " class=\"" << getClassName() << "\"";
21ef37
-    out << " handle=\"" << getHandle() << "\"";
21ef37
+    if(getHandle()!="") out << " handle=\"" << escape(getHandle()) << "\"";
21ef37
+    if(getModalias()!="") out << " modalias=\"" << escape(getModalias()) << "\"";
21ef37
     out << ">" << endl;
21ef37
 
21ef37
     if (getDescription() != "")
21ef37
diff --git a/src/core/hw.h b/src/core/hw.h
21ef37
index 4211a82..6454a4d 100644
21ef37
--- a/src/core/hw.h
21ef37
+++ b/src/core/hw.h
21ef37
@@ -154,6 +154,9 @@ class hwNode
21ef37
     string getSlot() const;
21ef37
     void setSlot(const string & slot);
21ef37
 
21ef37
+    string getModalias() const;
21ef37
+    void setModalias(const string & modalias);
21ef37
+
21ef37
     unsigned int countChildren(hw::hwClass c = hw::generic) const;
21ef37
     hwNode * getChild(unsigned int);
21ef37
     hwNode * getChildByPhysId(long);
21ef37
diff --git a/src/core/network.cc b/src/core/network.cc
21ef37
index 1d54959..e4d667f 100644
21ef37
--- a/src/core/network.cc
21ef37
+++ b/src/core/network.cc
21ef37
@@ -338,9 +338,7 @@ bool scan_network(hwNode & n)
21ef37
       string businfo = sysfs::entry::byClass("net", interface.getLogicalName()).businfo();
21ef37
       if (businfo!="")
21ef37
         interface.setBusInfo(businfo);
21ef37
-      string modalias = sysfs::entry::byClass("net", interface.getLogicalName()).modalias();
21ef37
-      if (modalias!="")
21ef37
-        interface.setConfig("modalias", modalias);
21ef37
+      interface.setModalias(sysfs::entry::byClass("net", interface.getLogicalName()).modalias());
21ef37
 
21ef37
 //scan_mii(fd, interface);
21ef37
       scan_ip(interface);
21ef37
diff --git a/src/core/pci.cc b/src/core/pci.cc
21ef37
index f667f89..0d02b31 100644
21ef37
--- a/src/core/pci.cc
21ef37
+++ b/src/core/pci.cc
21ef37
@@ -1148,9 +1148,7 @@ bool scan_pci(hwNode & n)
21ef37
           device->claim();
21ef37
         }
21ef37
 
21ef37
-	string modalias = sysfs::entry::byBus("pci", devices[i]->d_name).modalias();
21ef37
-	if(modalias!="")
21ef37
-		device->setConfig("modalias", modalias);
21ef37
+	device->setModalias(sysfs::entry::byBus("pci", devices[i]->d_name).modalias());
21ef37
 
21ef37
         if(exists(resourcename))
21ef37
         {
21ef37
-- 
21ef37
2.10.2
21ef37