# starts udev # $Header$ seed_dev() { echo -e ${COLOREDSTAR}" Seeding /dev with needed nodes ..." # not provided by sysfs but needed ln -snf /proc/self/fd /dev/fd ln -snf fd/0 /dev/stdin ln -snf fd/1 /dev/stdout ln -snf fd/2 /dev/stderr ln -snf /proc/kcore /dev/core ln -snf /proc/asound/oss/sndstat /dev/sndstat # create problematic directories mkdir -p /dev/{pts,shm} return 0 } # some needed functions functions populate_udev() { # trigger via uevents on newer kernels (>= 2.6.15) if [ "$(kernel_version | sed 's:\.::g')" -gt "2614" ] then echo -e ${COLOREDSTAR}" Populating /dev with existing devices through uevents ..." trigger_uevents evaluate_retval else echo -e ${COLOREDSTAR}" Populating /dev with existing devices via udevstart ..." /sbin/udevstart evaluate_retval fi # loop until everything is finished # there's gotta be a better way... echo -e ${COLOREDSTAR}" Letting udev process events ..." local loop=0 while test -d /dev/.udev/queue do sleep 0.1; test "${loop}" -gt 300 && break loop=$((${loop} + 1)) done evaluate_retval return 0 } # This works for 2.6.15 kernels or greater trigger_uevents() { local list="" local i local first local last local default # if you want real coldplug (with all modules being loaded for all # devices in the system), uncomment out the next line. #list="${lis}t $(echo /sys/bus/*/devices/*/uevent)" list="${list} $(echo /sys/class/*/*/uevent)" list="${list} $(echo /sys/block/*/uevent /sys/block/*/*/uevent)" for i in ${list} do case "${i}" in */device/uevent) # skip followed device symlinks continue ;; */class/mem/*|*/class/tty/*) first="${first} ${i}" ;; */block/md*) last="${last} ${i}" ;; */*) default="${default} ${i}" ;; esac done # trigger the sorted events for i in ${first} ${default} ${last} do echo "add" > "${i}" done } start_udev() { # create a ramdisk for populating udev echo -e ${COLOREDSTAR}"Mounting udev at /dev ..." # many video drivers needed exec access fstype=ramfs # tmpfs was suggested by Greg Kroah-Hartman kernel_supports_fs tmpfs && fstype=tmpfs # mount devtmpfs if supported kernel_supports_fs devtmpfs && fstype=devtmpfs mount -n -t ${fstype} udev /dev -o exec,nosuid,mode=0755,size=10M evaluate_retval # if a device tarball exists load it and if it is activated echo -e ${COLOREDSTAR}"Configurating system to use udev ..." if [[ ${RC_DEVICE_TARBALL} = yes ]] then echo -e ${COLOREDSTAR}" Populating /dev with with device nodes ..." tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev evaluate_retval fi seed_dev # use netlink to manage udev with newer kernels if [ "$(kernel_version | sed 's:\.::g')" -gt "2614" ] then echo -e ${COLOREDSTAR}" Using netlink for hotplug events ..." echo "" > /proc/sys/kernel/hotplug elif [ -e /proc/sys/kernel/hotplug ] then echo -e ${COLOREDSTAR}" Setting /sbin/udev as hotplug agent ..." echo "/sbin/udev" > /proc/sys/kernel/hotplug else echo -e ${COLOREDSTAR}${COLYELLOW}" Kernel was not compiled with hotplug support !" fi evaluate_retval # start udev daemon echo -e ${COLOREDSTAR}" Starting udevd daemon ..." start-stop-daemon --start --exec /sbin/udevd -- --daemon evaluate_retval # now load udev populate_udev } stop_udev() { echo -e ${COLOREDSTAR}" Stopping udevd daemon ..." start-stop-daemon --stop --exec /sbin/udevd evaluate_retval # if requested save devices to a device tarball before halt # only for kernels >=2.6 *and* udev # make sure that udev is mounted but *not* devfs --> /dev/.devfsd if [[ ${RC_DEVICE_TARBALL} = yes ]] && \ [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ] then echo -e ${COLOREDSTAR}"Saving /dev device nodes ..." ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null ) mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2 evaluate_retval fi } start_devicemanager() { start_udev } stop_devicemanager() { stop_udev }