--- trunk/magellan-initscripts/etc/rc.d/init.d/rc 2005/07/03 21:34:35 150 +++ trunk/magellan-initscripts/etc/rc.d/init.d/rc 2006/01/03 18:03:21 318 @@ -1,5 +1,5 @@ #!/bin/bash -# $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/rc,v 1.5 2005-07-03 21:34:35 niro Exp $ +# $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/rc,v 1.6 2006-01-03 18:03:21 niro Exp $ source /etc/sysconfig/rc source $rc_functions @@ -10,27 +10,117 @@ # source kernel config if exists [ -f /etc/conf.d/kernel ] && source /etc/conf.d/kernel -# some needed functions functions +# this works only for 2.6.15 kernels and greater +trigger_events() +{ + local list="" + local i + local first + local last + local default + + # if you want real hotplug (with all modules being loaded for all + # devices in the system), uncomment out the next line. + #list="$list $(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 +} + populate_udev() { + local loop + + # populate /dev with devices already found by the kernel + if [ "$(kernel_version | sed 's:\.::g')" -gt "2614" ] + then + echo -e ${COLOREDSTAR}" Populating /dev with existing devices through uevents ..." + trigger_events + evaluate_retval + else + echo -e ${COLOREDSTAR}" Populating /dev with existing devices with 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 ..." + 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 +} +seed_dev() { + # seed /dev with some things that we know we need + echo -e ${COLOREDSTAR}" Seeding /dev with needed nodes ..." + ( + # copy over any persistant things + cp --preserve=all --recursive --update /lib/udev/devices/* /dev + # 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 - + [[ -e /proc/kcore ]] && ln -snf /proc/kcore /dev/core + # create problematic directories mkdir -p /dev/{pts,shm} - - # same as /dev/.devfsd - touch /dev/.udev - - return 0 + ) + evaluate_retval } +# # some needed functions functions +# populate_udev() { +# /sbin/udevstart +# +# # 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} +# +# # same as /dev/.devfsd +# touch /dev/.udev +# +# return 0 +# } + trap "" INT QUIT TSTP [ "$1" != "" ] && runlevel=$1 @@ -118,27 +208,55 @@ echo -e ${COLOREDSTAR}"Configurating system to use udev ..." if [[ ${RC_DEVICE_TARBALL} = yes ]] then - echo -e ${COLOREDSTAR}" Populating /dev with with device nodes ..." + echo -e ${COLOREDSTAR}" Populating /dev with saved device nodes ..." tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev evaluate_retval fi - # now load udev - populate_udev - - # if hotplug support exists in the kernel use it to manage udev - if [ -e /proc/sys/kernel/hotplug -a -x /sbin/hotplug ] - then - echo -e ${COLOREDSTAR}" Using /sbin/hotplug for udev management ..." + # other eeded device nodes with udev + seed_dev - elif [ -e /proc/sys/kernel/hotplug ] + if [ -e /proc/sys/kernel/hotplug ] then - echo -e ${COLOREDSTAR}" Setting /sbin/udev as hotplug agent ..." - echo "/sbin/udev" > /proc/sys/kernel/hotplug + if [ "$(kernel_version | sed 's:\.::g')" -gt "2614" ] + then + echo -e ${COLOREDSTAR}" Using netlink for hotplug events ..." + echo "" > /proc/sys/kernel/hotplug + evaluate_retval + elif [[ $(udev_version) -ge "48" ]] + then + echo -e ${COLOREDSTAR}" Setting /sbin/udevsend as hotplug agent ..." + echo "/sbin/udevsend" > /proc/sys/kernel/hotplug + evaluate_retval + elif [[ -x /sbin/hotplug ]] + then + echo -e ${COLOREDSTAR}" Using /sbin/hotplug as hotplug agent ..." + print_status success + else + echo -e ${COLOREDSTAR}" Setting /sbin/udev as hotplug agent ..." + echo "/sbin/udev" > /proc/sys/kernel/hotplug + evaluate_retval + fi else echo -e ${COLOREDSTAR}${COLYELLOW}" Kernel was not compiled with hotplug support !" + print_status failure fi + + echo -e ${COLOREDSTAR}" Starting udevd daemon ..." + /sbin/udevd --daemon evaluate_retval + + populate_udev + + # create nodes that udev can't + echo -e ${COLOREDSTAR}" Finializing udev configuration ..." + [[ -x /sbin/dmsetup ]] && /sbin/dmsetup mknodes &>/dev/null + [[ -x /sbin/lvm ]] && /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null + [[ -x /sbin/evms_activate ]] && /sbin/evms_activate -q &>/dev/null + print_status success + + # same thing as /dev/.devfsd + touch /dev/.udev fi ## load devpts ##