Changeset 3cf57d40 for udev-config/doc/55-lfs.txt
- Timestamp:
- 01/26/2010 07:28:22 PM (15 years ago)
- Branches:
- 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, 12.2, 12.2-rc1, 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/loongarch-12.2, xry111/mips64el, xry111/multilib, xry111/pip3, xry111/rust-wip-20221008, xry111/update-glibc
- Children:
- 279eb4f
- Parents:
- cf8d194
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
udev-config/doc/55-lfs.txt
rcf8d194 r3cf57d40 1 1 Purpose of rules file: 2 2 3 This is the core rules file for Udev on LFS. If these rules were not included, 4 most devices would either only work for root, or would not work at all. 5 3 Most of the rules installed by Udev itself create devices with the correct 4 properties. This file contains rules that have not been merged upstream yet. 6 5 7 6 Description of rules: 8 7 9 By default, Udev creates device nodes with UID 0, GID 0, and permissions 0660, 10 and in one flat directory structure with all nodes in /dev. This does not 11 always work well. 8 By default, Udev creates device nodes with UID 0, GID 0, and permissions 0660. 12 9 13 KERNEL=="ptmx" 10 ISDN-related devices should be owned by the 'dialout' group, hence the following 11 rule (and similar): 14 12 15 Any uevent generated by the kernel with a name matching "ptmx" will match this 16 rule. Note that the matching done by Udev is shell-style; these are not regex 17 matches. For the ptmx device, we first change the permisions, by assigning to 18 the MODE value: 13 KERNEL=="ippp[0-9]*", GROUP="dialout" 19 14 20 KERNEL=="ptmx", MODE="0666" 21 22 We also assign a different GID to /dev/ptmx (also all other TTY devices), by 23 assigning to the GROUP value: 24 25 KERNEL=="ptmx", MODE="0666", "GROUP="tty" 26 27 28 There are also devices that should not be in /dev, because historically they 29 have been created in subdirectories instead. For instance, all Alsa devices 30 have traditionally been put into the /dev/snd subdirectory: 31 32 KERNEL=="controlC[0-9]*", <...>, NAME="snd/%k" 33 34 "%k" expands into "the original value of KERNEL" (note: not the pattern that was 35 matched against). This type of rule puts any matching device into the snd/ 36 subdirectory. 37 38 Sometimes we need to move devices based on more than just their name. For 39 example, USB printer devices need to be moved to /dev/usb/lpX, but we can't 40 match only "lp[0-9]*", because that would also match parallel port printers. 41 So we match both KERNEL and SUBSYSTEMS in this case, to move USB printers only. 42 43 44 Some devices also commonly have symlinks pointing to them -- for example, 45 /dev/mouse is usually a symlink to /dev/input/mice. We acheive this by 46 assigning to the SYMLINK value. But note that SYMLINK can store multiple values 47 (because each device node could have multiple symlinks pointing to it), so we 48 need to add to the list of symlinks, not overwrite the whole list: 49 50 KERNEL=="mice", <...>, SYMLINK+="mouse" 51 52 If we needed to add multiple symlinks, they would be space-separated inside the 53 double quotes. 54 55 Of course, symlinks, permissions, and device names can all be combined in a 56 rule if needed. But note that if you combine permissions and symlinks, or if 57 you combine GROUP and symlinks, the permissions of the symlink will not be 58 modified, only those of the target device. (This is because the kernel does 59 not pay any attention to the permissions on symlinks, only the permissions on 60 their targets, and there's no reason to change something that won't be used.) 61 62 63 Finally, we have this rule: 64 65 SUBSYSTEM=="usb_device", PROGRAM="/bin/sh -c 'X=%k; X=$${X#usbdev}; B=$${X%%%%.*} D=$${X#*.}; echo bus/usb/$$B/$$D'", NAME="%c" 66 67 This rule matches any device under the SUBSYSTEM of usb_device. (All devices 68 that were traditionally created under /proc/bus/usb/ use this subsystem.) We 69 tell Udev to run the specified PROGRAM; Udev will save the output of this 70 program (it will be available under %c later). 71 72 The program itself is a shell that starts by setting the variable X to the 73 original kernel name (which is "usbdevB.D" for these devices, where B and D are 74 the bus and device numbers of the USB device). Then, the rule re-sets X to the 75 value of X with the string "usbdev" removed from the start. So now, X has the 76 value "B.D". Then, the rule sets B to the value of X after a period, and all 77 characters following it, have been removed from the end; this sets B to just 78 the string "B" (just the bus number of the USB device). Then, the rule sets D 79 to the value of X after a period, and all characters before it, have been 80 removed from the beginning; this sets D to just the string "D" (just the device 81 number). 82 83 Then, the rule echoes "bus/usb/$B/$D" (bus/usb/bus-number/device-number), so 84 Udev will capture that value. The rule sets NAME="%c" to put the device node 85 at /dev/bus/usb/bus-number/device-number. (This is the same layout that the 86 /proc/bus/usb/ devices used.) 87 88 Most of the doubled characters in this rule are doubled so that Udev does not 89 interpret them. The rule looks all the more confusing because of this method 90 of escaping special characters. 91 15 The RTC-related rules cause the setclock bootscript to be run as soon as the 16 RTC device has been created by Udev, meaning that times in log files, for 17 example, are as accurate as possible as quickly as possible. 92 18 93 19 A final word of caution: Any particular rule must be written on one line, and a
Note:
See TracChangeset
for help on using the changeset viewer.