r7600 - in trunk: . udev-config

archaic at linuxfromscratch.org archaic at linuxfromscratch.org
Fri May 12 16:03:14 PDT 2006


Author: archaic
Date: 2006-05-12 17:03:13 -0600 (Fri, 12 May 2006)
New Revision: 7600

Added:
   trunk/udev-config/
   trunk/udev-config/05-udev-early.rules
   trunk/udev-config/25-lfs.rules
   trunk/udev-config/26-modprobe.rules
   trunk/udev-config/27-firmware.rules
   trunk/udev-config/60-persistent-storage.rules
   trunk/udev-config/81-cdrom.rules
   trunk/udev-config/83-cdrom-symlinks.rules
   trunk/udev-config/90-bug.rules
   trunk/udev-config/write_cd_aliases
Log:
Initial import of the udev-config directory.

Added: trunk/udev-config/05-udev-early.rules
===================================================================
--- trunk/udev-config/05-udev-early.rules	                        (rev 0)
+++ trunk/udev-config/05-udev-early.rules	2006-05-12 23:03:13 UTC (rev 7600)
@@ -0,0 +1,4 @@
+# sysfs is populated after the event is sent
+ACTION=="add", DEVPATH=="/devices/*", ENV{PHYSDEVBUS}=="?*", WAIT_FOR_SYSFS="bus"
+ACTION=="add", SUBSYSTEM=="scsi", WAIT_FOR_SYSFS="ioerr_cnt"
+

Added: trunk/udev-config/25-lfs.rules
===================================================================
--- trunk/udev-config/25-lfs.rules	                        (rev 0)
+++ trunk/udev-config/25-lfs.rules	2006-05-12 23:03:13 UTC (rev 7600)
@@ -0,0 +1,137 @@
+# /etc/udev/rules.d/25-lfs.rules: Rule definitions for LFS.
+
+# Core kernel devices
+
+KERNEL=="ptmx",		MODE="0666",	GROUP="tty"
+KERNEL=="random",	MODE="0444"
+KERNEL=="urandom",	MODE="0444"
+KERNEL=="kmem",		MODE="0640",	GROUP="kmem"
+KERNEL=="mem",		MODE="0640",	GROUP="kmem"
+KERNEL=="port",		MODE="0640",	GROUP="kmem"
+KERNEL=="null",		MODE="0666"
+KERNEL=="zero",		MODE="0666"
+KERNEL=="full",		MODE="0666"
+KERNEL=="aio",		MODE="0444"
+KERNEL=="kmsg",		MODE="0600"
+KERNEL=="rtc",		MODE="0666"
+
+# Comms devices
+
+KERNEL=="ttyS[0-9]*",                   GROUP="dialout"
+KERNEL=="ttyUSB[0-9]*",                 GROUP="dialout"
+KERNEL=="rfcomm[0-9]*",                 GROUP="dialout"
+KERNEL=="tty[BCDEFHILMPRSTUVWX][0-9]*", GROUP="dialout"
+KERNEL=="ttyS[ACIR][0-9]*",             GROUP="dialout"
+KERNEL=="ttyUSB[0-9]*",                 GROUP="dialout"
+KERNEL=="ttyACM[0-9]*",                 GROUP="dialout"
+KERNEL=="ippp[0-9]*",                   GROUP="dialout"
+KERNEL=="isdn[0-9]*",                   GROUP="dialout"
+KERNEL=="isdnctrl[0-9]*",               GROUP="dialout"
+KERNEL=="capi",						NAME="capi20",	SYMLINK="isdn/capi20"
+KERNEL=="capi?*",					NAME="capi/%n",	GROUP="dialout"
+KERNEL=="dcbri[0-9]*",                  GROUP="dialout"
+KERNEL=="ircomm[0-9]*",                 GROUP="dialout"
+
+# TTY's
+
+KERNEL=="tty",		MODE="0666",	GROUP="tty"
+KERNEL=="tty[0-9]*",	MODE="0666"	GROUP="tty"
+KERNEL=="vcs*",		MODE="0600"
+KERNEL=="console",	MODE="0622"	GROUP="tty"
+
+# ALSA devices go in their own subdirectory
+
+KERNEL=="controlC[0-9]*",		GROUP="audio",	NAME="snd/%k"
+KERNEL=="hw[CD0-9]*",			GROUP="audio",	NAME="snd/%k"
+KERNEL=="pcm[CD0-9cp]*",		GROUP="audio",	NAME="snd/%k"
+KERNEL=="midiC[D0-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"
+
+# Printing devices
+
+KERNEL=="lp[0-9]*",			GROUP="lp"
+KERNEL=="parport[0-9]*",		GROUP="lp"
+KERNEL=="irlpt[0-9]*",			GROUP="lp"
+
+# Input devices go in their own subdirectory
+
+KERNEL=="mice",		MODE="0644",			NAME="input/%k"	SYMLINK="mouse"
+KERNEL=="mouse*",	MODE="0644",			NAME="input/%k"
+KERNEL=="event*",	MODE="0644",			NAME="input/%k"
+KERNEL=="js*",		MODE="0644",			NAME="input/%k"
+KERNEL=="ts*",		MODE="0644",			NAME="input/%k"
+
+KERNEL=="psaux",	MODE="0644"
+KERNEL=="js",		MODE="0644"
+KERNEL=="djs",		MODE="0644"
+
+# USB devices go in their own subdirectory
+
+SUBSYSTEM=="usb_device", PROGRAM="/bin/sh -c 'X=%k X=$${X#usbdev} B=$${X%%%%.*} D=$${X#*.}; echo bus/usb/$$B/$$D'", NAME="%c"
+KERNEL=="hiddev*",					NAME="usb/%k"
+KERNEL=="auer*",					NAME="usb/%k"
+KERNEL=="legousbtower*",				NAME="usb/%k"
+KERNEL=="dabusb*",					NAME="usb/%k"
+BUS=="usb", KERNEL=="lp[0-9]*",		GROUP="lp"	NAME="usb/%k"
+
+# DRI devices are managed by the X server, so prevent udev from creating them
+
+KERNEL=="card*",					NAME=""
+
+# Video devices
+
+KERNEL=="fb[0-9]*",	MODE="0620",	GROUP="video"
+KERNEL=="agpgart",			GROUP="video"
+KERNEL=="nvidia[0-9]*",			GROUP="video"
+KERNEL=="nvidiactl",			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"
+
+# Storage/memory devices
+
+KERNEL=="fd[0-9]*",			GROUP="floppy"
+KERNEL=="ram[0-9]*",			GROUP="disk"
+KERNEL=="raw[0-9]*",			GROUP="disk",	NAME="raw/%k"
+KERNEL=="hd*",				GROUP="disk"
+KERNEL=="sd[a-z]",			GROUP="disk"
+KERNEL=="sd[a-z][0-9]*",		GROUP="disk"
+KERNEL=="sd[a-i][a-z]",			GROUP="disk"
+KERNEL=="sd[a-i][a-z][0-9]*",		GROUP="disk"
+KERNEL=="dasd[0-9]*",			GROUP="disk"
+KERNEL=="loop[0-9]*",			GROUP="disk"
+KERNEL=="md[0-9]*",			GROUP="disk"
+
+# dmsetup and lvm2 related programs create devicemapper devices so we prevent
+# udev from creating them
+
+KERNEL=="dm-*",						NAME=""
+
+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"
+
+# Network devices
+
+KERNEL=="tun",						NAME="net/%k"

