--- trunk/magellan-initscripts/etc/rc.d/init.d/rc 2006/03/04 18:55:54 345 +++ trunk/magellan-initscripts/etc/rc.d/init.d/rc 2007/03/06 00:10:26 431 @@ -1,5 +1,5 @@ #!/bin/bash -# $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/rc,v 1.8 2006-03-04 18:55:54 niro Exp $ +# $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/rc,v 1.14 2007-03-06 00:10:26 niro Exp $ source /etc/sysconfig/rc source $rc_functions @@ -21,60 +21,29 @@ version=${version##0} # Older udev's will print nothing [[ -z ${version} ]] && version=0 + elif [[ -x /sbin/udevd ]] + then + version=$(/sbin/udevd --version) + version=${version##0} + [[ -z ${version} ]] && version=0 fi echo "${version}" } -# 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 + local opts + + # tell modprobe.sh to be verbose to $CONSOLE + echo CONSOLE=${CONSOLE} > /dev/.udev_populate # populate /dev with devices already found by the kernel - if [ "$(kernel_version | sed 's:\.::g')" -gt "2614" ] + if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ] then echo -e ${COLOREDSTAR}" Populating /dev with existing devices through uevents ..." - trigger_events + [[ $(udev_version) -ge "96" ]] && [[ ${RC_COLDPLUG} != yes ]] && opts="--attr-match=dev" + /sbin/udevtrigger ${opts} evaluate_retval else echo -e ${COLOREDSTAR}" Populating /dev with existing devices with udevstart ..." @@ -83,17 +52,11 @@ 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 + /sbin/udevsettle --timeout=60 evaluate_retval + rm -f /dev/.udev_populate return 0 } @@ -102,9 +65,16 @@ # seed /dev with some things that we know we need echo -e ${COLOREDSTAR}" Seeding /dev with needed nodes ..." ( + [ ! -c /dev/console ] && mknod /dev/console c 5 1 + [ ! -c /dev/tty1 ] && mknod /dev/tty1 c 4 1 + [ ! -c /dev/null ] && mknod /dev/null c 1 3 + # copy over any persistant things - cp --preserve=all --recursive --update /lib/udev/devices/* /dev - + if [[ -d /lib/udev/devices ]] + then + cp --preserve=all --recursive --update /lib/udev/devices/* /dev + fi + # not provided by sysfs but needed ln -snf /proc/self/fd /dev/fd ln -snf fd/0 /dev/stdin @@ -126,7 +96,7 @@ then echo echo -e "${COLGREEN}Starting ${COLBLUE}MAGELLAN (v${MAGEVER}) ${COLGREEN}Linux${COLDEFAULT}" - echo -e "Copyright 2001-2006 Niels Rogalla; http://magellan-linux.net" + echo -e "Copyright 2001-2007 Niels Rogalla; http://magellan-linux.net" echo # mount proc filesystem, needed for bootsplash; @@ -194,11 +164,16 @@ # load udev only with a 2.6 kernel if [[ $(kernel_major_version) = 2.6 ]] && [[ ${RC_USED_DEV} = udev ]] then + # check if /dev/console exists outside tmpfs + [ -c /dev/console ] ; need_redirect=$? + # create a ramdisk for populating udev echo -e ${COLOREDSTAR}"Mounting udev at /dev ..." - # tmpfs was suggested by Greg Kroah-Hartman # many video drivers needed exec access - mount -n -t ramfs udev /dev -o exec,nosuid,mode=0755 + fstype=ramfs + # tmpfs was suggested by Greg Kroah-Hartman + kernel_supports_fs tmpfs && fstype=tmpfs + mount -n -t ${fstype} udev /dev -o exec,nosuid,mode=0755 evaluate_retval # if a device tarball exists load it and if it is activated @@ -215,24 +190,15 @@ if [ -e /proc/sys/kernel/hotplug ] then - if [ "$(kernel_version | sed 's:\.::g')" -gt "2614" ] + if [ "$(kernel_version | sed 's:\.::g' | cut -d_ -f1)" -gt "2614" ] then echo -e ${COLOREDSTAR}" Using netlink for hotplug events ..." echo "" > /proc/sys/kernel/hotplug evaluate_retval - elif [[ $(udev_version) -ge "48" ]] - then + else 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 !" @@ -240,7 +206,13 @@ fi echo -e ${COLOREDSTAR}" Starting udevd daemon ..." - /sbin/udevd --daemon + if [ ${need_redirect} -eq 1 ] + then + # we need to open fds 0 1 2 + /sbin/udevd --daemon /dev/console 2>/dev/console + else + /sbin/udevd --daemon + fi evaluate_retval populate_udev