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 # don't use udev if sysfs is not mounted.
24 [ ! -d $sysfs_dir/class ] || exit 1
25 [ -r /proc/mounts ] || exit 1
26 [ -x /sbin/udev ] || exit 1
27 [ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf
30 . /etc/rc.d/init.d/functions
35 MAKEDEV="/sbin/MAKEDEV"
38 ln -snf /proc/self/fd $udev_root/fd
39 ln -snf /proc/self/fd/0 $udev_root/stdin
40 ln -snf /proc/self/fd/1 $udev_root/stdout
41 ln -snf /proc/self/fd/2 $udev_root/stderr
42 ln -snf /proc/kcore $udev_root/core
44 [ -d $udev_root/pts ] || (mkdir $udev_root/pts;chmod 0755 $udev_root/pts)
45 [ -d $udev_root/shm ] || (mkdir $udev_root/shm;chmod 0755 $udev_root/shm)
47 if [ -x $MAKEDEV ]; then
49 for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
50 echo cpu/$i/microcode;
52 for i in 1 2 3 4 5 6; do echo tty$i;done;
53 for i in 0 1 2 3 4 5 6 7; do echo loop$i; done;
54 for i in 0 1 2 3; do echo lp$i; echo parport$i;done;
55 echo net/tun ppp console null zero;
57 [ -a /dev/MAKEDEV ] || ln -s $MAKEDEV /dev/MAKEDEV;
58 cp -a /etc/udev/devices/* /dev/ >/dev/null 2>&1 || :
63 if [ -x /sbin/pidof ]; then
64 pid=`/sbin/pidof -x udevd`
65 [ -n "$pid" ] && kill $pid
69 # we cannot use /usr/bin/find here
75 if [ -d "$f" -a ! -L "$f" ]; then
76 if [ "$f" != "${f%%$what}" ];then
77 # make sure we are at the path end
78 # we have no dirname and basename
80 [ "${rest##*/}" = "$rest" ] && found="$found $f"
82 found="$found $(find_d $f $what)"
88 # we cannot use /usr/bin/find here
94 if [ -d "$f" -a ! -L "$f" ]; then
95 found="$found $(find_f $f $what)"
96 elif [ -e "$f" ]; then
97 [ "$f" != "${f%$what}" ] && found="$found $f"
103 # call hotplug with the scsi devices
105 HOTPLUG=$(cat /proc/sys/kernel/hotplug)
106 [ -z "$HOTPLUG" ] && return 1
108 scsi_hosts=$(find_d /sys/devices host\*)
111 for host in $scsi_hosts; do
112 [ -d $host ] || continue
113 devs=$(find_f $host type)
115 [ -f $dev ] || continue
118 DEVPATH=${DEVPATH#/sys}
122 SEQNUM=$(($SEQNUM + 1))
124 SEQNUM=$(($SEQNUM + 1))
131 if [ ! -d /proc/ide ]; then
134 for i in /proc/ide/*/media; do
153 /sbin/modprobe $module
159 export UDEV_NO_SLEEP=1
163 # propagate $udev_root from /sys
164 grep -q "none ${udev_root%/} " /proc/mounts || {
165 mount -n -o mode=0755 -t tmpfs none "$udev_root"
168 rm -f $udev_root/.udev.tdb
170 kill_udevd >/dev/null 2>&1
171 scsi_replay >/dev/null 2>&1
173 kill_udevd >/dev/null 2>&1
174 ide_scan >/dev/null 2>&1
177 [ $ret -eq 0 ] && ok || fail