Magellan Linux

Contents of /tags/udev-081-r4/config-udev-081-r4/udev.rc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1211 - (show annotations) (download)
Thu Dec 2 13:03:42 2010 UTC (13 years, 5 months ago) by niro
File size: 4114 byte(s)
tagged udev-081-r4
1 # starts udev
2 # $Header$
3
4 seed_dev()
5 {
6 echo -e ${COLOREDSTAR}" Seeding /dev with needed nodes ..."
7
8 # not provided by sysfs but needed
9 ln -snf /proc/self/fd /dev/fd
10 ln -snf fd/0 /dev/stdin
11 ln -snf fd/1 /dev/stdout
12 ln -snf fd/2 /dev/stderr
13 ln -snf /proc/kcore /dev/core
14 ln -snf /proc/asound/oss/sndstat /dev/sndstat
15
16 # create problematic directories
17 mkdir -p /dev/{pts,shm}
18
19 return 0
20 }
21
22 # some needed functions functions
23 populate_udev()
24 {
25 # trigger via uevents on newer kernels (>= 2.6.15)
26 if [ "$(kernel_version | sed 's:\.::g')" -gt "2614" ]
27 then
28 echo -e ${COLOREDSTAR}" Populating /dev with existing devices through uevents ..."
29 trigger_uevents
30 evaluate_retval
31 else
32 echo -e ${COLOREDSTAR}" Populating /dev with existing devices via udevstart ..."
33 /sbin/udevstart
34 evaluate_retval
35 fi
36
37 # loop until everything is finished
38 # there's gotta be a better way...
39 echo -e ${COLOREDSTAR}" Letting udev process events ..."
40 local loop=0
41 while test -d /dev/.udev/queue
42 do
43 sleep 0.1;
44 test "${loop}" -gt 300 && break
45 loop=$((${loop} + 1))
46 done
47 evaluate_retval
48
49 return 0
50 }
51
52 # This works for 2.6.15 kernels or greater
53 trigger_uevents()
54 {
55 local list=""
56 local i
57 local first
58 local last
59 local default
60
61 # if you want real coldplug (with all modules being loaded for all
62 # devices in the system), uncomment out the next line.
63 #list="${lis}t $(echo /sys/bus/*/devices/*/uevent)"
64 list="${list} $(echo /sys/class/*/*/uevent)"
65 list="${list} $(echo /sys/block/*/uevent /sys/block/*/*/uevent)"
66 for i in ${list}
67 do
68 case "${i}" in
69 */device/uevent)
70 # skip followed device symlinks
71 continue
72 ;;
73 */class/mem/*|*/class/tty/*)
74 first="${first} ${i}"
75 ;;
76 */block/md*)
77 last="${last} ${i}"
78 ;;
79 */*)
80 default="${default} ${i}"
81 ;;
82 esac
83 done
84
85 # trigger the sorted events
86 for i in ${first} ${default} ${last}
87 do
88 echo "add" > "${i}"
89 done
90 }
91
92 start_udev()
93 {
94
95 # create a ramdisk for populating udev
96 echo -e ${COLOREDSTAR}"Mounting udev at /dev ..."
97 # many video drivers needed exec access
98 fstype=ramfs
99 # tmpfs was suggested by Greg Kroah-Hartman
100 kernel_supports_fs tmpfs && fstype=tmpfs
101 # mount devtmpfs if supported
102 kernel_supports_fs devtmpfs && fstype=devtmpfs
103 mount -n -t ${fstype} udev /dev -o exec,nosuid,mode=0755,size=10M
104 evaluate_retval
105
106 # if a device tarball exists load it and if it is activated
107 echo -e ${COLOREDSTAR}"Configurating system to use udev ..."
108 if [[ ${RC_DEVICE_TARBALL} = yes ]]
109 then
110 echo -e ${COLOREDSTAR}" Populating /dev with with device nodes ..."
111 tar -jxpf /lib/udev-state/devices.tar.bz2 -C /dev
112 evaluate_retval
113 fi
114
115 seed_dev
116
117 # use netlink to manage udev with newer kernels
118 if [ "$(kernel_version | sed 's:\.::g')" -gt "2614" ]
119 then
120 echo -e ${COLOREDSTAR}" Using netlink for hotplug events ..."
121 echo "" > /proc/sys/kernel/hotplug
122
123 elif [ -e /proc/sys/kernel/hotplug ]
124 then
125 echo -e ${COLOREDSTAR}" Setting /sbin/udev as hotplug agent ..."
126 echo "/sbin/udev" > /proc/sys/kernel/hotplug
127 else
128 echo -e ${COLOREDSTAR}${COLYELLOW}" Kernel was not compiled with hotplug support !"
129 fi
130 evaluate_retval
131
132 # start udev daemon
133 echo -e ${COLOREDSTAR}" Starting udevd daemon ..."
134 start-stop-daemon --start --exec /sbin/udevd -- --daemon
135 evaluate_retval
136
137 # now load udev
138 populate_udev
139 }
140
141 stop_udev()
142 {
143 echo -e ${COLOREDSTAR}" Stopping udevd daemon ..."
144 start-stop-daemon --stop --exec /sbin/udevd
145 evaluate_retval
146
147 # if requested save devices to a device tarball before halt
148 # only for kernels >=2.6 *and* udev
149 # make sure that udev is mounted but *not* devfs --> /dev/.devfsd
150 if [[ ${RC_DEVICE_TARBALL} = yes ]] && \
151 [ -e /dev/.udev -a ! -e /dev/.devfsd -a ! -e /.bootdev ]
152 then
153 echo -e ${COLOREDSTAR}"Saving /dev device nodes ..."
154 ( cd /dev; tar -jclpf "/tmp/devices-$$.tar.bz2" * &> /dev/null )
155 mv -f "/tmp/devices-$$.tar.bz2" /lib/udev-state/devices.tar.bz2
156 evaluate_retval
157 fi
158 }
159
160 start_devicemanager()
161 {
162 start_udev
163 }
164
165 stop_devicemanager()
166 {
167 stop_udev
168 }

Properties

Name Value
svn:executable *