Magellan Linux

Contents of /trunk/busybox/mdev.rc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1236 - (show annotations) (download)
Fri Dec 10 23:27:46 2010 UTC (13 years, 4 months ago) by niro
File size: 2796 byte(s)
-enabled full coldplug support
1 #!/bin/sh
2 # $Header: /root/magellan-cvs/src/busybox/mdev.rc,v 1.1 2010-08-22 16:43:06 niro Exp $
3
4 seed_dev()
5 {
6 # seed /dev with some things that we know we need
7 rc_print " Seeding /dev with needed nodes ..."
8 (
9 [ ! -c /dev/console ] && mknod /dev/console c 5 1
10 [ ! -c /dev/tty1 ] && mknod /dev/tty1 c 4 1
11 [ ! -c /dev/null ] && mknod /dev/null c 1 3
12
13 # create kmsg too, so udev can add its start-message to dmesg
14 [ -c /dev/kmsg ] || mknod -m 660 /dev/kmsg c 1 11
15
16 # copy over any persistant things
17 if [[ -d /lib/udev/devices ]]
18 then
19 cp -RPp /lib/udev/devices/* /dev 2>/dev/null
20 fi
21
22 # not provided by sysfs but needed
23 ln -snf /proc/self/fd /dev/fd
24 ln -snf fd/0 /dev/stdin
25 ln -snf fd/1 /dev/stdout
26 ln -snf fd/2 /dev/stderr
27 [[ -e /proc/kcore ]] && ln -snf /proc/kcore /dev/core
28
29 # create problematic directories
30 mkdir -p /dev/pts /dev/shm
31 )
32 evaluate_retval
33 }
34
35 # This works for 2.6.15 kernels or greater
36 trigger_uevents()
37 {
38 local list=""
39 local i
40 local first
41 local last
42 local default
43
44 # if you want real coldplug (with all modules being loaded for all
45 # devices in the system), uncomment out the next line.
46 list="${lis}t $(echo /sys/bus/*/devices/*/uevent)"
47 list="${list} $(echo /sys/class/*/*/uevent)"
48 list="${list} $(echo /sys/block/*/uevent /sys/block/*/*/uevent)"
49 for i in ${list}
50 do
51 case "${i}" in
52 */device/uevent)
53 # skip followed device symlinks
54 continue
55 ;;
56 */class/mem/*|*/class/tty/*)
57 first="${first} ${i}"
58 ;;
59 */block/md*)
60 last="${last} ${i}"
61 ;;
62 */*)
63 default="${default} ${i}"
64 ;;
65 esac
66 done
67
68 # trigger the sorted events
69 for i in ${first} ${default} ${last}
70 do
71 echo "add" > "${i}"
72 done
73 }
74
75 # main functions
76 start_devicemanager()
77 {
78 # create a ramdisk for populating mdev
79 rc_print "Mounting mdev at /dev ..."
80 # many video drivers needed exec access
81 fstype=ramfs
82 # tmpfs was suggested by Greg Kroah-Hartman
83 kernel_supports_fs tmpfs && fstype=tmpfs
84 # mount devtmpfs if supported
85 kernel_supports_fs devtmpfs && fstype=devtmpfs
86 mount -n -t ${fstype} mdev /dev -o exec,nosuid,mode=0755,size=1024
87 evaluate_retval
88
89 # other eeded device nodes with udev
90 seed_dev
91
92 if [ -e /proc/sys/kernel/hotplug ]
93 then
94 rc_print " Using mdev for hotplug events ..."
95 echo "/sbin/mdev" > /proc/sys/kernel/hotplug
96 evaluate_retval
97 else
98 rc_print ${COLYELLOW}" Kernel was not compiled with hotplug support !"
99 print_status failure
100 fi
101
102 # load unix domain sockets if built as module
103 if [ -e /proc/modules ]
104 then
105 modprobe -q unix 2>/dev/null
106 fi
107
108 rc_print " Populating /dev with existing devices through uevents ..."
109 trigger_uevents
110
111 rc_print " Starting mdev ..."
112 /sbin/mdev -s
113 evaluate_retval
114
115 # same thing as /dev/.devfsd
116 touch /dev/.mdev
117 }
118
119 stop_devicemanager()
120 {
121 return 0
122 }