summaryrefslogtreecommitdiff
path: root/source/a/udev/config/rc.d/rc.udev.new
diff options
context:
space:
mode:
Diffstat (limited to 'source/a/udev/config/rc.d/rc.udev.new')
-rw-r--r--source/a/udev/config/rc.d/rc.udev.new92
1 files changed, 49 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 6a6218f6..2bbd9819 100644
--- a/source/a/udev/config/rc.d/rc.udev.new
+++ b/source/a/udev/config/rc.d/rc.udev.new
@@ -4,7 +4,6 @@
# appropriate kernel modules, and configures the devices.
PATH="/sbin:/bin"
-OPT=""
. /etc/udev/udev.conf
@@ -25,26 +24,38 @@ mount_devpts() {
case "$1" in
start)
- # Sanity check #1, udev requires that the kernel support tmpfs:
+ # Sanity check #1, udev requires that the kernel support devtmpfs:
+ if ! grep -wq devtmpfs /proc/filesystems ; then
+ echo "Sorry, but you need devtmpfs support in the kernel to use udev."
+ echo "Both of these options are needed: CONFIG_DEVTMPFS=y CONFIG_DEVTMPFS_MOUNT=y"
+ echo
+ echo "FATAL: Refusing to run /etc/rc.d/rc.udev."
+ sleep 10
+ exit 1
+ fi
+
+ # Sanity check #2, udev requires that the kernel support tmpfs:
if ! grep -wq tmpfs /proc/filesystems ; then
echo "Sorry, but you need tmpfs support in the kernel to use udev."
echo
echo "FATAL: Refusing to run /etc/rc.d/rc.udev."
+ sleep 10
exit 1
fi
- # Sanity check #2, make sure that a 2.6.x kernel is new enough:
+ # Sanity check #3, 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 "32" ]; then
echo "Sorry, but you need a 2.6.32+ kernel to use this udev."
echo "Your kernel version is only $(uname -r)."
echo
echo "FATAL: Refusing to run /etc/rc.d/rc.udev."
+ sleep 10
exit 1
fi
fi
- # Sanity check #3, make sure the udev package was not removed. If udevd
+ # Sanity check #4, make sure the udev package was not removed. If udevd
# is not there, this will also shut off this script to prevent further
# problems:
if [ ! -x /sbin/udevd ]; then
@@ -52,6 +63,7 @@ case "$1" in
echo "No udevd daemon found."
echo "Turning off udev: chmod 644 /etc/rc.d/rc.udev"
echo "FATAL: Refusing to run /etc/rc.d/rc.udev."
+ sleep 10
exit 1
fi
@@ -90,47 +102,41 @@ case "$1" in
# Mount devpts
mount_devpts
- # Start udevd.
- /sbin/udevd --daemon 2>/dev/null
-
- # 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:
-
- # Create rootdev rules
- DEVICENUMBER=$( /bin/stat -c %d / )
- MAJORNUMBER=$(($DEVICENUMBER / 256))
- MINORNUMBER=$(($DEVICENUMBER % 256))
-
- echo 'ACTION!="remove", SUBSYSTEM=="block", ENV{MAJOR}=="'$MAJORNUMBER'", ENV{MINOR}=="'$MINORNUMBER'", SYMLINK+="root"' > /dev/.udev/rules.d/61-dev-root-link.rules
-
- # Set OPT="--action=add" to generate add events on coldplug
- OPT="--action=add"
-
- fi
-
- 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
-
- ;;
+ if ! /sbin/pidof udevd 1>/dev/null 2>/dev/null; then # start udevd
+ echo "Starting udevd: /sbin/udevd --daemon"
+ /sbin/udevd --daemon
+ # Since udev is just now being started we want to use add events:
+ echo "Triggering udev events: /sbin/udevadm trigger --action=add"
+ # Call udevtrigger and udevsettle to do the device configuration:
+ /sbin/udevadm trigger --type=subsystems --action=add
+ /sbin/udevadm trigger --type=devices --action=add
+ else # trigger changes for already running udevd
+ # If the persistent rules files do not exist, trigger an add event:
+ if [ ! -r /etc/udev/rules.d/70-persistent-net.rules ]; then
+ # Test that we can actually write to the directory first:
+ if touch /etc/udev/rules.d/testfile 2> /dev/null ; then
+ rm -f /etc/udev/rules.d/testfile
+ # This should add persistent net/cd rules:
+ echo "Triggering udev to write persistent rules to /etc/udev/rules.d/"
+ /sbin/udevadm trigger --type=devices --action=add
+ sleep 3
+ fi
+ fi
+ # Since udevd is running, most of the time we only need change events:
+ echo "Triggering udev events: /sbin/udevadm trigger --action=change"
+ /sbin/udevadm trigger --type=subsystems --action=change
+ /sbin/udevadm trigger --type=devices --action=change
+ fi
+ /sbin/udevadm settle --timeout=120
+ ;;
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
- fi
- killall udevd
+ udevadm control --exit
+ killall udevd 2>/dev/null
;;
restart)
echo "Restarting udevd is STRONGLY discouraged and not supported."
@@ -138,18 +144,18 @@ case "$1" in
;;
force-restart)
echo "Restarting udevd"
- killall udevd
- sleep 5
+ udevadm control --exit
+ sleep 3
udevd --daemon
;;
reload)
echo "Reloading udev rules"
- udevadm control --reload-rules
+ udevadm control --reload
cp --preserve=all --recursive --update /lib/udev/devices/* $UDEV_ROOT
;;
force-reload)
echo "Updating all available device nodes in $UDEV_ROOT"
- udevadm control --reload-rules
+ udevadm control --reload
rm -rf $UDEV_ROOT/.udev $UDEV_ROOT/disk
cp --preserve=all --recursive --update /lib/udev/devices/* $UDEV_ROOT
;;