Added: trunk/udev-config/26-modprobe.rules
===================================================================
--- trunk/udev-config/26-modprobe.rules	                        (rev 0)
+++ trunk/udev-config/26-modprobe.rules	2006-05-12 23:03:13 UTC (rev 7600)
@@ -0,0 +1,18 @@
+# /etc/udev/rules.d/26-modprobe.rules: Rules that require modprobe.
+
+# Generic rule to allow loading modular drivers for existing hardware
+
+ACTION=="add", ENV{MODALIAS}=="?*", RUN+="/sbin/modprobe $env{MODALIAS}"
+
+# SCSI devices require different modules, dependent on their SYSFS{type}.  All
+# of them require 'sg' though.
+#
+# module name       sysfs types
+# sd                0 (TYPE_DISK), 7 (TYPE_MOD), 14 (TYPE_MOD)
+# st/osst           1 (TYPE_TAPE)
+# sr                4 (TYPE_WORM), 5 (TYPE_ROM)
+
+SUBSYSTEM=="scsi_device", ACTION=="add", SYSFS{type}=="0|7|14", RUN+="/sbin/modprobe sd_mod"
+SUBSYSTEM=="scsi_device", ACTION=="add", SYSFS{type}=="1",      RUN+="/sbin/modprobe st"
+SUBSYSTEM=="scsi_device", ACTION=="add", SYSFS{type}=="[45]",   RUN+="/sbin/modprobe sr_mod"
+SUBSYSTEM=="scsi_device", ACTION=="add",                        RUN+="/sbin/modprobe sg"

Added: trunk/udev-config/27-firmware.rules
===================================================================
--- trunk/udev-config/27-firmware.rules	                        (rev 0)
+++ trunk/udev-config/27-firmware.rules	2006-05-12 23:03:13 UTC (rev 7600)
@@ -0,0 +1,3 @@
+# /etc/udev/rules.d/27-firmware.rules: Load firmware for devices that need it
+
+ACTION=="add", SUBSYSTEM=="firmware", RUN+="/lib/udev/firmware_helper"

