#!/bin/sh # $Header: /root/magellan-cvs/src/busybox/mdev.rc,v 1.1 2010-08-22 16:43:06 niro Exp $ seed_dev() { # seed /dev with some things that we know we need rc_print " 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 # create kmsg too, so udev can add its start-message to dmesg [ -c /dev/kmsg ] || mknod -m 660 /dev/kmsg c 1 11 # copy over any persistant things if [[ -d /lib/udev/devices ]] then cp -RPp /lib/udev/devices/* /dev 2>/dev/null fi # 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 [[ -e /proc/kcore ]] && ln -snf /proc/kcore /dev/core # create problematic directories mkdir -p /dev/pts /dev/shm ) 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 # other eeded device nodes with udev seed_dev if [ -e /proc/sys/kernel/hotplug ] then rc_print " Using mdev for hotplug events ..." echo "/sbin/mdev" > /proc/sys/kernel/hotplug evaluate_retval else rc_print ${COLYELLOW}" Kernel was not compiled with hotplug support !" print_status failure fi # load unix domain sockets if built as module if [ -e /proc/modules ] then 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 # same thing as /dev/.devfsd touch /dev/.mdev } stop_devicemanager() { return 0 }