| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 | Purpose of rules file:The rules in this file allow Udev to fully replace the old /sbin/hotplugscript.  They automatically load kernel modules as devices are discovered.Description of rules:All rules in this file match ACTION=="add", so they only run when devices arebeing added.ENV{MODALIAS} is the value of the environment variable named MODALIAS.  Thisenvironment variable is sent by the kernel when it sends a uevent for anydevice that has a modalias.  Modaliases are strings that can be used to loadthe appropriate kernel module driver.Generally a modalias will contain information like vendor ID, device ID, andpossibly other IDs depending on the bus the device is connected to.  (USB, forinstance, has the concept of a "device class" and a "device interface", whichare basically just ways to standardize the USB protocol for various types ofdevices.  This is what allows a single kernel module such as hid.ko to drivemany different vendors' USB input devices: all devices that support the USBHID interface expose the HID interface number in their modalias, and so thehid.ko driver can be loaded for each device.  When it loads, hid.ko attachesto the HID interface and does whatever is needed to work with each device.)Kernel modules that drive hardware expose a list of modaliases.  Thesemodaliases are matched against the device modalias by /sbin/modprobe (aftershell-style expansion), with the help of /sbin/depmod's modules.alias file.The upshot of all this is, you can tell Udev to run "/sbin/modprobe modalias",and it will load the module that claims it can drive the "modalias" device.The rule that does this inspects ENV{MODALIAS} to ensure it is not empty.  Itdoes this by comparing it to "?*" -- inside a match, "*" would match *any*string, including the empty string, so to ensure MODALIAS is not empty, we needto match against "?*" instead.  ("?" matches any one character.)The Udev RUN+="" option adds a program to run when the rule matches.  In thiscase, we tell Udev to run "/sbin/modprobe $env{MODALIAS}".  Note that Udev doesnot do path searches; if the executable is not specified with a fully-qualifiedpath, it *must* be located under the /lib/udev directory.  If it is not, you*must* specify a fully-qualified path, as we do here.  Also, "$env{string}" isreplaced by the value of the environment variable "string" when the commandruns, so this adds the modalias to the modprobe command.  The modprobe programwill do the rest.  Finally, the {ignore_error} option is added to the RUN key;this prevents Udev from failing the uevent if the modprobe command fails.  (Themodprobe command will fail when run during cold-plugging, if the driver wasconfigured into the kernel instead of as a module, for instance.)There is still one feature of the old hotplug shell-script system that Udevcannot provide: blacklisting modules from being auto-loaded.  To accomplishthis, we must use module-init-tools.  In /etc/modprobe.conf, if you use the"blacklist <module-name>" syntax, modprobe will not load <module-name> underany name except its real module name.  Any modaliases exposed by that modulewill not be honored.There are also rules in this file for various other types of driver loading.PNP-BIOS devices, for instance, expose a list of PNP IDs in their sysfs "id"attribute, instead of exposing a single MODALIAS, so one rule loops througheach ID and tries to load the appropriate module.  Several other types ofdevices require an extra module before they will work properly; one exampleof this is IDE tapes, which require the ide-scsi module.  Finally, wheneverany SCSI device is found, the file uses the TEST key to check whether the/sys/module/sg directory exists.  If not, then the "sg" module -- the SCSIgeneric driver -- is loaded.  (That driver creates the module/sg directory,so the module/sg test is just to see whether the driver has already beenloaded.)
 |