source: udev-config/doc/80-drivers.txt@ 7f6363f

6.4
Last change on this file since 7f6363f was 1c48007, checked in by Bruce Dubbs <bdubbs@…>, 16 years ago

Moved bootscripts and udev-config to BOOK
Updated Makefile to automatically generate bootscript and udev-config tarballs
Updated licesnse to be the same as BLFS

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@8548 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 3.9 KB
Line 
1Purpose of rules file:
2
3The rules in this file allow Udev to fully replace the old /sbin/hotplug
4script. They automatically load kernel modules as devices are discovered.
5
6
7Description of rules:
8
9All rules in this file match ACTION=="add", so they only run when devices are
10being added.
11
12ENV{MODALIAS} is the value of the environment variable named MODALIAS. This
13environment variable is sent by the kernel when it sends a uevent for any
14device that has a modalias. Modaliases are strings that can be used to load
15the appropriate kernel module driver.
16
17Generally a modalias will contain information like vendor ID, device ID, and
18possibly other IDs depending on the bus the device is connected to. (USB, for
19instance, has the concept of a "device class" and a "device interface", which
20are basically just ways to standardize the USB protocol for various types of
21devices. This is what allows a single kernel module such as hid.ko to drive
22many different vendors' USB input devices: all devices that support the USB
23HID interface expose the HID interface number in their modalias, and so the
24hid.ko driver can be loaded for each device. When it loads, hid.ko attaches
25to the HID interface and does whatever is needed to work with each device.)
26
27Kernel modules that drive hardware expose a list of modaliases. These
28modaliases are matched against the device modalias by /sbin/modprobe (after
29shell-style expansion), with the help of /sbin/depmod's modules.alias file.
30The upshot of all this is, you can tell Udev to run "/sbin/modprobe modalias",
31and it will load the module that claims it can drive the "modalias" device.
32
33The rule that does this inspects ENV{MODALIAS} to ensure it is not empty. It
34does this by comparing it to "?*" -- inside a match, "*" would match *any*
35string, including the empty string, so to ensure MODALIAS is not empty, we need
36to match against "?*" instead. ("?" matches any one character.)
37
38The Udev RUN+="" option adds a program to run when the rule matches. In this
39case, we tell Udev to run "/sbin/modprobe $env{MODALIAS}". Note that Udev does
40not do path searches; if the executable is not specified with a fully-qualified
41path, it *must* be located under the /lib/udev directory. If it is not, you
42*must* specify a fully-qualified path, as we do here. Also, "$env{string}" is
43replaced by the value of the environment variable "string" when the command
44runs, so this adds the modalias to the modprobe command. The modprobe program
45will do the rest. Finally, the {ignore_error} option is added to the RUN key;
46this prevents Udev from failing the uevent if the modprobe command fails. (The
47modprobe command will fail when run during cold-plugging, if the driver was
48configured into the kernel instead of as a module, for instance.)
49
50There is still one feature of the old hotplug shell-script system that Udev
51cannot provide: blacklisting modules from being auto-loaded. To accomplish
52this, we must use module-init-tools. In /etc/modprobe.conf, if you use the
53"blacklist <module-name>" syntax, modprobe will not load <module-name> under
54any name except its real module name. Any modaliases exposed by that module
55will not be honored.
56
57
58There are also rules in this file for various other types of driver loading.
59PNP-BIOS devices, for instance, expose a list of PNP IDs in their sysfs "id"
60attribute, instead of exposing a single MODALIAS, so one rule loops through
61each ID and tries to load the appropriate module. Several other types of
62devices require an extra module before they will work properly; one example
63of this is IDE tapes, which require the ide-scsi module. Finally, whenever
64any SCSI device is found, the file uses the TEST key to check whether the
65/sys/module/sg directory exists. If not, then the "sg" module -- the SCSI
66generic driver -- is loaded. (That driver creates the module/sg directory,
67so the module/sg test is just to see whether the driver has already been
68loaded.)
69
Note: See TracBrowser for help on using the repository browser.