From: Pali Rohár Date: Mon, 27 Dec 2021 13:05:47 +0000 (+0100) Subject: libpci: sysfs: Implement support for PCI_FILL_DRIVER X-Git-Tag: v3.8.0~30 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=9b744f7611b5831f0c47cb1a26a37cca88f1335c;p=pciutils.git libpci: sysfs: Implement support for PCI_FILL_DRIVER In sysfs is driver name stored as symlink path of "driver" node. --- diff --git a/lib/sysfs.c b/lib/sysfs.c index 735c144..ffa4f9d 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -461,6 +461,20 @@ sysfs_fill_info(struct pci_dev *d, unsigned int flags) } } + if (want_fill(d, flags, PCI_FILL_DRIVER)) + { + char *driver_path = sysfs_deref_link(d, "driver"); + if (driver_path) + { + char *driver = strrchr(driver_path, '/'); + driver = driver ? driver+1 : driver_path; + pci_set_property(d, PCI_FILL_DRIVER, driver); + free(driver_path); + } + else + clear_fill(d, PCI_FILL_DRIVER); + } + pci_generic_fill_info(d, flags); }