linux 如何找到导致加载内核模块88XXau.ko的udev规则?[已关闭]

yhuiod9q  于 2023-01-25  发布在  Linux
关注(0)|答案(1)|浏览(210)

此问题似乎与a specific programming problem, a software algorithm, or software tools primarily used by programmers无关。如果您认为此问题与another Stack Exchange site的主题有关,您可以留下评论,说明在何处可以回答此问题。
4个月前关闭。
社区昨天讨论了是否重新讨论此问题,并将其关闭:
原始关闭原因未解决
Improve this question
在我的Linux发行版中,我使用EdimaxEW-7811UTCWi-Fi USB适配器。我已通过以下步骤安装了驱动程序rtl8812au

  • 从源代码构建内核模块88XXau.ko(命令make
  • 将其安装到目录中:/lib/modules/$(uname -r)/kernel/drivers/net/wireless/(命令make install

此驱动程序支持许多Wi-Fi适配器,但我需要编写脚本或其他东西来加载模块88XXau.ko,只有当Wi-Fi适配器正是Edimax EW-7811UTC时。
我想展示两个场景:

  • 在启动时,通过命令lsmod,我已检查是否未**插入Wifi-USB适配器,模块88XXau.ko是否未加载。
  • 当我插入WiFi-USB适配器时,内核和udev自动加载模块,但我找不到执行此加载的特定udev rule

我还没有编写任何udev rule,所以在Linux发行版中必须存在一个默认的udev rule,负责自动加载内核模块88XXau.ko
为了达到我的目标,即加载模块,只有当WiFi适配器是Edimax EW-7811UTC,我需要禁用自动,所以我在这里问是否有人可以告诉我一个过程,找到默认的udev rule为这个驱动程序?
谢谢

8aqjt8rx

8aqjt8rx1#

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}'"

相关问题