--- trunk/busybox/mdev.rc 2010/08/22 16:43:06 1113 +++ trunk/busybox/mdev.rc 2012/04/02 13:07:13 1723 @@ -32,21 +32,64 @@ evaluate_retval } +# 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 +} + # main functions start_devicemanager() { # create a ramdisk for populating mdev - rc_print "Mounting mdev 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} mdev /dev -o exec,nosuid,mode=0755,size=1024 - evaluate_retval + if [[ -z $(grep '[[:space:]]/dev[[:space:]]' /proc/mounts | cut -d ' ' -f2) ]] + then + rc_print "Mounting mdev 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} dev /dev -o exec,nosuid,mode=0755,size=10M + evaluate_retval + fi - # other eeded device nodes with udev + # other needed device nodes with mdev seed_dev if [ -e /proc/sys/kernel/hotplug ] @@ -65,6 +108,9 @@ modprobe -q unix 2>/dev/null fi + rc_print " Populating /dev with existing devices through uevents ..." + trigger_uevents + rc_print " Starting mdev ..." /sbin/mdev -s evaluate_retval