linuxwifilinux-device-driverudev

How to find the udev rule which causes the loading of the kernel module 88XXau.ko?


In my Linux distribution I use an Edimax EW-7811UTC Wi-Fi USB Adapter.

Installation of the driver rtl8812au

I have installed the driver rtl8812au from source by following steps:

  • building of the kernel module 88XXau.ko (command make) from source
  • installing it in the directory: /lib/modules/$(uname -r)/kernel/drivers/net/wireless/ (command make install)

This driver support many Wi-Fi adapter, but I need to write a script or something else to load the module 88XXau.ko only if the Wi-Fi adapter is exactly the Edimax EW-7811UTC.

The module 88XXau.ko is automatically loaded

I want to show 2 scenarios:

  • by the command lsmod, I have checked that at boot time if the Wifi-USB adapter is not plugged in, the module 88XXau.ko is not loaded.

  • when I plug in the WiFi-USB adapter the kernel and udev automatically load the module (I have check this by the command lsmod | grep 88XXau), but I can not find the specific udev rule which executes this loading.

I haven't written any udev rule, so in the Linux distribution must be present a default udev rule responsible of this automatic loading of the kernel module 88XXau.ko.

The problem: find the udev rule

To reach my goal that is to load the module only if the WiFi adapter is the Edimax EW-7811UTC, I need to disable the automatism so I'm here to ask if someone could show me a procedure to find the default udev rule for this driver?

Thanks


Solution

  • https://www.linuxfromscratch.org/lfs/view/development/chapter09/udev.html

    Device drivers compiled as modules may have aliases built into them. Aliases are visible in the output of the modinfo program and are usually related to the bus-specific identifiers of devices supported by a module. For example, the snd-fm801 driver supports PCI devices with vendor ID 0x1319 and device ID 0x0801, and has an alias of “pci:v00001319d00000801svsdbc04sc01i*”. For most devices, the bus driver exports the alias of the driver that would handle the device via sysfs. E.g., the /sys/bus/pci/devices/0000:00:0d.0/modalias file might contain the string “pci:v00001319d00000801sv00001319sd00001319bc04sc01i00”. The default rules provided with udev will cause udevd to call out to /sbin/modprobe with the contents of the MODALIAS uevent environment variable (which should be the same as the contents of the modalias file in sysfs), thus loading all modules whose aliases match this string after wildcard expansion.

    https://wiki.archlinux.org/title/Modalias

    $ cd /usr/lib/udev/rules.d
    $ grep -r MODALIAS .
    80-drivers.rules
    5:ENV{MODALIAS}=="?*", RUN{builtin}+="kmod load '$env{MODALIAS}'"