summaryrefslogtreecommitdiffstats
path: root/meta/packages
diff options
context:
space:
mode:
authorMarcin Juszkiewicz <hrw@openedhand.com>2008-07-02 15:38:04 +0000
committerMarcin Juszkiewicz <hrw@openedhand.com>2008-07-02 15:38:04 +0000
commit398512ef6e250dbc78a0ce55427b45f4896c61b4 (patch)
tree60e46a0400e1819564ddb1ffc396b5000def6d50 /meta/packages
parent5e2864a274fe9738d752c857e505d3cd046290e6 (diff)
downloadpoky-398512ef6e250dbc78a0ce55427b45f4896c61b4.tar.gz
udev: use init script from OLPC
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@4788 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/packages')
-rw-r--r--meta/packages/udev/udev-115/init254
1 files changed, 38 insertions, 216 deletions
diff --git a/meta/packages/udev/udev-115/init b/meta/packages/udev/udev-115/init
index f3eaaf0ffe..5711d74b40 100644
--- a/meta/packages/udev/udev-115/init
+++ b/meta/packages/udev/udev-115/init
@@ -1,227 +1,49 @@
1#!/bin/sh -e 1export TZ=/etc/localtime
2### BEGIN INIT INFO 2
3# Provides: udev 3[ -d /sys/class ] || exit 1
4# Required-Start: mountvirtfs 4[ -r /proc/mounts ] || exit 1
5# Required-Stop: 5[ -x /sbin/udevd ] || exit 1
6# Default-Start: S 6[ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf
7# Default-Stop: 7
8# Short-Description: Start udevd, populate /dev and load drivers. 8kill_udevd() {
9### END INIT INFO 9 if [ -x /sbin/pidof ]; then
10 10 pid=`/sbin/pidof -x udevd`
11# we need to unmount /dev/pts/ and remount it later over the tmpfs 11 [ -n "$pid" ] && kill $pid
12unmount_devpts() { 12 fi
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} 13}
21 14
22# mount a tmpfs over /dev, if somebody did not already do it 15export ACTION=add
23mount_tmpfs() { 16# propagate /dev from /sys
24 if grep -E -q "^[^[:space:]]+ /dev tmpfs" /proc/mounts; then 17echo -n "Starting udev"
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 -a /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 18
83set_hotplug_handler() { 19# mount the tmpfs on /dev, if not already done
84 case "$(uname -r)" in 20LANG=C awk "\$2 == \"/dev\" && \$4 == \"tmpfs\" { exit 1 }" /proc/mounts && {
85 2.6.1[0-4]|2.6.1[0-4][!0-9]*) HANDLER='/sbin/udevsend' ;; 21 mount -n -o mode=0755 -t tmpfs none "/dev"
86 esac 22 mkdir -m 0755 /dev/pts
87 echo $HANDLER > /proc/sys/kernel/hotplug 23 mkdir -m 0755 /dev/shm
88} 24}
89 25
90# shell version of /usr/bin/tty 26if [ -e /etc/dev.tar ]; then
91my_tty() { 27 (cd /; tar xf /etc/dev.tar)
92 [ -x /bin/readlink ] || return 0 28 not_first_boot=1
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 29fi
142 30
143if [ ! -d /sys/class/ ]; then 31# make_extra_nodes
144 echo "udev requires a mounted sysfs, not started." 32kill_udevd > "/dev/null" 2>&1
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 33
159case "$1" in 34 # trigger the sorted events
160 start) 35 echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug
161 if [ -e "$udev_root/.udev/" ]; then 36 /sbin/udevd -d
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 37
171 echo "Starting the hotplug events dispatcher" "udevd" 38 /sbin/udevcontrol env STARTUP=1
172 udevd --daemon 39 if [ "$not_first_boot" != "" ];then
173 40 /sbin/udevtrigger --subsystem-nomatch=tty --subsystem-nomatch=mem --subsystem-nomatch=vc --subsystem-nomatch=vtconsole --subsystem-nomatch=misc --subsystem-nomatch=dcon --subsystem-nomatch=pci_bus --subsystem-nomatch=graphics --subsystem-nomatch=backlight --subsystem-nomatch=video4linux --subsystem-nomatch=platform
174 set_hotplug_handler 41 (/sbin/udevsettle --timeout=3; /sbin/udevcontrol env STARTUP=)&
175 42 else
176 if [ -z "$TMPFS_MOUNTED" ]; then 43 /sbin/udevtrigger
177 unmount_devpts 44 /sbin/udevsettle
178 mount_tmpfs 45 (cd /; tar cf /etc/dev.tar /dev)
179 [ -d /proc/1 ] || mount -n /proc 46 fi
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 udevtrigger
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
208 ;;
209
210 restart|force-reload)
211 echo "Stopping the hotplug events dispatcher" "udevd"
212 if start-stop-daemon --stop --name udevd --quiet ; 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 47
48echo
226exit 0 49exit 0
227