To find which driver is controlling your network device, you need look into the sysfs directory. sysfs is a virtual filesystem and mounted at /sys.
# grep "sysfs" /etc/fstab sysfs /sys sysfs defaults 0 0
sysfs provides a glimpse into how the different portions of the kernel are hooked together, with many different symlinks pointing all around the filesystem.
First of all, check your network devices:
# ls /sys/class/net/ eth0 lo tun0 tun1 wlan0
This tells me that I have one ethernet interface (eth0), two vpn interfaces (tun0 and tun0) and one wireless interface (wlan0).
1. Follow the /sys/class/net/eth0/device symlink into the directory which contains the info for eth0. Note that the /sys/class/net/eth0 directory might also be a symlink on the newer versions of the kernel.
# cd /sys/class/net/eth0/device # ls broken_parity_status device irq modalias net remove resource resource2_wc subsystem uevent class driver local_cpulist msi_bus numa_node rescan resource0 resource4 subsystem_device vendor config enable local_cpus msi_irqs power reset resource2 resource4_wc subsystem_vendor vpd
2. Within the directory, there is a symlink to the driver, and within the driver, there is another symlink called module.
# ls -l | grep driver lrwxrwxrwx 1 root root 0 Oct 4 10:34 driver -> ../../../../bus/pci/drivers/r8169 # ls -l driver/ | grep module lrwxrwxrwx 1 root root 0 Oct 4 10:34 module -> ../../../../module/r8169
We can see that module r8169 is controlling your eth0 device.
A easy way to do this is to use the "basename" and "readlink" command:
# basename `readlink /sys/class/net/eth0/device/driver/module` r8169
Here is another example for how to look at a USB device driver:
# ls /sys/class/tty/ | grep USB ttyUSB0
You can trace through sysfs for this device to find the controlling module, as
shown in the previous section:
# basename `readlink /sys/class/tty/ttyUSB0/device/driver/module` pl2303
Summary:
1. Find the proper sysfs class device that the device is bound to. Network devices are listed in /sys/class/net and tty devices in /sys/class/tty. Other types of devices are listed in other directories in /sys/class, depending on the type of device.
2. Trace through the sysfs tree to find the module name that controls this device. It will be found in the /sys/class/class_name/device_name/device/driver/ module, and can be displayed using the readlink and basename applications:
$ basename `readlink /sys/class/class_name/device_name/device/driver/module`
For kernel module installation:
3. Search the kernel Makefiles for the CONFIG_ rule that builds this module name by using find and grep:
# find -type f -name Makefile | xargs grep module_name
4. Search in the kernel configuration system for that configuration value and go to the location in the menu that it specifies to enable that driver to be built.
No comments:
Post a Comment