Contents of /trunk/busybox/mdev.rc
Parent Directory | Revision Log
Revision 1723 -
(show annotations)
(download)
Mon Apr 2 13:07:13 2012 UTC (12 years, 5 months ago) by niro
File size: 2894 byte(s)
Mon Apr 2 13:07:13 2012 UTC (12 years, 5 months ago) by niro
File size: 2894 byte(s)
-do not mount /dev if already mounted, and fixed mount options (mount as dev and use 10MB)
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 | if [[ -z $(grep '[[:space:]]/dev[[:space:]]' /proc/mounts | cut -d ' ' -f2) ]] |
80 | then |
81 | rc_print "Mounting mdev at /dev ..." |
82 | # many video drivers needed exec access |
83 | fstype=ramfs |
84 | # tmpfs was suggested by Greg Kroah-Hartman |
85 | kernel_supports_fs tmpfs && fstype=tmpfs |
86 | # mount devtmpfs if supported |
87 | kernel_supports_fs devtmpfs && fstype=devtmpfs |
88 | mount -n -t ${fstype} dev /dev -o exec,nosuid,mode=0755,size=10M |
89 | evaluate_retval |
90 | fi |
91 | |
92 | # other needed device nodes with mdev |
93 | seed_dev |
94 | |
95 | if [ -e /proc/sys/kernel/hotplug ] |
96 | then |
97 | rc_print " Using mdev for hotplug events ..." |
98 | echo "/sbin/mdev" > /proc/sys/kernel/hotplug |
99 | evaluate_retval |
100 | else |
101 | rc_print ${COLYELLOW}" Kernel was not compiled with hotplug support !" |
102 | print_status failure |
103 | fi |
104 | |
105 | # load unix domain sockets if built as module |
106 | if [ -e /proc/modules ] |
107 | then |
108 | modprobe -q unix 2>/dev/null |
109 | fi |
110 | |
111 | rc_print " Populating /dev with existing devices through uevents ..." |
112 | trigger_uevents |
113 | |
114 | rc_print " Starting mdev ..." |
115 | /sbin/mdev -s |
116 | evaluate_retval |
117 | |
118 | # same thing as /dev/.devfsd |
119 | touch /dev/.mdev |
120 | } |
121 | |
122 | stop_devicemanager() |
123 | { |
124 | return 0 |
125 | } |