diff options
author | Bruce Dubbs <bdubbs@linuxfromscratch.org> | 2008-06-03 21:51:14 +0000 |
---|---|---|
committer | Bruce Dubbs <bdubbs@linuxfromscratch.org> | 2008-06-03 21:51:14 +0000 |
commit | 1c4800743d22d675ccfa48364d8aa558e8b7407c (patch) | |
tree | ca4254cbe5dd5adb0ed8af1f87c26bc569403164 /udev-config | |
parent | 9faa3e27afb932894ace74854fbb76631022446b (diff) |
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
Diffstat (limited to 'udev-config')
-rw-r--r-- | udev-config/55-lfs.rules | 101 | ||||
-rw-r--r-- | udev-config/61-cdrom.rules | 3 | ||||
-rw-r--r-- | udev-config/ChangeLog | 199 | ||||
-rw-r--r-- | udev-config/Makefile | 42 | ||||
-rw-r--r-- | udev-config/contrib/debian/81-cdrom.rules | 3 | ||||
-rw-r--r-- | udev-config/contrib/debian/83-cdrom-symlinks.rules | 12 | ||||
-rw-r--r-- | udev-config/contrib/debian/write_cd_aliases | 111 | ||||
-rw-r--r-- | udev-config/doc/05-udev-early.txt | 33 | ||||
-rw-r--r-- | udev-config/doc/55-lfs.txt | 94 | ||||
-rw-r--r-- | udev-config/doc/60-persistent-input.txt | 86 | ||||
-rw-r--r-- | udev-config/doc/60-persistent-storage.txt | 95 | ||||
-rw-r--r-- | udev-config/doc/61-cdrom.txt | 16 | ||||
-rw-r--r-- | udev-config/doc/80-drivers.txt | 69 | ||||
-rw-r--r-- | udev-config/doc/95-udev-late.txt | 18 | ||||
-rw-r--r-- | udev-config/doc/README | 6 |
15 files changed, 888 insertions, 0 deletions
diff --git a/udev-config/55-lfs.rules b/udev-config/55-lfs.rules new file mode 100644 index 000000000..d920008fc --- /dev/null +++ b/udev-config/55-lfs.rules @@ -0,0 +1,101 @@ +# /etc/udev/rules.d/25-lfs.rules: Rule definitions for LFS. + +# Core kernel devices + +# override both of these +KERNEL=="random", MODE="0444" +KERNEL=="urandom", MODE="0444" + +KERNEL=="aio", MODE="0444" +KERNEL=="kmsg", MODE="0600" +KERNEL=="rtc", MODE="0666" + +# Comms devices + +KERNEL=="rfcomm[0-9]*", GROUP="uucp" +KERNEL=="ippp[0-9]*", GROUP="uucp" +KERNEL=="isdn[0-9]*", GROUP="uucp" +KERNEL=="isdnctrl[0-9]*", GROUP="uucp" +KERNEL=="capi", NAME="capi20", SYMLINK+="isdn/capi20" +KERNEL=="capi?*", NAME="capi/%n", GROUP="uucp" +KERNEL=="dcbri[0-9]*", GROUP="uucp" + +# ALSA devices go in their own subdirectory + +KERNEL=="controlC[0-9]*", GROUP="audio", NAME="snd/%k" +KERNEL=="hwC[0-9]*D[0-9]*", GROUP="audio", NAME="snd/%k" +KERNEL=="pcmC[0-9]*D[0-9]*[cp]", GROUP="audio", NAME="snd/%k" +KERNEL=="midiC[0-9]*D[0-9]*", GROUP="audio", NAME="snd/%k" +KERNEL=="timer", GROUP="audio", NAME="snd/%k" +KERNEL=="seq", GROUP="audio", NAME="snd/%k" + +# Sound devices + +KERNEL=="admmidi*", GROUP="audio" +KERNEL=="adsp*", GROUP="audio" +KERNEL=="aload*", GROUP="audio" +KERNEL=="amidi*", GROUP="audio" +KERNEL=="amixer*", GROUP="audio" +KERNEL=="audio*", GROUP="audio" +KERNEL=="dmfm*", GROUP="audio" +KERNEL=="dmmidi*", GROUP="audio" +KERNEL=="dsp*", GROUP="audio" +KERNEL=="midi*", GROUP="audio" +KERNEL=="mixer*", GROUP="audio" +KERNEL=="music", GROUP="audio" +KERNEL=="sequencer*", GROUP="audio" + +# Input devices + +# override MODE on these four +KERNEL=="mice", MODE="0644", SYMLINK+="mouse" +KERNEL=="mouse*", MODE="0644" +KERNEL=="event*", MODE="0644" +KERNEL=="ts*", MODE="0644" + +KERNEL=="psaux", MODE="0644" +KERNEL=="js", MODE="0644" +KERNEL=="djs", MODE="0644" + +# USB devices go in their own subdirectory + +KERNEL=="hiddev*", NAME="usb/%k" +KERNEL=="legousbtower*", NAME="usb/%k" +KERNEL=="dabusb*", NAME="usb/%k" +SUBSYSTEMS=="usb", KERNEL=="lp[0-9]*", NAME="usb/%k" + +# DRI devices are managed by the X server, so prevent udev from creating them + +KERNEL=="card*", OPTIONS+="ignore_device" + +# Video devices + +KERNEL=="fb[0-9]*", GROUP="video" +KERNEL=="video[0-9]*", GROUP="video" +KERNEL=="radio[0-9]*", GROUP="video" +KERNEL=="vbi[0-9]*", GROUP="video" +KERNEL=="vtx[0-9]*", GROUP="video" + +# DVB devices + +SUBSYSTEM=="dvb", GROUP="video" + +# Storage/memory devices + +# override: make group-writable +SUBSYSTEM=="block", MODE="0660" + +# dmsetup and lvm2 related programs create devicemapper devices so we prevent +# udev from creating them + +KERNEL=="dm-*", OPTIONS+="ignore_device" + +# Tape devices + +# override all these +KERNEL=="ht[0-9]*", GROUP="tape" +KERNEL=="nht[0-9]*", GROUP="tape" +KERNEL=="pt[0-9]*", GROUP="tape" +KERNEL=="npt[0-9]*", GROUP="tape" +KERNEL=="st[0-9]*", GROUP="tape" +KERNEL=="nst[0-9]*", GROUP="tape" diff --git a/udev-config/61-cdrom.rules b/udev-config/61-cdrom.rules new file mode 100644 index 000000000..5a38a7210 --- /dev/null +++ b/udev-config/61-cdrom.rules @@ -0,0 +1,3 @@ +# /etc/udev/rules.d/81-cdrom.rules: Set CD-ROM permissions. + +ACTION=="add", SUBSYSTEM=="block", ENV{ID_TYPE}=="cd", GROUP="cdrom" diff --git a/udev-config/ChangeLog b/udev-config/ChangeLog new file mode 100644 index 000000000..c7a0df19a --- /dev/null +++ b/udev-config/ChangeLog @@ -0,0 +1,199 @@ +2008-05-21 Bryan Kadzban <bryan@linuxfromscratch.org> + * 81-firmware.rules, doc/81-firmware.txt: Remove. This rule is + already handled by udev's 50-udev-default.rules file. The docs + can be added back later if needed. + * Makefile: Don't install the above deleted files. + * 55-lfs.rules: Remove the device-mapper rule, since the upstream + 50-udev-default.rules file handles it properly. + +2008-04-02 Bryan Kadzban <bryan@linuxfromscratch.org> + * Makefile: Make the package DESTDIR-friendly by installing the docs + into a fixed $(PREFIX)/share/doc/udev-config directory, instead of + trying to figure out what version of udev was just installed. + +2007-10-30 Bryan Kadzban <bryan@linuxfromscratch.org> + * 55-lfs.rules: Since the dialout group was renamed to uucp, delete + the rules that override upstream's assignment of the dialout group. + Replace "dialout" with "uucp" on the remaining rules. + +2007-10-29 Bryan Kadzban <bryan@linuxfromscratch.org> + * 51-lfs.rules: Move to 55-lfs.rules. + * doc/51-lfs.rules: Move to doc/55-lfs.rules. + +2007-10-27 Bryan Kadzban <bryan@linuxfromscratch.org> + * 25-lfs.rules: Some rules in here are duplicates of rules from udev's + new 50-udev-defaults.rules file; remove them. Override permissions + where needed elsewhere (and document overrides in comments). + * 26-modprobe.rules: Provided by udev's 80-drivers.rules and built-in + modaliases for SCSI device-type modules in 2.6.22+ kernels; remove. + + * 25-lfs.rules: Move to 51-lfs.rules. + * 27-firmware.rules: Move to 81-firmware.rules. + * 81-cdrom.rules: Move to 61-cdrom.rules. + + * doc/25-lfs.txt: Rename to 51-lfs.txt. + * doc/26-modprobe.txt: Rename to 80-drivers.txt, and modify to reflect + the upstream rules. + * doc/27-firmware.txt: Rename to 81-firmware.txt. + * doc/81-cdrom.txt: Rename to 61-cdrom.txt. + + * Makefile: Use new filenames. + +2007-07-31 Dan Nicholson <dnicholson@linuxfromscratch.org> + * 25-lfs.rules: Changed the usb_device rule tto create /dev/bus/usb + nodes if the usb_device in 2.6.22+ kernels. The rule was also changed + to only trigger on "add" events. This change is not backwards + compatible with older kernels. + +2007-06-12 Dan Nicholson <dnicholson@linuxfromscratch.org> + * 25-lfs.rules: Fix the CPUID nodes from cpu/%n/cpu to cpu/%n/cpuid, + which is what's expected in userspace apps such as x86info. + +2007-06-08 Bryan Kadzban <bryan@linuxfromscratch.org> + * 25-lfs.rules: Add rules for DVB devices (create nodes in /dev/dvb/) + and floppies (create extra nodes based on CMOS type), copied from + the SuSE rules file. Thanks to Alexander Patrakov for the bugreport. + +2007-03-04 Matthew Burgess <matthew@linuxfromscratch.org> + * Makefile: Use `udevd --version' to work out what version of Udev is + installed (requires Udev >= 106) + +2007-01-02 Bryan Kadzban <bryan@linuxfromscratch.org> + * 25-lfs.rules: Change CPU devices (cpu, msr, microcode) to be in + /dev/cpu/ and /dev/cpu/N/, to match Documentation/devices.txt. + +2006-10-21 Bryan Kadzban <bryan@linuxfromscratch.org> + * Makefile: Add a missing backslash in install-extra-doc. + + * 05-udev-early.rules, 60-persistent-input.rules, + 60-persistent-storage.rules, 95-udev-late.rules: Remove. The book + will install these files from udev's etc/udev/rules.d directory + instead. + * Makefile: Don't install these rules files after all. Also, only + install corresponding docs if requested. + +2006-10-20 Bryan Kadzban <bryan@linuxfromscratch.org> + * Makefile: Added; contains targets to install rules and doc files. + From Dan Nicholson. + +2006-10-14 Bryan Kadzban <bryan@linuxfromscratch.org> + * 05-udev-early.rules, 60-persistent-storage.rules: Sync up with + upstream sample rules files (from udev-102), except for one rule + which is more specific in our tarball and should probably be changed + upstream. + * doc/60-persistent-storage.txt: Modify to match the changes. Also + fix a couple typos. + + * 25-lfs.rules: Remove duplicate rules (ttyS[0-9]* is also matched by + tty[BC...S...][0-9]*, and ttyUSB[0-9]* is in there twice). + + * 25-lfs.rules: Fix Alsa device KERNEL rules. Udev uses shell-style + glob matching, not regular expressions, so the old rules would match + nonsense device names like hw0asdf and pcmDzxcv. As long as the first + character after the "fixed" portion was in the list, the rule would + match; it wouldn't apply the same character range to later characters. + + * doc/25-lfs.txt: Add a note on interaction between permissions and + symlinks. + +2006-10-09 Bryan Kadzban <bryan@linuxfromscrtach.org> + * 25-lfs.rules: Fix fb[0-9]* device permissions (should use the default + 0660). + + * doc/25-lfs.txt: Fix typo: /dev/ptmx is given mode 0666, not 0660. + Also tweak the comment about other TTY devices. + +2006-10-04 Bryan Kadzban <bryan@linuxfromscratch.org> + * 05-udev-early.rules: Remove WAIT_FOR_SYSFS="bus" rule. With kernel + 2.6.18, this rule is no longer required. + + * doc/05-udev-early.txt: Update to match. + +2006-09-28 Bryan Kadzban <bryan@linuxfromscratch.org> + * doc/60-persistent-storage.txt: Explain persistent storage rules, or + at least the parts I understand. (I don't use DASD or netblock or + several other supported configurations.) + + * doc/81-cdrom.txt: Explain 81-cdrom.rules. + + * doc/95-udev-late.txt: Explain 95-udev-late.rules. Documentation is + now finished. + +2006-09-26 Bryan Kadzban <bryan@linuxfromscratch.org> + * doc/60-persistent-input.txt: Explain (in probably too much detail) + 60-persistent-input.rules. + +2006-09-24 Bryan Kadzban <bryan@linuxfromscratch.org> + * doc/05-udev-early.txt: Rewrap to fit 80 columns. + + * doc/26-modprobe.txt: Explain 26-modprobe.rules, and modaliases. + + * doc/27-firmware.txt: Explain 27-firmware.rules. + +2006-09-24 Bryan Kadzban <bryan@linuxfromscratch.org> + * doc/25-lfs.txt: Explain 25-lfs.rules. + + * 25-lfs.rules: Use SYMLINK+= for isdn/capi20 also. + +2006-09-23 Bryan Kadzban <bryan@linuxfromscratch.org> + * doc: New subdirectory to contain documentation of rules + * doc/README: New file, top-level documentation + * doc/*.txt: New documentation files, one for each rules file. Only + 05-udev-early.txt has anything in it. + +2006-09-23 Bryan Kadzban <bryan@linuxfromscratch.org> + * 25-lfs.rules: Add "ignore_device" to OPTIONS for DRI devices, instead + of setting NAME to an empty string. This matches the way we ignore + devmapper / LVM devices. + +2006-09-22 Bryan Kadzban <bryan@linuxfromscratch.org> + * 60-persistent-input.rules, 95-udev-late.rules: Import from udev-100. + 60-persistent-input.rules creates persistent symlinks for input + devices, and 95-udev-late.rules enables udevmonitor. + + * 60-persistent-storage.rules: Replace ATTRS{../removable} with just + ATTRS{removable} on partition devices. Replace ATTRS{removable} + with ATTR{removable} on whole-disk devices. + +2006-09-20 Bryan Kadzban <bryan@linuxfromscratch.org> + * 05-early.rules: Missed a rule in the last change. ENV{PHYSDEVBUS} + in the rule that waits for the "bus" symlink should be replaced by + SUBSYSTEMS. + +2006-09-20 Bryan Kadzban <bryan@linuxfromscratch.org> + * Adapted rules to the new matches used in udev-098 and above (e.g., + SYSFS becomes ATTRS). Prevents warnings, and support for the old + matches will be removed eventually. These rules will not work with + udev-097 and before! + * Fixed several bugs in the rules left over from previous udev + versions (missing commas, overwriting user symlinks using ="..." + instead of +="...", and matching against "*" instead of "?*"). + + * Renamed CHANGELOG to ChangeLog, started using pseudo-GNU-format + entries. (See standards.info; search it for "changelog" to get + the general gist.) + +dnicholson - Jul 14, 2006 + * Fixed usbdev PROGRAM so that it works with the BusyBox sh. Thanks + to Anthony Wright. + +n/a - Jul 12, 2006 + * Added options so temporary nodes are not created with device-mapper + * Adapted cdrom rules to identify CD-ROM drives correctly by adding + SUBSYSTEM=="block" test. + * Added simple 81-cdrom.rules file to set cdrom group ownership + +n/a - Jun 07, 2006 + * Removed nvidia rules + * Removed bug reporting rule + * Moved Debian-based persistent CD-ROM rules to contrib + * Adapted firmware rule to udev-093 + +n/a - May 15, 2006 + * Part one of 25-lfs.rules rewrite + * Some minor tweaking of the layout + +n/a - May 12, 2006 + * Initial import of the udev-config directory. + * Reorganized and modularized the rules files. + * Added explanatory comments diff --git a/udev-config/Makefile b/udev-config/Makefile new file mode 100644 index 000000000..18451cd48 --- /dev/null +++ b/udev-config/Makefile @@ -0,0 +1,42 @@ +# Makefile to install udev rules and documentation + +PREFIX = /usr +RULES_DIR = /etc/udev/rules.d +INSTALL = install +INSTALL_DATA = $(INSTALL) -m644 +RULES_FILES = \ + 55-lfs.rules \ + 61-cdrom.rules +DOC_FILES = $(RULES_FILES:.rules=.txt) + +EXTRA_DOC_FILES = \ + 05-udev-early.txt \ + 60-persistent-input.txt \ + 60-persistent-storage.txt \ + 80-drivers.txt \ + 95-udev-late.txt + +# Location to install the docs +DOC_DIR = $(PREFIX)/share/doc/udev-config + +all: + +install: install-rules + +install-rules: + $(INSTALL) -d $(DESTDIR)$(RULES_DIR) + for rule in $(RULES_FILES); do \ + $(INSTALL_DATA) $$rule $(DESTDIR)$(RULES_DIR) || exit 1; \ + done; + +install-doc: + $(INSTALL) -d $(DESTDIR)$(DOC_DIR) + for doc in $(DOC_FILES); do \ + $(INSTALL_DATA) doc/$$doc $(DESTDIR)$(DOC_DIR) || exit 1; \ + done + +install-extra-doc: + $(INSTALL) -d $(DESTDIR)$(DOC_DIR) + for doc in $(EXTRA_DOC_FILES); do \ + $(INSTALL_DATA) doc/$$doc $(DESTDIR)$(DOC_DIR) || exit 1; \ + done diff --git a/udev-config/contrib/debian/81-cdrom.rules b/udev-config/contrib/debian/81-cdrom.rules new file mode 100644 index 000000000..cb7ea5748 --- /dev/null +++ b/udev-config/contrib/debian/81-cdrom.rules @@ -0,0 +1,3 @@ +# /etc/udev/rules.d/81-cdrom.rules: Set CD-ROM permissions and get device capabilities + +ACTION=="add", SUBSYSTEM=="block", ENV{ID_TYPE}=="cd", IMPORT{program}="cdrom_id --export $tempnode", GROUP="cdrom" diff --git a/udev-config/contrib/debian/83-cdrom-symlinks.rules b/udev-config/contrib/debian/83-cdrom-symlinks.rules new file mode 100644 index 000000000..4713c0b92 --- /dev/null +++ b/udev-config/contrib/debian/83-cdrom-symlinks.rules @@ -0,0 +1,12 @@ +# /etc/udev/rules.d/83-cdrom-symlinks.rules: Determine CD drive capability. + +ACTION!="add", GOTO="cd_aliases_generator_end" +SUBSYSTEM!="block", GOTO="cd_aliases_generator_end" +ENV{GENERATED}=="?*", GOTO="cd_aliases_generator_end" + +# Fail the uevent if the autogenerated rules cannot be saved +ENV{ID_CDROM}=="?*", PROGRAM="/bin/grep -c ' / [^[:space:]]* rw' /proc/mounts", RESULT!="2", RUN+="/bin/false", GOTO="cd_aliases_generator_end" + +ENV{ID_CDROM}=="?*", PROGRAM="write_cd_aliases", SYMLINK+="%c" + +LABEL="cd_aliases_generator_end" diff --git a/udev-config/contrib/debian/write_cd_aliases b/udev-config/contrib/debian/write_cd_aliases new file mode 100644 index 000000000..6443b6dcf --- /dev/null +++ b/udev-config/contrib/debian/write_cd_aliases @@ -0,0 +1,111 @@ +#!/bin/sh -e + +RULES_FILE="/etc/udev/rules.d/82-persistent-cd.rules" + +############################################################################## +lock_rules_file() { + RULES_LOCK="/dev/.udev/.lock-${RULES_FILE##*/}" + + retry=30 + while ! mkdir $RULES_LOCK 2> /dev/null; do + if [ $retry -eq 0 ]; then + echo "Cannot lock $RULES_FILE!" >&2 + exit 2 + fi + sleep 1 + retry=$(($retry - 1)) + done +} + +unlock_rules_file() { + rmdir $RULES_LOCK || true +} + +############################################################################## +find_next_available() { + # use echo to convert newlines to spaces + local links=`echo $(find_all_symlinks $1)` + local basename=${links%%[ 0-9]*} + local max=-1 + for name in $links; do + local num=${name#$basename} + [ "$num" ] || num=0 + [ $num -gt $max ] && max=$num + done + + max=$(($max + 1)) + # "name0" actually is just "name" + [ $max -eq 0 ] && return + echo "$max" +} + +find_all_symlinks() { + local linkre="$1" + local match="$2" + + [ -e $RULES_FILE ] || return + + local search='.*[[:space:],]SYMLINK+="\('"$linkre"'\)"[[:space:]]*\(,.*\|\\\|\)$' + + sed -n -e "${match}s/${search}/\1/p" $RULES_FILE +} + +write_rule() { + local match="$1" + local link="$2" + local comment="$3" + + [ -e "$RULES_FILE" ] || PRINT_HEADER=1 + { + if [ "$PRINT_HEADER" ]; then + PRINT_HEADER= + echo "# This file was automatically generated by the $0" + echo "# program, probably run by the 83-cdrom.rules rules file." + echo "#" + echo "# You can modify it, as long as you keep each rule on a single line" + echo "# and set the \$GENERATED variable." + echo "" + fi + + [ "$comment" ] && echo "# $comment" + echo "ACTION==\"add\", SUBSYSTEM==\"block\", $match, ENV{ID_CDROM}==\"1\", SYMLINK+=\"$link\", ENV{GENERATED}=\"1\"" + } >> $RULES_FILE + SYMLINKS="$SYMLINKS $link" +} + +############################################################################## +if [ -z "$DEVPATH" ]; then + echo "Missing \$DEVPATH." >&2 + exit 1 +fi +if [ -z "$ID_CDROM" ]; then + echo "$DEVPATH is not a CD reader." >&2 + exit 1 +fi + +# Prevent parallel processes from modifying the file at the same time. +lock_rules_file + +link_num=$(find_next_available 'cdrom[0-9]*') + +#match="ENV{ID_PATH}==\"$ID_PATH\"" + +#kernel=${DEVPATH##*/} +#match="KERNEL==\"$kernel\"" + +id=${PHYSDEVPATH##*/} +match="BUS==\"$PHYSDEVBUS\", ID==\"$id\"" + +comment="$ID_MODEL ($ID_PATH)" + + write_rule "$match" "cdrom$link_num" "$comment" +[ "$ID_CDROM_CD_RW" ] && write_rule "$match" "cdrw$link_num" +[ "$ID_CDROM_DVD" ] && write_rule "$match" "dvd$link_num" +[ "$ID_CDROM_DVD_RW" ] && write_rule "$match" "dvdrw$link_num" + +unlock_rules_file + +echo $SYMLINKS + +exit 0 + diff --git a/udev-config/doc/05-udev-early.txt b/udev-config/doc/05-udev-early.txt new file mode 100644 index 000000000..9c0fb4fb8 --- /dev/null +++ b/udev-config/doc/05-udev-early.txt @@ -0,0 +1,33 @@ +Purpose of rules file: + +The kernel does not always fully populate a given kobject's attributes before +sending the uevent for that kobject. This means that a given sysfs directory +may not have all the required files in it (each directory corresponds to a +kobject, and each file corresponds to an attribute). + +Therefore, we must sometimes wait for attributes to show up when devices are +discovered. This is accomplished by udev's WAIT_FOR_SYSFS rule types. + + +Description of rules: + +All rules in this file match ACTION="add", because none of them apply when +devices are being removed. + +SUBSYSTEM is the kernel subsystem that the device uses. Current kernels have +some issues with SCSI device attributes being created too late. For any device +with a SUBSYSTEM of scsi, we must wait for the ioerr_cnt attribute. (This is +the last attribute created for SCSI devices, so when this attribute appears, +the kobject is fully populated.) + +It is also possible to use SUBSYSTEMS in Udev rules. Using SUBSYSTEMS would +cause Udev to search up the device tree for a matching SUBSYSTEM value. (Note +that "the device tree" is not necessarily the same as the path under /sys (the +DEVPATH). Rather, "up the device tree" is the path followed by udevinfo when +it is given the argument "-a".) + +We do not use SUBSYSTEMS in this rule, because we only care about the SUBSYSTEM +of the kobject in question. We don't care about devices that are children of +SCSI devices, only the SCSI device itself. We will use SUBSYSTEMS in later +rules, though. + diff --git a/udev-config/doc/55-lfs.txt b/udev-config/doc/55-lfs.txt new file mode 100644 index 000000000..7b09c79a0 --- /dev/null +++ b/udev-config/doc/55-lfs.txt @@ -0,0 +1,94 @@ +Purpose of rules file: + +This is the core rules file for Udev on LFS. If these rules were not included, +most devices would either only work for root, or would not work at all. + + +Description of rules: + +By default, Udev creates device nodes with UID 0, GID 0, and permissions 0660, +and in one flat directory structure with all nodes in /dev. This does not +always work well. + +KERNEL=="ptmx" + +Any uevent generated by the kernel with a name matching "ptmx" will match this +rule. Note that the matching done by Udev is shell-style; these are not regex +matches. For the ptmx device, we first change the permisions, by assigning to +the MODE value: + +KERNEL=="ptmx", MODE="0666" + +We also assign a different GID to /dev/ptmx (also all other TTY devices), by +assigning to the GROUP value: + +KERNEL=="ptmx", MODE="0666", "GROUP="tty" + + +There are also devices that should not be in /dev, because historically they +have been created in subdirectories instead. For instance, all Alsa devices +have traditionally been put into the /dev/snd subdirectory: + +KERNEL=="controlC[0-9]*", <...>, NAME="snd/%k" + +"%k" expands into "the original value of KERNEL" (note: not the pattern that was +matched against). This type of rule puts any matching device into the snd/ +subdirectory. + +Sometimes we need to move devices based on more than just their name. For +example, USB printer devices need to be moved to /dev/usb/lpX, but we can't +match only "lp[0-9]*", because that would also match parallel port printers. +So we match both KERNEL and SUBSYSTEMS in this case, to move USB printers only. + + +Some devices also commonly have symlinks pointing to them -- for example, +/dev/mouse is usually a symlink to /dev/input/mice. We acheive this by +assigning to the SYMLINK value. But note that SYMLINK can store multiple values +(because each device node could have multiple symlinks pointing to it), so we +need to add to the list of symlinks, not overwrite the whole list: + +KERNEL=="mice", <...>, SYMLINK+="mouse" + +If we needed to add multiple symlinks, they would be space-separated inside the +double quotes. + +Of course, symlinks, permissions, and device names can all be combined in a +rule if needed. But note that if you combine permissions and symlinks, or if +you combine GROUP and symlinks, the permissions of the symlink will not be +modified, only those of the target device. (This is because the kernel does +not pay any attention to the permissions on symlinks, only the permissions on +their targets, and there's no reason to change something that won't be used.) + + +Finally, we have this rule: + +SUBSYSTEM=="usb_device", PROGRAM="/bin/sh -c 'X=%k; X=$${X#usbdev}; B=$${X%%%%.*} D=$${X#*.}; echo bus/usb/$$B/$$D'", NAME="%c" + +This rule matches any device under the SUBSYSTEM of usb_device. (All devices +that were traditionally created under /proc/bus/usb/ use this subsystem.) We +tell Udev to run the specified PROGRAM; Udev will save the output of this +program (it will be available under %c later). + +The program itself is a shell that starts by setting the variable X to the +original kernel name (which is "usbdevB.D" for these devices, where B and D are +the bus and device numbers of the USB device). Then, the rule re-sets X to the +value of X with the string "usbdev" removed from the start. So now, X has the +value "B.D". Then, the rule sets B to the value of X after a period, and all +characters following it, have been removed from the end; this sets B to just +the string "B" (just the bus number of the USB device). Then, the rule sets D +to the value of X after a period, and all characters before it, have been +removed from the beginning; this sets D to just the string "D" (just the device +number). + +Then, the rule echoes "bus/usb/$B/$D" (bus/usb/bus-number/device-number), so +Udev will capture that value. The rule sets NAME="%c" to put the device node +at /dev/bus/usb/bus-number/device-number. (This is the same layout that the +/proc/bus/usb/ devices used.) + +Most of the doubled characters in this rule are doubled so that Udev does not +interpret them. The rule looks all the more confusing because of this method +of escaping special characters. + + +A final word of caution: Any particular rule must be written on one line, and a +comma must separate each part of the rule. diff --git a/udev-config/doc/60-persistent-input.txt b/udev-config/doc/60-persistent-input.txt new file mode 100644 index 000000000..45030723f --- /dev/null +++ b/udev-config/doc/60-persistent-input.txt @@ -0,0 +1,86 @@ +Purpose of rules file: + +This rules file provides nonvolatile, unique names (in the form of symlinks) +for input devices that cooperate. + + +Description of rules: + +This file starts off with a few rules that make Udev skip the entire file if +the current uevent is not input related. If ACTION is not "add", or SUBSYSTEM +is not "input", or KERNEL (the device node) matches "input[0-9]*", then Udev +will GOTO the LABEL named "persistent_input_end", which is the last rule in +this file. (input[0-9]* uevents are skipped because they do not create device +nodes.) + +This type of "skip this list of rules if X" operation is done in both the +persistent input and persistent storage rules files. The reason is efficiency +-- if Udev had to go run the usb_id and/or path_id programs for non-input and +non-storage rules, those rules would take much longer to process for no good +reason. + + +First in this file is a set of rules for by-ID style symlinks. These attempt +to uniquely identify a device based on its serial number, but there are some +issues with this. Many USB manufacturers do not provide a unique serial number +for each device -- for instance, my Microsoft Intellimouse Optical has a USB +serial number of "Microsoft_Microsoft_IntelliMouse_Optical". This kind of +nonsensical "serial number" means that if you plug in two Intellimouse Optical +devices, they will both get the same by-id symlink, and the device that the +symlink points to will be random. This defeats the purpose of by-ID symlinks. +(However, I believe this behavior is technically valid according to the USB +standard. I believe it is not recommended, though.) + +Anyway, first in the by-ID rules, we have a rule that runs for any (input) +device hanging anywhere off a USB bus. It uses the IMPORT{program} option to +run the "/lib/udev/usb_id -x" program. usb_id looks at the environment to find +out which device to look at, generates a list of environment-variable VAR=value +pairs, and prints them. Udev stores this output away while the process is +running. After the process exits, Udev modifies the current environment to +include the VARs that usb_id printed. (It assigns the "value"s that usb_id +printed to each of those VARs.) Specifically, usb_id prints ID_VENDOR, +ID_MODEL, ID_REVISION, ID_SERIAL, ID_TYPE, and ID_BUS (at least in the case of +the aforementioned USB optical mouse). These variable names will all be set in +the environment. + +Then, we have a set of rules to set ID_CLASS for various types of devices. The +rules first check for a "usb"-bus device that has a "bInterfaceClass" of 03 and +a "bInterfaceProtocol" of 01. If the interface class is 03, this is an HID +device. If the protocol is 01, it's a keyboard device. So we set ID_CLASS to +"kbd". The next rule checks whether the interface protocol is 02, and if so, +sets ID_CLASS to "mouse" (HID devices with a protocol of 02 are mice). + +Any input device that the "pcspkr" driver claims must be a speaker. Any input +device that the "atkbd" driver claims must be a keyboard. Any input device +that the "psmouse" driver claims must be a mouse. If there's a sysfs attribute +named "name", whose contents contain "dvb", "DVB", or " IR ", then we set +ID_CLASS to "ir". + +Then, we have a rule to search the tree and find the first parent that has a +modalias. If that modalias matches the big long ugly string in the rules file, +we assume this is a joystick device, and set ID_CLASS appropriately. (This +parent should be the kobject for the joystick device itself. The reason we +search the tree is that the current uevent is for a device node, not the +physical joystick device.) + +Once the ID_CLASS variable is set properly, we have one more modification to +perform: if the ID_SERIAL variable was not set at all by the usb_id program, we +set it to "noserial". + +Now that all the environment variables are set up properly, we start generating +the by-ID symlinks in /dev/input/by-id/. If the current device node's name +starts with "event", we add "event" into the symlink name. Otherwise, we don't +add anything for mice. (Other device types don't get a persistent by-ID +symlink.) + + +Next, we create by-path symlinks. The /lib/udev/path_id program takes the path +of the device as an argument, and prints out "ID_PATH=string", where "string" +is the "shortest physical path" to the device. We import this value into the +environment. + +If the path is non-empty, and the device node name starts with "mouse" or +"event", we add a by-path symlink based on the path and the device class (and +we also add "event" if it's an event device). This symlink should be stable as +long as the device never moves to a different port. + diff --git a/udev-config/doc/60-persistent-storage.txt b/udev-config/doc/60-persistent-storage.txt new file mode 100644 index 000000000..32062c559 --- /dev/null +++ b/udev-config/doc/60-persistent-storage.txt @@ -0,0 +1,95 @@ +Purpose of rules file: + +This rules file provides nonvolatile, unique names (in the form of symlinks) +for various types of storage devices -- both IDE/ATA and SCSI. + + +Description of rules: + +First, similar to the 60-persistent-input.rules file, we skip the entire file +for uevents that this rules file should not apply to, as an optimization. The +file does not apply to removal uevents or non-block devices. It does not apply +to ramdisks, loopback-mount devices, floppy disks, netblock devices, or device- +mapper devices. It also should not apply to removable devices (that is, non- +partition devices with attributes named "removable" with the value "1", or +partition devices whose parents have "removable" set to "1" -- partition +kobjects don't have the "removable" attribute, only whole-disk kobjects do). + +For partition devices, we use the IMPORT{parent} option to pull in all the +environment variables that get set for the parent device. (The parent of a +partition device is the containing whole-disk device.) The IMPORT{parent} +option is documented in the udev(7) manpage, but basically the value that we +assign is used as a filter of environment variable names to import. + +Now, we start with rules to create by-ID symlinks (similar to the by-ID links +created for input devices). For hd* whole-disk devices (they're IDE/ATA, since +they start with hd), we run the ata_id program in --export mode. The ata_id +program requires a device node to be passed, so we also use the $tempnode Udev +variable -- this causes Udev to create a temporary device node somewhere and +substitute its name where $tempnode appears in the program command line. + +The ata_id program, in --export mode, prints several ID_* values. If we're +looking at a whole-disk device, and if ID_SERIAL is among those, we add a +symlink containing the device's ID_MODEL and ID_SERIAL values. If we're +looking at a partition device, we create an ID_MODEL- and ID_SERIAL-based +symlink also, but we add -partX to the end of the link name (where X is the +partition number). + +For SCSI devices, we first make some modifications to the environment. If the +device's kobject has a parent with a non-empty "ieee1394_id" attribute, then +the device is Firewire, so we set the ID_SERIAL environment variable to the +value of that attribute, and we set ID_BUS to "ieee1394". Now, if ID_SERIAL is +not set, we run usb_id, which (if this is a USB storage device) will print +various values. If ID_SERIAL is still unset, we run scsi_id with a set of +parameters designed to get an ID_SERIAL by querying the device itself. If that +still fails, we try running scsi_id in a mode that prints the information even +if the disk doesn't support so-called "vital product data" pages. If the +uevent is for a DASD device, we run dasd_id. + +If one of these *_id programs gave us an ID_SERIAL, then for whole-disk devices +we create a by-ID symlink using the ID_BUS and ID_SERIAL. For partition +devices, we create a by-ID symlink that has the same form except we add -partX +to the end (just like for IDE/ATA devices). + + +Now we have some rules to create by-path persistent symlinks. We start by +running the path_id program on the DEVPATH (%p) value. For whole-disk devices +and SCSI ROM type devices, we create a symlink directly, using the environment +variable ID_PATH, under the /dev/disk/by-path directory. But for SCSI tape +devices, we create a by-path symlink in the /dev/tape/by-path directory (we +base the symlink on the same information, though: the ID_PATH value printed by +path_id). Now, for both SCSI ROM and SCSI tape devices, we skip everything +that's left in the rules file (this is another optimization: neither SCSI ROM +nor SCSI tape devices have UUIDs, labels, or EDD information). + +For partition devices, we now create a by-path symlink of the same form as the +other partition device persistent symlinks (that is, with the same name as the +parent device, but with -partX added). We know that ID_PATH is set whenever it +applies, because we ran the path_id program on the parent device, and we did an +IMPORT{parent} on ID_* earlier in the rules file. + +Now we create by-label and by-uuid symlinks. These use properties of various +filesystems to generate a persistent name for a partition. For instance, if +you use the ext2 filesystem, you can use e2label to assign a label, and mke2fs +assigns a UUID when the filesystem is created. MS-DOS compatible filesystems +also assign a "UUID" (actually it's just a serial number, created based on the +date and time the partition was formatted, so it is not unique), which these +rules will also use. But for removable partitions, we skip the rules (for the +same reason as we skipped them above for removable disks). + +We run the vol_id program to get ID_FS_USAGE, ID_FS_UUID, and ID_FS_LABEL_SAFE +values. (vol_id supports other values as well, but we do not use them here.) +ID_FS_USAGE corresponds to the way the filesystem is supposed to be used; if it +gets set to "filesystem", "other", or "crypto", we create a symlink. If +ID_FS_UUID is set, we use it in a by-uuid symlink. If ID_FS_LABEL_SAFE is set, +we use it in a by-label symlink. + +Finally, we create EDD-based symlinks in the by-id directory. For whole-disk +devices, we run edd_id to get the EDD-generated ID string. (For partition +devices, we import this string from the parent.) If edd_id yields an ID_EDD +value, we use it in a symlink, for both whole disks and partitions. + + +The last rule in the file is merely a LABEL that various other rules use to +bypass the file (or the rest of the file) when needed. + diff --git a/udev-config/doc/61-cdrom.txt b/udev-config/doc/61-cdrom.txt new file mode 100644 index 000000000..ff7887fe3 --- /dev/null +++ b/udev-config/doc/61-cdrom.txt @@ -0,0 +1,16 @@ +Purpose of rules file: + +This file re-assigns CD-ROM type devices to the "cdrom" group. + + +Description of rules: + +There is only one rule here. It depends on the 60-persistent-storage file, +though, because it requires the ID_TYPE environment variable to be set properly +for CD devices. Normally the rules in the 60-persistent-storage.rules file +will run the correct *_id programs to do this properly. + +If ID_TYPE is "cd", and this is a block device, and it's an add event, then we +assign the device to the "cdrom" group. Simple, once the *_id programs have +all been run. + diff --git a/udev-config/doc/80-drivers.txt b/udev-config/doc/80-drivers.txt new file mode 100644 index 000000000..e5cfcefb3 --- /dev/null +++ b/udev-config/doc/80-drivers.txt @@ -0,0 +1,69 @@ +Purpose of rules file: + +The rules in this file allow Udev to fully replace the old /sbin/hotplug +script. 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 are +being added. + +ENV{MODALIAS} is the value of the environment variable named MODALIAS. This +environment variable is sent by the kernel when it sends a uevent for any +device that has a modalias. Modaliases are strings that can be used to load +the appropriate kernel module driver. + +Generally a modalias will contain information like vendor ID, device ID, and +possibly other IDs depending on the bus the device is connected to. (USB, for +instance, has the concept of a "device class" and a "device interface", which +are basically just ways to standardize the USB protocol for various types of +devices. This is what allows a single kernel module such as hid.ko to drive +many different vendors' USB input devices: all devices that support the USB +HID interface expose the HID interface number in their modalias, and so the +hid.ko driver can be loaded for each device. When it loads, hid.ko attaches +to the HID interface and does whatever is needed to work with each device.) + +Kernel modules that drive hardware expose a list of modaliases. These +modaliases are matched against the device modalias by /sbin/modprobe (after +shell-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. It +does this by comparing it to "?*" -- inside a match, "*" would match *any* +string, including the empty string, so to ensure MODALIAS is not empty, we need +to match against "?*" instead. ("?" matches any one character.) + +The Udev RUN+="" option adds a program to run when the rule matches. In this +case, we tell Udev to run "/sbin/modprobe $env{MODALIAS}". Note that Udev does +not do path searches; if the executable is not specified with a fully-qualified +path, 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}" is +replaced by the value of the environment variable "string" when the command +runs, so this adds the modalias to the modprobe command. The modprobe program +will 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. (The +modprobe command will fail when run during cold-plugging, if the driver was +configured into the kernel instead of as a module, for instance.) + +There is still one feature of the old hotplug shell-script system that Udev +cannot provide: blacklisting modules from being auto-loaded. To accomplish +this, we must use module-init-tools. In /etc/modprobe.conf, if you use the +"blacklist <module-name>" syntax, modprobe will not load <module-name> under +any name except its real module name. Any modaliases exposed by that module +will 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 through +each ID and tries to load the appropriate module. Several other types of +devices require an extra module before they will work properly; one example +of this is IDE tapes, which require the ide-scsi module. Finally, whenever +any 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 SCSI +generic driver -- is loaded. (That driver creates the module/sg directory, +so the module/sg test is just to see whether the driver has already been +loaded.) + diff --git a/udev-config/doc/95-udev-late.txt b/udev-config/doc/95-udev-late.txt new file mode 100644 index 000000000..00ea17c61 --- /dev/null +++ b/udev-config/doc/95-udev-late.txt @@ -0,0 +1,18 @@ +Purpose of rules file: + +Sends all uevents to a Unix-domain socket, where they can be monitored by other +programs. + + +Description of rules: + +There is only one rule, which matches all uevents. It uses Udev's RUN key to +specify a socket to send each uevent to. Normally RUN is used to start up a +process, but if the pathname starts with "socket:", Udev instead interprets +the rest of the name as a Unix-domain socket to send the uevent to. In this +case, we send send the uevent to the socket named /org/kernel/udev/monitor, +which is created by the udevmonitor program. Udevmonitor is used to watch +uevents as they come to Udev. Its only purpose is for debugging, but sending +the uevent to a socket that doesn't exist is a very cheap operation, so we +enable this rule for all uevents. + diff --git a/udev-config/doc/README b/udev-config/doc/README new file mode 100644 index 000000000..01216694c --- /dev/null +++ b/udev-config/doc/README @@ -0,0 +1,6 @@ +This directory contains documentation for each rule file used in LFS. + +Each .rules file should contain a corresponding .txt file in this directory, +which explains both the overall purpose of the rules file, and each type of +rule contained therein. + |