5 # script to initialize /dev by using udev.
7 # Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com>
9 # Released under the GPL v2 only.
11 # This needs to be run at the earliest possible point in the boot
14 # Based on the udev init.d script
16 # Thanks go out to the Gentoo developers for proving
17 # that this is possible to do.
19 # Yes, it's very verbose, feel free to turn off all of the echo calls,
20 # they were there to make me feel better that everything was working
21 # properly during development...
23 # default value, if no config present.
28 # don't use udev if sysfs is not mounted.
29 [ -d $sysfs_dir/class ] || exit 1
30 [ -r /proc/mounts ] || exit 1
31 [ -x /sbin/udev ] || exit 1
32 [ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf
34 . /etc/rc.d/init.d/functions
41 grep '^[^#]' /etc/udev/links.conf | \
42 while read type name arg1; do
43 [ "$type" -a "$name" -a ! -e "$udev_root/$name" -a ! -L "/dev/$name" ] ||continue
45 L) ln -s $arg1 $udev_root/$name ;;
46 D) mkdir -p $udev_root/$name ;;
47 *) echo "links.conf: unparseable line ($type $name $arg1)" ;;
50 cp -a /lib/udev/devices/* /dev/ >/dev/null 2>&1 || :
54 if [ -x /sbin/pidof ]; then
55 pid=`/sbin/pidof -x udevd`
56 [ -n "$pid" ] && kill $pid
60 set_hotplug_handler() {
61 echo "" > /proc/sys/kernel/hotplug
70 if ! supported_kernel; then
73 # mount the tmpfs on ${udev_root%/}, if not already done
74 LANG=C awk "\$2 == \"${udev_root%/}\" && \$3 == \"tmpfs\" { exit 1 }" /proc/mounts && {
75 if LANG=C fgrep -q "none ${udev_root%/}/pts " /proc/mounts; then
76 PTSDIR=$(mktemp -d ${TMPDIR:-/tmp}/tmpXXXXXX)
77 mount --move $udev_root/pts "$PTSDIR"
79 if LANG=C fgrep -q "none ${udev_root%/}/shm " /proc/mounts; then
80 SHMDIR=$(mktemp -d ${TMPDIR:-/tmp}/tmpXXXXXX)
81 mount --move $udev_root/shm "$SHMDIR"
83 mount -n -o mode=0755 -t tmpfs none "$udev_root"
84 mkdir -m 0755 $udev_root/pts
85 mkdir -m 0755 $udev_root/shm
86 if [ -n "$PTSDIR" ]; then
87 mount --move "$PTSDIR" $udev_root/pts
90 if [ -n "$SHMDIR" ]; then
91 mount --move "$SHMDIR" $udev_root/shm
98 kill_udevd > "$udev_root/null" 2>&1
100 if [ -f "/sys/class/tty/console/uevent" ]; then
107 # Setting default hotplug handler
110 # retrigger all events
111 mkdir -p /dev/.udev/queue
112 list=$(echo /sys/bus/*/devices/*/uevent)
113 list="$list $(echo /sys/class/*/*/uevent)"
114 list="$list $(echo /sys/block/*/uevent /sys/block/*/*/uevent)"
117 */device/uevent|*\**)
120 */class/mem/*|*/class/tty/*)
127 default="$default $i"
132 # trigger the sorted events
133 for i in $first $default $last; do
138 # wait for the events to finish
140 while test -d /dev/.udev/queue; do
142 test "$loop" -gt 0 || break
146 echo "udev requires a kernel >= 2.6.15, not started."
151 [ $ret -eq 0 ] && ok || fail