Author: dnicholson
Date: 2006-07-12 07:25:33 -0600 (Wed, 12 Jul 2006)
New Revision: 7657

Added:
   trunk/udev-config/contrib/
   trunk/udev-config/contrib/debian/
   trunk/udev-config/contrib/debian/81-cdrom.rules
   trunk/udev-config/contrib/debian/83-cdrom-symlinks.rules
   trunk/udev-config/contrib/debian/write_cd_aliases
Removed:
   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
Modified:
   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/CHANGELOG
Log:
Checked in Alexander's changes from udev-config-20060607-try2.tar.bz2 (see 
CHANGELOG).
Fixed some inconsistent whitespace and expanded all tabs to spaces.


Modified: trunk/udev-config/05-udev-early.rules
===================================================================
--- trunk/udev-config/05-udev-early.rules       2006-07-12 00:32:00 UTC (rev 
7656)
+++ trunk/udev-config/05-udev-early.rules       2006-07-12 13:25:33 UTC (rev 
7657)
@@ -1,19 +1,3 @@
-# The files, directories, and symlinks in /sys do not all appear at once. They
-# appear as the kernel identifies and enumerates them. However, the uevent for
-# any given device might sometimes be generated before this is finished. To
-# avoid race conditions, this rule matches those devices (which have an ACTION
-# of add, DEVPATH of /devices/*, and a non-empty environment variable named
-# PHYSDEVBUS) and causes Udev to wait until the kernel has created the needed
-# "bus" file (in this case it will be a symlink) for that particular device
-# before it attempts to match any other rule. This gives the kernel time to
-# enumerate the various devices and export them via sysfs.
-
+# sysfs is populated after the event is sent
 ACTION=="add", DEVPATH=="/devices/*", ENV{PHYSDEVBUS}=="?*", 
WAIT_FOR_SYSFS="bus"
-
-# Very similar to the previous rule, any uevent for devices handled by the
-# kernel's SCSI subsystem where the ACTION to take is "add" the device, Udev
-# will wait for the existence of the file /sys/bus/scsi/devices/<device
-# number>/ioerr_cnt (ioerr_cnt is known to be the last sysfs attribute created
-# for SCSI devices).
-
 ACTION=="add", SUBSYSTEM=="scsi", WAIT_FOR_SYSFS="ioerr_cnt"

Modified: trunk/udev-config/25-lfs.rules
===================================================================
--- trunk/udev-config/25-lfs.rules      2006-07-12 00:32:00 UTC (rev 7656)
+++ trunk/udev-config/25-lfs.rules      2006-07-12 13:25:33 UTC (rev 7657)
@@ -1,147 +1,135 @@
-# In the following example, each comma-separated section will be explained.
-# 
-# KERNEL=="mice", MODE="0644", GROUP="some group", NAME="input/%k", 
SYMLINK="mouse"
-# 
-# In the first section, a uevent generated by the kernel with the name "mice"
-# will cause a device node named "mice" to be created in the default location 
of
-# /dev with a default ownership of root:root and default permissions of 0660. 
In
-# the next 2 sections we change the default permissions and group ownership
-# depending on needs. In the 4th section, we change where the device node will
-# be created (in this example we want /dev/input/mice instead of /dev/mice). 
The
-# last section says to create a symlink in /dev/mouse.
-# 
-# Keep in mind that /dev is the default location for nodes and symlinks. If you
-# want a node or symlink in a subdirectory, you have to specify it (for 
example:
-# SYMLINK="input/mouse" would create a /dev/input/mouse symlink)
-# 
-# If for some reason you do not want a device node created for hardware that is
-# present, give it a blank NAME. An example would be DRI devices. X Windows 
will
-# handle those itself.
-# 
-# A final word of caution: Any particular rule must be written on one line and 
a
-# comma must separate each section of the rule. You can have either spaces or
-# tabs between each section.
+# /etc/udev/rules.d/25-lfs.rules: Rule definitions for LFS.
 
 # Core kernel devices
 
-KERNEL=="mem",          MODE="640", GROUP="kmem"
-KERNEL=="kmem",         MODE="640", GROUP="kmem"
-KERNEL=="null",         MODE="666"
-KERNEL=="port",         MODE="640", GROUP="kmem"
-KERNEL=="zero",         MODE="666"
-KERNEL=="full",         MODE="666"
-KERNEL=="random",       MODE="664"
-KERNEL=="urandom",      MODE="664"
-KERNEL=="rtc",          MODE="664"
+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"
 
-# TTY devices (both communications and terminal types)
+# Comms devices
 
-SUBSYSTEM=="tty",                   GROUP="dialout"
-KERNEL=="ptmx",         MODE="666", GROUP="tty"
-KERNEL=="pty[p-za-e]*", MODE="666", GROUP="tty"
-KERNEL=="tty[p-za-e]*",             GROUP="tty"
-KERNEL=="capi",                                     NAME="capi20", 
SYMLINK+="isdn/capi20"
-KERNEL=="capi?*",                                   NAME="capi/%n"
-KERNEL=="tty",          MODE="620", GROUP="tty"
-KERNEL=="tty[0-9]*",    MODE="620"  GROUP="tty"
-KERNEL=="vcs",                      GROUP="tty"
-KERNEL=="console",      MODE="600"  GROUP="tty"
+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"
 
