diff options
author | Mark Hatle <mark.hatle@windriver.com> | 2013-09-17 11:48:08 -0500 |
---|---|---|
committer | Joe MacDonald <joe@deserted.net> | 2013-10-02 13:24:45 -0400 |
commit | a43e03a87c4d69c2554621394127d50f197d9eaf (patch) | |
tree | 490cfb6126e9654a0163ad392a8a62093979bf59 | |
parent | c1dc2858007322d99e3f2d646fbe0b1c6d7699b5 (diff) | |
download | meta-selinux-a43e03a87c4d69c2554621394127d50f197d9eaf.tar.gz |
udev/init: sync to latest poky version
[ CQID: WIND00424385 ]
Sync with the latest init file from poky as of 09172013. Changes include:
- adding /sbin/restorecon on start
- specifying full path for /sbin/udevadm
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Signed-off-by: Joe MacDonald <joe@deserted.net>
-rw-r--r-- | recipes-core/udev/udev/init | 158 |
1 files changed, 103 insertions, 55 deletions
diff --git a/recipes-core/udev/udev/init b/recipes-core/udev/udev/init index 5fd1011..e88bddf 100644 --- a/recipes-core/udev/udev/init +++ b/recipes-core/udev/udev/init | |||
@@ -13,74 +13,122 @@ export TZ=/etc/localtime | |||
13 | 13 | ||
14 | [ -d /sys/class ] || exit 1 | 14 | [ -d /sys/class ] || exit 1 |
15 | [ -r /proc/mounts ] || exit 1 | 15 | [ -r /proc/mounts ] || exit 1 |
16 | [ -x /sbin/udevd ] || exit 1 | 16 | [ -x @UDEVD@ ] || exit 1 |
17 | [ -f /etc/default/udev-cache ] && . /etc/default/udev-cache | 17 | [ -f /etc/default/udev-cache ] && . /etc/default/udev-cache |
18 | [ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf | 18 | [ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf |
19 | [ -f /etc/default/rcS ] && . /etc/default/rcS | ||
19 | 20 | ||
20 | readfile () { | 21 | readfiles () { |
21 | filename=$1 | ||
22 | READDATA="" | 22 | READDATA="" |
23 | if [ -r $filename ]; then | 23 | for filename in $@; do |
24 | while read line; do | 24 | if [ -r $filename ]; then |
25 | READDATA="$READDATA$line" | 25 | while read line; do |
26 | done < $filename | 26 | READDATA="$READDATA$line" |
27 | fi | 27 | done < $filename |
28 | fi | ||
29 | done | ||
28 | } | 30 | } |
29 | 31 | ||
30 | kill_udevd() { | 32 | kill_udevd () { |
31 | pid=`pidof -x udevd` | 33 | pid=`pidof -x udevd` |
32 | [ -n "$pid" ] && kill $pid | 34 | [ -n "$pid" ] && kill $pid |
33 | } | 35 | } |
34 | 36 | ||
35 | export ACTION=add | 37 | case "$1" in |
36 | # propagate /dev from /sys | 38 | start) |
37 | echo "Starting udev" | 39 | export ACTION=add |
40 | # propagate /dev from /sys | ||
41 | echo "Starting udev" | ||
38 | 42 | ||
39 | # mount the tmpfs on /dev, if not already done | 43 | # Check for requireed devtmpfs before trying to start udev and |
40 | LANG=C awk '$2 == "/dev" && ($3 == "tmpfs" || $3 == "devtmpfs") { exit 1 }' /proc/mounts && { | 44 | # mount a no-existant fs. |
41 | mount -n -o mode=0755 -t tmpfs none "/dev" | 45 | if ! grep -q devtmpfs /proc/filesystems |
42 | } | 46 | then |
43 | [ -e /dev/pts ] || mkdir -m 0755 /dev/pts | 47 | echo "Missing devtmpfs, which is required for udev to run"; |
44 | [ -e /dev/shm ] || mkdir -m 1777 /dev/shm | 48 | echo "Halting..." |
45 | 49 | halt | |
46 | # cache handling | 50 | fi |
47 | if [ "$DEVCACHE" != "" ]; then | 51 | # mount the devtmpfs on /dev, if not already done |
48 | readfile /proc/version | 52 | LANG=C awk '$2 == "/dev" && ($3 == "devtmpfs") { exit 1 }' /proc/mounts && { |
49 | VERSION="$READDATA" | 53 | mount -n -o mode=0755 -t devtmpfs none "/dev" |
50 | readfile /proc/cmdline | 54 | } |
51 | CMDLINE="$READDATA" | 55 | [ -e /dev/pts ] || mkdir -m 0755 /dev/pts |
52 | readfile /proc/devices | 56 | [ -e /dev/shm ] || mkdir -m 1777 /dev/shm |
53 | DEVICES="$READDATA" | 57 | mount -a -t tmpfs 2>/dev/null |
54 | readfile /proc/atags | 58 | mkdir -p /var/volatile/tmp |
55 | ATAGS="$READDATA" | ||
56 | |||
57 | if [ -e $DEVCACHE ]; then | ||
58 | readfile /etc/udev/cache.data | ||
59 | if [ "$READDATA" = "$VERSION$CMDLINE$DEVICES$ATAGS" ]; then | ||
60 | (cd /; tar xf $DEVCACHE > /dev/null 2>&1) | ||
61 | not_first_boot=1 | ||
62 | fi | ||
63 | 59 | ||
64 | echo "$VERSION$CMDLINE$DEVICES$ATAGS" > /dev/shm/udev.cache | 60 | # Cache handling. |
65 | fi | 61 | # A list of files which are used as a criteria to judge whether the udev cache could be reused. |
66 | fi | 62 | CMP_FILE_LIST="/proc/version /proc/cmdline /proc/devices /proc/atags" |
63 | if [ "$DEVCACHE" != "" ]; then | ||
64 | if [ -e $DEVCACHE ]; then | ||
65 | readfiles $CMP_FILE_LIST | ||
66 | NEWDATA="$READDATA" | ||
67 | readfiles /etc/udev/cache.data | ||
68 | OLDDATA="$READDATA" | ||
69 | if [ "$OLDDATA" = "$NEWDATA" ]; then | ||
70 | (cd /; tar xf $DEVCACHE > /dev/null 2>&1) | ||
71 | not_first_boot=1 | ||
72 | [ "$VERBOSE" != "no" ] && echo "udev: using cache file $DEVCACHE" | ||
73 | [ -e /dev/shm/udev.cache ] && rm -f /dev/shm/udev.cache | ||
74 | else | ||
75 | # Output detailed reason why the cached /dev is not used | ||
76 | if [ "$VERBOSE" != "no" ]; then | ||
77 | echo "udev: udev cache not used" | ||
78 | echo "udev: we use $CMP_FILE_LIST as criteria to judge whether the cache /dev could be resued" | ||
79 | echo "udev: olddata: $OLDDATA" | ||
80 | echo "udev: newdata: $NEWDATA" | ||
81 | fi | ||
82 | echo "$NEWDATA" > /dev/shm/udev.cache | ||
83 | fi | ||
84 | else | ||
85 | if [ "$ROOTFS_READ_ONLY" != "yes" ]; then | ||
86 | # If rootfs is not read-only, it's possible that a new udev cache would be generated; | ||
87 | # otherwise, we do not bother to read files. | ||
88 | readfiles $CMP_FILE_LIST | ||
89 | echo "$READDATA" > /dev/shm/udev.cache | ||
90 | fi | ||
91 | fi | ||
92 | fi | ||
67 | 93 | ||
68 | # make_extra_nodes | 94 | # make_extra_nodes |
69 | kill_udevd > "/dev/null" 2>&1 | 95 | kill_udevd > "/dev/null" 2>&1 |
70 | 96 | ||
71 | # trigger the sorted events | 97 | # trigger the sorted events |
72 | echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug | 98 | echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug |
73 | /sbin/udevd -d | 99 | @UDEVD@ -d |
74 | 100 | ||
75 | /sbin/udevadm control --env=STARTUP=1 | 101 | /usr/bin/udevadm control --env=STARTUP=1 |
76 | if [ "$not_first_boot" != "" ];then | 102 | if [ "$not_first_boot" != "" ];then |
77 | /sbin/udevadm trigger --action=add --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 | 103 | /usr/bin/udevadm trigger --action=add --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 |
78 | (/sbin/udevadm settle --timeout=3; /sbin/udevadm control --env=STARTUP=)& | 104 | (/usr/bin/udevadm settle --timeout=3; /usr/bin/udevadm control --env=STARTUP=)& |
79 | else | 105 | else |
80 | /sbin/udevadm trigger --action=add | 106 | /usr/bin/udevadm trigger --action=add |
81 | /sbin/udevadm settle | 107 | /usr/bin/udevadm settle |
82 | fi | 108 | fi |
83 | 109 | ||
84 | test ! -x /sbin/restorecon || /sbin/restorecon -F /dev | 110 | test ! -x /sbin/restorecon || /sbin/restorecon -F /dev |
85 | 111 | ||
112 | ;; | ||
113 | stop) | ||
114 | echo "Stopping udevd" | ||
115 | start-stop-daemon --stop --name udevd --quiet | ||
116 | ;; | ||
117 | restart) | ||
118 | $0 stop | ||
119 | sleep 1 | ||
120 | $0 start | ||
121 | ;; | ||
122 | status) | ||
123 | pid=`pidof -x udevd` | ||
124 | if [ -n "$pid" ]; then | ||
125 | echo "udevd (pid $pid) is running ..." | ||
126 | else | ||
127 | echo "udevd is stopped" | ||
128 | fi | ||
129 | ;; | ||
130 | *) | ||
131 | echo "Usage: $0 {start|stop|status|restart}" | ||
132 | exit 1 | ||
133 | esac | ||
86 | exit 0 | 134 | exit 0 |