summaryrefslogtreecommitdiffstats
path: root/openembedded/packages/udev/udev-084/init
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2006-02-03 09:02:41 +0000
committerRichard Purdie <richard@openedhand.com>2006-02-03 09:02:41 +0000
commit4a64818533733e194138a45656aaf14d5a123e98 (patch)
tree79925075659d01f3b148e4267138ee6e8de91789 /openembedded/packages/udev/udev-084/init
parentbc4e7ed8993d3f598e5c03b78838bbc6199413ba (diff)
downloadpoky-4a64818533733e194138a45656aaf14d5a123e98.tar.gz
Update to udev 084 from OE. This adds a coldplug script to emulate the calls necessary to load devices already inserted into the system at boot. It also adds a network interface control script.
git-svn-id: https://svn.o-hand.com/repos/poky@247 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'openembedded/packages/udev/udev-084/init')
-rw-r--r--openembedded/packages/udev/udev-084/init227
1 files changed, 227 insertions, 0 deletions
diff --git a/openembedded/packages/udev/udev-084/init b/openembedded/packages/udev/udev-084/init
new file mode 100644
index 0000000000..d3983df6bc
--- /dev/null
+++ b/openembedded/packages/udev/udev-084/init
@@ -0,0 +1,227 @@
1#!/bin/sh -e
2### BEGIN INIT INFO
3# Provides: udev
4# Required-Start: mountvirtfs
5# Required-Stop:
6# Default-Start: S
7# Default-Stop:
8# Short-Description: Start udevd, populate /dev and load drivers.
9### END INIT INFO
10
11# we need to unmount /dev/pts/ and remount it later over the tmpfs
12unmount_devpts() {
13 if mountpoint -q /dev/pts/; then
14 umount -l /dev/pts/
15 fi
16
17 if mountpoint -q /dev/shm/; then
18 umount -l /dev/shm/
19 fi
20}
21
22# mount a tmpfs over /dev, if somebody did not already do it
23mount_tmpfs() {
24 if grep -E -q "^[^[:space:]]+ /dev tmpfs" /proc/mounts; then
25 return
26 fi
27
28 # /dev/.static/dev/ is used by MAKEDEV to access the real /dev/ directory.
29 # /etc/udev/ is recycled as a temporary mount point because it's the only
30 # directory which is guaranteed to be available.
31 mount -n -o bind /dev /etc/udev
32
33 if ! mount -n -o size=$tmpfs_size,mode=0755 -t tmpfs tmpfs /dev; then
34 umount /etc/udev
35 echo "udev requires tmpfs support, not started."
36 exit 1
37 fi
38
39 mkdir -p /dev/.static/dev
40 chmod 700 /dev/.static/
41 # The mount options in busybox are non-standard...
42 if test -x /bin/mount.util-linux
43 then
44 /bin/mount.util-linux --move /etc/udev /dev/.static/dev
45 elif test -x /bin/busybox
46 then
47 busybox mount -n -o move /etc/udev /dev/.static/dev
48 else
49 echo "udev requires an identifiable mount command, not started."
50 umount /etc/udev
51 umount /dev
52 exit 1
53 fi
54}
55
56# I hate this hack. -- Md
57make_extra_nodes() {
58 if [ "$(echo /lib/udev/devices/*)" != "/lib/udev/devices/*" ]; then
59 cp --preserve=all --recursive --update /lib/udev/devices/* /dev/
60 fi
61
62 [ -e /etc/udev/links.conf ] || return 0
63 grep '^[^#]' /etc/udev/links.conf | \
64 while read type name arg1; do
65 [ "$type" -a "$name" -a ! -e "/dev/$name" -a ! -L "/dev/$name" ] ||continue
66 case "$type" in
67 L) ln -s $arg1 /dev/$name ;;
68 D) mkdir -p /dev/$name ;;
69 M) mknod -m 600 /dev/$name $arg1 ;;
70 *) echo "links.conf: unparseable line ($type $name $arg1)" ;;
71 esac
72 done
73}
74
75supported_kernel() {
76 case "$(uname -r)" in
77 2.[012345].*|2.6.[0-9]|2.6.[0-9][!0-9]*) return 1 ;;
78 2.6.1[01]|2.6.1[01][!0-9]*) return 1 ;;
79 esac
80 return 0
81}
82
83set_hotplug_handler() {
84 case "$(uname -r)" in
85 2.6.1[0-4]|2.6.1[0-4][!0-9]*) HANDLER='/sbin/udevsend' ;;
86 esac
87 echo $HANDLER > /proc/sys/kernel/hotplug
88}
89
90# shell version of /usr/bin/tty
91my_tty() {
92 [ -x /bin/readlink ] || return 0
93 [ -e /proc/self/fd/0 ] || return 0
94 readlink --silent /proc/self/fd/0 || true
95}
96
97warn_if_interactive() {
98 if [ "$RUNLEVEL" = "S" -a "$PREVLEVEL" = "N" ]; then
99 return
100 fi
101
102 TTY=$(my_tty)
103 if [ -z "$TTY" -o "$TTY" = "/dev/console" ]; then
104 return
105 fi
106
107 printf "\n\n\nIt has been detected that the command\n\n\t$0 $*\n\n"
108 printf "has been run from an interactive shell.\n"
109 printf "It will probably not do what you expect, so this script will wait\n"
110 printf "60 seconds before continuing. Press ^C to stop it.\n"
111 printf "RUNNING THIS COMMAND IS HIGHLY DISCOURAGED!\n\n\n\n"
112 sleep 60
113}
114
115##############################################################################
116
117PATH="/sbin:/bin:/usr/bin"
118
119[ -x /sbin/udevd ] || exit 0
120
121# defaults
122tmpfs_size="10M"
123udev_root="/dev"
124udevd_timeout=30
125
126. /etc/udev/udev.conf
127
128if ! supported_kernel; then
129 echo "udev requires a kernel >= 2.6.12, not started."
130 exit 1
131fi
132
133if [ ! -e /proc/filesystems ]; then
134 echo "udev requires a mounted procfs, not started."
135 exit 1
136fi
137
138if ! grep -q '[[:space:]]tmpfs$' /proc/filesystems; then
139 echo "udev requires tmpfs support, not started."
140 exit 1
141fi
142
143if [ ! -d /sys/class/ ]; then
144 echo "udev requires a mounted sysfs, not started."
145 exit 1
146fi
147
148if [ ! -e /proc/sys/kernel/hotplug ]; then
149 echo "udev requires hotplug support, not started."
150 exit 1
151fi
152
153##############################################################################
154
155# When modifying this script, do not forget that between the time that
156# the new /dev has been mounted and udevsynthesize has been run there will be
157# no /dev/null. This also means that you cannot use the "&" shell command.
158
159case "$1" in
160 start)
161 if [ -e "$udev_root/.udev/" ]; then
162 if mountpoint -q /dev/; then
163 TMPFS_MOUNTED=1
164 else
165 echo ".udev/ already exists on the static $udev_root!"
166 fi
167 else
168 warn_if_interactive
169 fi
170
171 echo "Starting the hotplug events dispatcher" "udevd"
172 udevd --daemon
173
174 set_hotplug_handler
175
176 if [ -z "$TMPFS_MOUNTED" ]; then
177 unmount_devpts
178 mount_tmpfs
179 [ -d /proc/1 ] || mount -n /proc
180 fi
181
182 # if this directory is not present /dev will not be updated by udev
183 mkdir -p /dev/.udev/ /dev/.udev/db/ /dev/.udev/queue/ /dev/.udevdb/
184 # /dev/null must be created before udevd is started
185 make_extra_nodes
186
187 echo "Synthesizing the initial hotplug events"
188 udevsynthesize
189
190 # wait for the udevd childs to finish
191 echo "Waiting for /dev to be fully populated"
192 while [ -d /dev/.udev/queue/ ]; do
193 sleep 1
194 udevd_timeout=$(($udevd_timeout - 1))
195 if [ $udevd_timeout -eq 0 ]; then
196 # ps axf
197 break
198 fi
199 done
200 if [ $udevd_timeout -eq 0 ]; then
201 echo 'timeout'
202 fi
203 ;;
204
205 stop)
206 echo "Stopping the hotplug events dispatcher" "udevd"
207 start-stop-daemon --stop --name udevd --quiet --oknodo --retry 5
208 ;;
209
210 restart|force-reload)
211 echo "Stopping the hotplug events dispatcher" "udevd"
212 if start-stop-daemon --stop --name udevd --quiet --oknodo --retry 5; then
213 exit 1
214 fi
215
216 echo "Starting the hotplug events dispatcher" "udevd"
217 udevd --daemon
218 ;;
219
220 *)
221 echo "Usage: /etc/init.d/udev {start|stop|restart|force-reload}"
222 exit 1
223 ;;
224esac
225
226exit 0
227