3 # udev init script to setup /udev
5 # chkconfig: 2345 20 80
6 # description: manage user-space device nodes in /udev
8 . /etc/rc.d/init.d/functions
19 # handle block devices and their partitions
20 for i in ${sysfs_dir}/block/*; do
22 export DEVPATH=${i#${sysfs_dir}}
25 # add each partition, on each device
27 if [ -f $j/dev ]; then
28 export DEVPATH=${j#${sysfs_dir}}
33 # all other device classes
34 for i in ${sysfs_dir}/class/*; do
36 if [ -f $j/dev ]; then
37 export DEVPATH=${j#${sysfs_dir}}
38 CLASS=`echo ${i#${sysfs_dir}} | \
39 cut --delimiter='/' --fields=3-`
48 # there are a few things that sysfs does not export for us.
49 # these things go here (and remember to remove them in
50 # remove_extra_nodes()
52 # Thanks to Gentoo for the initial list of these.
53 ln -snf /proc/self/fd $udev_root/fd
54 ln -snf /proc/self/fd/0 $udev_root/stdin
55 ln -snf /proc/self/fd/1 $udev_root/stdout
56 ln -snf /proc/self/fd/2 $udev_root/stderr
57 ln -snf /proc/kcore $udev_root/core
58 #ln -snf /proc/asound/oss/sndstat $udev_root/sndstat
61 remove_extra_nodes () {
62 # get rid of the extra nodes created in make_extra_nodes()
68 #rm $udev_root/sndstat
73 # don't use udev if sysfs is not mounted.
74 if [ ! -d $sysfs_dir/block ]; then
77 if [ ! -d $udev_root ]; then
81 # remove the database if it is there as we always want to start fresh
82 if [ -f $udev_root/.udev.tdb ]; then
83 rm -f $udev_root/.udev.tdb
86 # propogate /udev from /sys - we only need this while we do not
87 # have initramfs and an early user-space with which to do early
90 echo -n $"Creating initial udev device nodes:"
94 # We want to start udevd ourselves if it isn't already running. This
95 # lets udevd run at a sane nice level...
100 touch /var/lock/subsys/udev
104 echo -n $"Removing udev device nodes: "
110 rm -f /var/lock/subsys/udev
113 if [ -f /var/lock/subsys/udev ]; then
114 echo $"$prog has run"
117 echo $"$prog is stopped"
128 echo "Usage: $0 {start|stop|status|restart}"