开发者

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’
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