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