Added: trunk/udev-config/60-persistent-storage.rules
===================================================================
--- trunk/udev-config/60-persistent-storage.rules	                        (rev 0)
+++ trunk/udev-config/60-persistent-storage.rules	2006-05-12 23:03:13 UTC (rev 7600)
@@ -0,0 +1,49 @@
+# persistent storage links: /dev/{disk,tape}/{by-id,by-uuid,by-label,by-path,by-name}
+# scheme based on "Linux persistent device names", 2004, Hannes Reinecke <hare at suse.de>
+
+ACTION!="add", GOTO="persistent_storage_end"
+SUBSYSTEM!="block", GOTO="persistent_storage_end"
+
+# skip rules for inappropriate block devices
+KERNEL=="ram*|loop*|fd*|nbd*", GOTO="persistent_storage_end"
+
+# never access removable ide devices, the drivers are causing event loops on open()
+KERNEL=="hd*[!0-9]", SYSFS{removable}=="1", DRIVER=="ide-cs|ide-floppy", GOTO="persistent_storage_end"
+KERNEL=="hd*[0-9]", SYSFS{../removable}=="1", GOTO="persistent_storage_end"
+
+# for partitions import parent information
+KERNEL=="*[0-9]", IMPORT{parent}=="ID_*"
+
+# by-id (hardware serial number)
+KERNEL=="hd*[!0-9]", IMPORT{program}="ata_id --export $tempnode"
+KERNEL=="hd*[!0-9]", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/ata-$env{ID_MODEL}_$env{ID_SERIAL}"
+KERNEL=="hd*[0-9]", IMPORT{parent}=="ID_*", SYMLINK+="disk/by-id/ata-$env{ID_MODEL}_$env{ID_SERIAL}-part%n"
+
+KERNEL=="sd*[!0-9]|sr*|st*", SYSFS{ieee1394_id}=="*", ENV{ID_SERIAL}="$sysfs{ieee1394_id}", ENV{ID_BUS}="ieee1394"
+KERNEL=="sd*[!0-9]|sr*|st*", ENV{ID_SERIAL}=="", IMPORT{program}="usb_id -x"
+KERNEL=="sd*[!0-9]|sr*|st*", ENV{ID_SERIAL}=="", IMPORT{program}="scsi_id -g -x -s %p -d $tempnode"
+KERNEL=="sd*[!0-9]|sr*|st*", ENV{ID_SERIAL}=="", IMPORT{program}="scsi_id -g -x -a -s %p -d $tempnode"
+KERNEL=="dasd*[!0-9]", IMPORT{program}="dasd_id --export $tempnode"
+KERNEL=="sd*[!0-9]|sr*|dasd*[!0-9]", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}"
+KERNEL=="sd*[0-9]|dasd*[0-9]", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}-part%n"
+KERNEL=="st*", ENV{ID_SERIAL}=="?*", SYMLINK+="tape/by-id/$env{ID_BUS}-$env{ID_SERIAL}"
+
+# by-path (shortest physical path)
+KERNEL=="*[!0-9]|sr*", IMPORT{program}="path_id %p", SYMLINK+="disk/by-path/$env{ID_PATH}"
+KERNEL=="st*", IMPORT{program}="path_id %p", SYMLINK+="tape/by-path/$env{ID_PATH}"
+KERNEL=="sr*|st*", GOTO="persistent_storage_end"
+KERNEL=="*[0-9]", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}-part%n"
+
+# by-label/by-uuid (filesystem properties)
+KERNEL=="*[!0-9]", SYSFS{removable}=="1", GOTO="persistent_storage_end"
+IMPORT{program}="vol_id --export $tempnode"
+ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_UUID}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID}"
+ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_SAFE}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_SAFE}"
+
+# BIOS Enhanced Disk Device
+KERNEL=="*[!0-9]", IMPORT{program}="edd_id --export $tempnode"
+KERNEL=="*[!0-9]", ENV{ID_EDD}=="?*", SYMLINK+="disk/by-id/edd-$env{ID_EDD}"
+KERNEL=="*[0-9]", ENV{ID_EDD}=="?*", SYMLINK+="disk/by-id/edd-$env{ID_EDD}-part%n"
+
+
+LABEL="persistent_storage_end"

Added: trunk/udev-config/81-cdrom.rules
===================================================================
--- trunk/udev-config/81-cdrom.rules	                        (rev 0)
+++ trunk/udev-config/81-cdrom.rules	2006-05-12 23:03:13 UTC (rev 7600)
@@ -0,0 +1,3 @@
+# /etc/udev/rules.d/81-cdrom.rules: Generate rules for newly-added CD drives.
+
+ACTION=="add", ENV{ID_TYPE}=="cd", IMPORT{program}="cdrom_id --export $tempnode", GROUP="cdrom"

Added: trunk/udev-config/83-cdrom-symlinks.rules
===================================================================
--- trunk/udev-config/83-cdrom-symlinks.rules	                        (rev 0)
+++ trunk/udev-config/83-cdrom-symlinks.rules	2006-05-12 23:03:13 UTC (rev 7600)
@@ -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"

Added: trunk/udev-config/90-bug.rules
===================================================================
--- trunk/udev-config/90-bug.rules	                        (rev 0)
+++ trunk/udev-config/90-bug.rules	2006-05-12 23:03:13 UTC (rev 7600)
@@ -0,0 +1 @@
+ACTION=="add", RUN+="bug"

Added: trunk/udev-config/write_cd_aliases
===================================================================
--- trunk/udev-config/write_cd_aliases	                        (rev 0)
+++ trunk/udev-config/write_cd_aliases	2006-05-12 23:03:13 UTC (rev 7600)
@@ -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\", $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
+




More information about the lfs-book mailing list