source: udev-config/doc/60-persistent-input.txt@ 10bd240

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 6.4 6.5 6.6 6.7 6.8 7.0 7.1 7.2 7.3 7.4 7.5 7.5-systemd 7.6 7.6-systemd 7.7 7.7-systemd 7.8 7.8-systemd 7.9 7.9-systemd 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 10bd240 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: 4.5 KB
Line 
1Purpose of rules file:
2
3This rules file provides nonvolatile, unique names (in the form of symlinks)
4for input devices that cooperate.
5
6
7Description of rules:
8
9This file starts off with a few rules that make Udev skip the entire file if
10the current uevent is not input related. If ACTION is not "add", or SUBSYSTEM
11is not "input", or KERNEL (the device node) matches "input[0-9]*", then Udev
12will GOTO the LABEL named "persistent_input_end", which is the last rule in
13this file. (input[0-9]* uevents are skipped because they do not create device
14nodes.)
15
16This type of "skip this list of rules if X" operation is done in both the
17persistent input and persistent storage rules files. The reason is efficiency
18-- if Udev had to go run the usb_id and/or path_id programs for non-input and
19non-storage rules, those rules would take much longer to process for no good
20reason.
21
22
23First in this file is a set of rules for by-ID style symlinks. These attempt
24to uniquely identify a device based on its serial number, but there are some
25issues with this. Many USB manufacturers do not provide a unique serial number
26for each device -- for instance, my Microsoft Intellimouse Optical has a USB
27serial number of "Microsoft_Microsoft_IntelliMouse_Optical". This kind of
28nonsensical "serial number" means that if you plug in two Intellimouse Optical
29devices, they will both get the same by-id symlink, and the device that the
30symlink points to will be random. This defeats the purpose of by-ID symlinks.
31(However, I believe this behavior is technically valid according to the USB
32standard. I believe it is not recommended, though.)
33
34Anyway, first in the by-ID rules, we have a rule that runs for any (input)
35device hanging anywhere off a USB bus. It uses the IMPORT{program} option to
36run the "/lib/udev/usb_id -x" program. usb_id looks at the environment to find
37out which device to look at, generates a list of environment-variable VAR=value
38pairs, and prints them. Udev stores this output away while the process is
39running. After the process exits, Udev modifies the current environment to
40include the VARs that usb_id printed. (It assigns the "value"s that usb_id
41printed to each of those VARs.) Specifically, usb_id prints ID_VENDOR,
42ID_MODEL, ID_REVISION, ID_SERIAL, ID_TYPE, and ID_BUS (at least in the case of
43the aforementioned USB optical mouse). These variable names will all be set in
44the environment.
45
46Then, we have a set of rules to set ID_CLASS for various types of devices. The
47rules first check for a "usb"-bus device that has a "bInterfaceClass" of 03 and
48a "bInterfaceProtocol" of 01. If the interface class is 03, this is an HID
49device. If the protocol is 01, it's a keyboard device. So we set ID_CLASS to
50"kbd". The next rule checks whether the interface protocol is 02, and if so,
51sets ID_CLASS to "mouse" (HID devices with a protocol of 02 are mice).
52
53Any input device that the "pcspkr" driver claims must be a speaker. Any input
54device that the "atkbd" driver claims must be a keyboard. Any input device
55that the "psmouse" driver claims must be a mouse. If there's a sysfs attribute
56named "name", whose contents contain "dvb", "DVB", or " IR ", then we set
57ID_CLASS to "ir".
58
59Then, we have a rule to search the tree and find the first parent that has a
60modalias. If that modalias matches the big long ugly string in the rules file,
61we assume this is a joystick device, and set ID_CLASS appropriately. (This
62parent should be the kobject for the joystick device itself. The reason we
63search the tree is that the current uevent is for a device node, not the
64physical joystick device.)
65
66Once the ID_CLASS variable is set properly, we have one more modification to
67perform: if the ID_SERIAL variable was not set at all by the usb_id program, we
68set it to "noserial".
69
70Now that all the environment variables are set up properly, we start generating
71the by-ID symlinks in /dev/input/by-id/. If the current device node's name
72starts with "event", we add "event" into the symlink name. Otherwise, we don't
73add anything for mice. (Other device types don't get a persistent by-ID
74symlink.)
75
76
77Next, we create by-path symlinks. The /lib/udev/path_id program takes the path
78of the device as an argument, and prints out "ID_PATH=string", where "string"
79is the "shortest physical path" to the device. We import this value into the
80environment.
81
82If the path is non-empty, and the device node name starts with "mouse" or
83"event", we add a by-path symlink based on the path and the device class (and
84we also add "event" if it's an event device). This symlink should be stable as
85long as the device never moves to a different port.
86
Note: See TracBrowser for help on using the repository browser.