Blame SOURCES/0011-report-modalias-information-for-PCI-and-network-devi.patch

99c779
From 4a19168dbd3949a4d5b7fd69fd6d646652f63ea3 Mon Sep 17 00:00:00 2001
99c779
From: Lyonel Vincent <lyonel@ezix.org>
99c779
Date: Tue, 16 Aug 2016 23:34:44 +0200
99c779
Subject: [PATCH 11/43] report modalias information for PCI and network devices
99c779
99c779
cf. http://www.linuxfromscratch.org/lfs/view/development/chapter07/udev.html
99c779
---
99c779
 src/core/network.cc | 1 +
99c779
 src/core/pci.cc     | 5 +++++
99c779
 src/core/sysfs.cc   | 4 ++++
99c779
 src/core/sysfs.h    | 1 +
99c779
 4 files changed, 11 insertions(+)
99c779
99c779
diff --git a/src/core/network.cc b/src/core/network.cc
99c779
index 15a961d..77233fc 100644
99c779
--- a/src/core/network.cc
99c779
+++ b/src/core/network.cc
99c779
@@ -337,6 +337,7 @@ bool scan_network(hwNode & n)
99c779
 
99c779
       string businfo = sysfs::entry::byClass("net", interface.getLogicalName()).businfo();
99c779
       interface.setBusInfo(businfo);
99c779
+      interface.setConfig("modalias", 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 fab6fd2..f667f89 100644
99c779
--- a/src/core/pci.cc
99c779
+++ b/src/core/pci.cc
99c779
@@ -3,6 +3,7 @@
99c779
 #include "pci.h"
99c779
 #include "osutils.h"
99c779
 #include "options.h"
99c779
+#include "sysfs.h"
99c779
 #include <sys/types.h>
99c779
 #include <sys/stat.h>
99c779
 #include <fcntl.h>
99c779
@@ -1147,6 +1148,10 @@ 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
+
99c779
         if(exists(resourcename))
99c779
         {
99c779
             FILE*resource = fopen(resourcename.c_str(), "r");
99c779
diff --git a/src/core/sysfs.cc b/src/core/sysfs.cc
99c779
index acc9d00..2b09554 100644
99c779
--- a/src/core/sysfs.cc
99c779
+++ b/src/core/sysfs.cc
99c779
@@ -298,6 +298,10 @@ entry entry::parent() const
99c779
   return e;
99c779
 }
99c779
 
99c779
+string entry::modalias() const
99c779
+{
99c779
+  return get_string(This->devpath+"/modalias");
99c779
+}
99c779
 
99c779
 vector < entry > sysfs::entries_by_bus(const string & busname)
99c779
 {
99c779
diff --git a/src/core/sysfs.h b/src/core/sysfs.h
99c779
index a9dc573..d37e2d4 100644
99c779
--- a/src/core/sysfs.h
99c779
+++ b/src/core/sysfs.h
99c779
@@ -24,6 +24,7 @@ namespace sysfs
99c779
       string name() const;
99c779
       string businfo() const;
99c779
       string driver() const;
99c779
+      string modalias() const;
99c779
       entry parent() const;
99c779
       string name_in_class(const string &) const;
99c779
 
99c779
-- 
99c779
2.10.2
99c779