-# End of edits 20060615 (archaic)
+# 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"
+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"
+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"
+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=="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"
+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"
+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=""
+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"
+KERNEL=="fb[0-9]*",     MODE="0620",    GROUP="video"
+KERNEL=="agpgart",      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"
+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=="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"
+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"
+KERNEL=="tun",  NAME="net/%k"

Modified: trunk/udev-config/26-modprobe.rules
===================================================================
--- trunk/udev-config/26-modprobe.rules 2006-07-12 00:32:00 UTC (rev 7656)
+++ trunk/udev-config/26-modprobe.rules 2006-07-12 13:25:33 UTC (rev 7657)
@@ -1,3 +1,5 @@
+# /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}"
@@ -10,7 +12,7 @@
 # st/osst           1 (TYPE_TAPE)
 # sr                4 (TYPE_WORM), 5 (TYPE_ROM)
 
-SUBSYSTEM=="scsi_device", ACTION=="add",                        
RUN+="/sbin/modprobe sg"
 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"

Modified: trunk/udev-config/27-firmware.rules
===================================================================
--- trunk/udev-config/27-firmware.rules 2006-07-12 00:32:00 UTC (rev 7656)
+++ trunk/udev-config/27-firmware.rules 2006-07-12 13:25:33 UTC (rev 7657)
@@ -1,3 +1,3 @@
-# This rule simply calls the firmware_helper program to load firmware
+# /etc/udev/rules.d/27-firmware.rules: Load firmware for devices that need it
 
-ACTION=="add", SUBSYSTEM=="firmware", RUN+="/lib/udev/firmware_helper"
+ACTION=="add", SUBSYSTEM=="firmware", RUN+="firmware.sh"

Deleted: trunk/udev-config/81-cdrom.rules
===================================================================
--- trunk/udev-config/81-cdrom.rules    2006-07-12 00:32:00 UTC (rev 7656)
+++ trunk/udev-config/81-cdrom.rules    2006-07-12 13:25:33 UTC (rev 7657)
@@ -1,3 +0,0 @@
-# /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"

Deleted: trunk/udev-config/83-cdrom-symlinks.rules
===================================================================
--- trunk/udev-config/83-cdrom-symlinks.rules   2006-07-12 00:32:00 UTC (rev 
7656)
+++ trunk/udev-config/83-cdrom-symlinks.rules   2006-07-12 13:25:33 UTC (rev 
7657)
@@ -1,12 +0,0 @@
-# /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"

Deleted: trunk/udev-config/90-bug.rules
===================================================================
--- trunk/udev-config/90-bug.rules      2006-07-12 00:32:00 UTC (rev 7656)
+++ trunk/udev-config/90-bug.rules      2006-07-12 13:25:33 UTC (rev 7657)
@@ -1 +0,0 @@
-ACTION=="add", RUN+="bug"

Modified: trunk/udev-config/CHANGELOG
===================================================================
--- trunk/udev-config/CHANGELOG 2006-07-12 00:32:00 UTC (rev 7656)
+++ trunk/udev-config/CHANGELOG 2006-07-12 13:25:33 UTC (rev 7657)
@@ -1,3 +1,9 @@
+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

Copied: trunk/udev-config/contrib/debian/81-cdrom.rules (from rev 7656, 
trunk/udev-config/81-cdrom.rules)
===================================================================
--- trunk/udev-config/contrib/debian/81-cdrom.rules                             
(rev 0)
+++ trunk/udev-config/contrib/debian/81-cdrom.rules     2006-07-12 13:25:33 UTC 
(rev 7657)
@@ -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"

Copied: trunk/udev-config/contrib/debian/83-cdrom-symlinks.rules (from rev 
7656, trunk/udev-config/83-cdrom-symlinks.rules)
===================================================================
--- trunk/udev-config/contrib/debian/83-cdrom-symlinks.rules                    
        (rev 0)
+++ trunk/udev-config/contrib/debian/83-cdrom-symlinks.rules    2006-07-12 
13:25:33 UTC (rev 7657)
@@ -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"

Copied: trunk/udev-config/contrib/debian/write_cd_aliases (from rev 7656, 
trunk/udev-config/write_cd_aliases)
===================================================================
--- trunk/udev-config/contrib/debian/write_cd_aliases                           
(rev 0)
+++ trunk/udev-config/contrib/debian/write_cd_aliases   2006-07-12 13:25:33 UTC 
(rev 7657)
@@ -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
+

Deleted: trunk/udev-config/write_cd_aliases
===================================================================
--- trunk/udev-config/write_cd_aliases  2006-07-12 00:32:00 UTC (rev 7656)
+++ trunk/udev-config/write_cd_aliases  2006-07-12 13:25:33 UTC (rev 7657)
@@ -1,111 +0,0 @@
-#!/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
-

-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-book
FAQ: http://www.linuxfromscratch.org/lfs/faq.html
Unsubscribe: See the above information page

Reply via email to