summaryrefslogtreecommitdiff
path: root/source/a/udev/config
diff options
context:
space:
mode:
Diffstat (limited to 'source/a/udev/config')
-rw-r--r--source/a/udev/config/rc.d/rc.udev.new100
-rw-r--r--source/a/udev/config/rules.d/59-non-libata-devices.rules44
-rw-r--r--source/a/udev/config/rules.d/65-permissions.rules11
3 files changed, 112 insertions, 43 deletions
diff --git a/source/a/udev/config/rc.d/rc.udev.new b/source/a/udev/config/rc.d/rc.udev.new
index 8c238b0d..40f38d1d 100644
--- a/source/a/udev/config/rc.d/rc.udev.new
+++ b/source/a/udev/config/rc.d/rc.udev.new
@@ -11,6 +11,18 @@ OPT=""
# remove trailing slash from udev_root
UDEV_ROOT=$(echo "${udev_root}" |sed 's/\/*$//')
+check_mounted() {
+ grep -E -q "^[^[:space:]]+ $1 $2" /proc/mounts
+ return $?
+}
+
+mount_devpts() {
+ if ! check_mounted $UDEV_ROOT/pts devpts ; then
+ mkdir $UDEV_ROOT/pts 2> /dev/null
+ mount -n -o mode=0620,gid=5 -t devpts devpts $UDEV_ROOT/pts
+ fi
+}
+
case "$1" in
start)
# Sanity check #1, udev requires that the kernel support tmpfs:
@@ -23,8 +35,8 @@ case "$1" in
# Sanity check #2, make sure that a 2.6.x kernel is new enough:
if [ "$(uname -r | cut -f 1,2 -d .)" = "2.6" ]; then
- if [ "$(uname -r | cut -f 3 -d . | sed 's/[^[:digit:]].*//')" -lt "15" ]; then
- echo "Sorry, but you need a 2.6.15+ kernel to use udev."
+ if [ "$(uname -r | cut -f 3 -d . | sed 's/[^[:digit:]].*//')" -lt "27" ]; then
+ echo "Sorry, but you need a 2.6.27+ kernel to use udev."
echo "Your kernel version is only $(uname -r)."
echo
echo "FATAL: Refusing to run /etc/rc.d/rc.udev."
@@ -48,45 +60,59 @@ case "$1" in
echo "" > /proc/sys/kernel/hotplug
fi
- # if udevd is already running, rc.udev start will try to re-run
- # failed events. Else, it will start udevd.
- if ps axc | grep -q udevd ; then
- OPT="--type=failed $OPT"
- ( cd ${UDEV_ROOT}/.udev
- for TMPFILE in tmp-rules-*.rules ; do
- mv $TMPFILE /etc/udev/rules.d/${TMPFILE/tmp-rules--/} 2>/dev/null
- done
- )
- else
- # Mount tmpfs on $UDEV_ROOT:
- if ! grep -E -q "^[^[:space:]]+ $UDEV_ROOT tmpfs" /proc/mounts; then
+ if grep -qw devtmpfs /proc/filesystems ; then
+ if ! check_mounted $UDEV_ROOT devtmpfs ; then
# umount shm if needed
- if grep -E -q "^[^[:space:]]+ $UDEV_ROOT/shm tmpfs" /proc/mounts; then
- umount -l $UDEV_ROOT/shm
- fi
+ check_mounted $UDEV_ROOT/shm tmpfs && umount -l $UDEV_ROOT/shm
# Umount pts if needed, we will remount it later:
- if grep -E -q "^[^[:space:]]+ $UDEV_ROOT/pts devpts" /proc/mounts; then
- umount -l $UDEV_ROOT/pts
+ check_mounted $UDEV_ROOT/pts devpts && umount -l $UDEV_ROOT/pts
+
+ # Mount tmpfs on $UDEV_ROOT:
+ mount -n -t devtmpfs devtmpfs $UDEV_ROOT
+ fi
+ else
+ # Mount tmpfs on $UDEV_ROOT:
+ if ! check_mounted $UDEV_ROOT tmpfs ; then
+ # umount shm if needed
+ check_mounted $UDEV_ROOT/shm tmpfs && umount -l $UDEV_ROOT/shm
+
+ # Umount pts if needed, we will remount it later:
+ check_mounted $UDEV_ROOT/pts devpts && umount -l $UDEV_ROOT/pts
+
+ # Mount tmpfs on $UDEV_ROOT:
+ # the -n is because we don't want $UDEV_ROOT umounted when
+ # someone (rc.[06]) calls umount -a
+ mount -n -o mode=0755 -t tmpfs tmpfs $UDEV_ROOT
+
fi
+ fi
+ # Mount devpts
+ mount_devpts
- # Mount tmpfs on $UDEV_ROOT:
- # the -n is because we don't want $UDEV_ROOT umounted when
- # someone (rc.[06]) calls umount -a
- mount -n -o mode=0755 -t tmpfs tmpfs $UDEV_ROOT
+ # Start udevd.
+ /sbin/udevd --daemon 2>/dev/null
- # Remount pts:
- mkdir $UDEV_ROOT/pts 2> /dev/null
- mount -n -o mode=0620,gid=5 -t devpts devpts $UDEV_ROOT/pts
- fi
+ # If udevd was already running, then it will return !=0 exit code,
+ # so we'll try to re-run failed events
+ if [ $? != 0 ]; then
+ OPT="--type=failed $OPT"
+ ( cd ${UDEV_ROOT}/.udev
+ for TMPFILE in tmp-rules-*.rules ; do
+ mv $TMPFILE /etc/udev/rules.d/${TMPFILE/tmp-rules--/} 2>/dev/null
+ done
+ )
+ else # udev is just now being started, so we'll do some initial setup:
- # Add the static nodes to $UDEV_ROOT:
- cp --preserve=all --recursive --remove-destination /lib/udev/devices/* $UDEV_ROOT
+ # Set STARTUP=1 in the environment
+ /sbin/udevadm control --property=STARTUP=1
- # Start udevd:
- echo "Starting udevd: /sbin/udevd --daemon"
- /sbin/udevd --daemon
+ # Set OPT="--action=add" to generate add events on coldplug
+ OPT="--action=add"
+ # Add the static nodes to $UDEV_ROOT:
+ cp --preserve=all --recursive --remove-destination /lib/udev/devices/* $UDEV_ROOT
+
# Create rootdev rules
DEVICENUMBER=$( /bin/stat -c %d / )
MAJORNUMBER=$(($DEVICENUMBER / 256))
@@ -99,9 +125,15 @@ case "$1" in
echo "Triggering udev events: /sbin/udevadm trigger $OPT"
# Call udevtrigger and udevsettle to do the device configuration:
/sbin/udevadm trigger $OPT && /sbin/udevadm settle --timeout=120
+ # Unset STARTUP=1 in the environment
+ /sbin/udevadm control --property=STARTUP=
;;
stop)
+ echo "Stopping udevd is STRONGLY discouraged and not supported."
+ echo "If you are sure you want to do this, use 'force-stop' instead."
+ ;;
+ force-stop)
echo "Stopping udevd"
if [ -e /proc/sys/kernel/hotplug ]; then
echo /sbin/hotplug > /proc/sys/kernel/hotplug
@@ -109,6 +141,10 @@ case "$1" in
killall udevd
;;
restart)
+ echo "Restarting udevd is STRONGLY discouraged and not supported."
+ echo "If you are sure you want to do this, use 'force-restart' instead."
+ ;;
+ force-restart)
echo "Restarting udevd"
killall udevd
sleep 5
diff --git a/source/a/udev/config/rules.d/59-non-libata-devices.rules b/source/a/udev/config/rules.d/59-non-libata-devices.rules
new file mode 100644
index 00000000..4b1238a4
--- /dev/null
+++ b/source/a/udev/config/rules.d/59-non-libata-devices.rules
@@ -0,0 +1,44 @@
+# Support for the deprecated IDE devices has been removed from the
+# default set of rules shipped with udev, but some administrators
+# might want (or need) the old ata drivers and thus build a custom
+# kernel, so we'll carry these on our own for now...
+
+#############################################################################
+
+# Old 50-udev-default.rules
+
+# floppy
+KERNEL=="hd*", SUBSYSTEMS=="ide", ATTRS{media}=="floppy"
+
+# cdrom
+SUBSYSTEM=="block", KERNEL=="hd*", SUBSYSTEMS=="ide", ATTRS{media}=="cdrom", GROUP="cdrom"
+
+#############################################################################
+
+# Old 60-persistent-storage.rules
+
+# never access non-cdrom removable ide devices, the drivers are causing event loops on open()
+KERNEL=="hd*[!0-9]", ATTR{removable}=="1", SUBSYSTEMS=="ide", ATTRS{media}=="disk|floppy", GOTO="old_persistent_storage_end"
+KERNEL=="hd*[0-9]", ATTRS{removable}=="1", GOTO="old_persistent_storage_end"
+
+# 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_SERIAL}"
+KERNEL=="hd*[0-9]", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/ata-$env{ID_SERIAL}-part%n"
+
+LABEL="old_persistent_storage_end"
+
+#############################################################################
+
+# Old ide stuff from our custom 65-permissions.rules
+
+# permissions for IDE floppy devices
+KERNEL=="hd*[!0-9]", SUBSYSTEMS=="ide", ATTRS{media}=="floppy", SYMLINK+="floppy floppy-%k"
+KERNEL=="hd*[0-9]", ATTRS{media}=="floppy", ATTRS{removable}=="1", SYMLINK+="floppy-%k"
+
+# put all removable devices in group "plugdev"
+KERNEL=="hd*[!0-9]", ATTR{removable}=="1", GROUP="plugdev"
+KERNEL=="hd*[0-9]", ATTRS{removable}=="1", GROUP="plugdev"
+
+#############################################################################
+
diff --git a/source/a/udev/config/rules.d/65-permissions.rules b/source/a/udev/config/rules.d/65-permissions.rules
index b0cfb259..6f82b0f3 100644
--- a/source/a/udev/config/rules.d/65-permissions.rules
+++ b/source/a/udev/config/rules.d/65-permissions.rules
@@ -12,15 +12,7 @@
# all disks with group disk
KERNEL!="fd*", SUBSYSTEM=="block", GROUP="disk"
-# permissions for IDE floppy devices
-KERNEL=="hd*[!0-9]", SUBSYSTEMS=="ide", ATTRS{media}=="floppy", \
- SYMLINK+="floppy floppy-%k", OPTIONS+="ignore_remove"
-KERNEL=="hd*[0-9]", ATTRS{media}=="floppy", ATTRS{removable}=="1", \
- SYMLINK+="floppy-%k", OPTIONS+="ignore_remove"
-
# put all removable devices in group "plugdev"
-KERNEL=="hd*[!0-9]", ATTR{removable}=="1", GROUP="plugdev"
-KERNEL=="hd*[0-9]", ATTRS{removable}=="1", GROUP="plugdev"
KERNEL=="sd*[!0-9]", ATTR{removable}=="1", GROUP="plugdev"
KERNEL=="sd*[0-9]", ATTRS{removable}=="1", GROUP="plugdev"
@@ -44,9 +36,6 @@ SUBSYSTEMS=="scsi", KERNEL=="s[gt][0-9]*", ATTRS{type}=="5", \
# Make DRI video devices usable by anyone in group "video":
KERNEL=="card[0-9]*",GROUP:="video"
-# alsa devices
-SUBSYSTEM=="sound", GROUP="audio"
-
# Make the real time clock readable by all, and writable by root:
KERNEL=="rtc|rtc0", MODE="0644"