Get programmatically driver name of an interface
Is there a way programmatically driver name of interface, e开发者_如何学编程xcept of parsing output of "ethtool -i interface_name"?
I would happy if it can be retrieved from a file.
You can query sysfs
for it. Read the target of the /sys/class/net/$interface/device/driver
symlink and take the part after the last /
.
Example:
$ stat --format '%N' /sys/class/net/*/device/driver
‘/sys/class/net/eth0/device/driver’ -> ‘../../../../bus/pci/drivers/jme’
‘/sys/class/net/wlan0/device/driver’ -> ‘../../../../bus/pci/drivers/iwlagn’
精彩评论