Gentoo Archives: gentoo-commits

From: "Matthias Schwarzott (zzam)" <zzam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in sys-fs/udev/files: udev-start-126.sh
Date: Wed, 27 Aug 2008 21:10:14
Message-Id: E1KYSHL-0001eH-Sc@stork.gentoo.org
1 zzam 08/08/27 21:10:11
2
3 Added: udev-start-126.sh
4 Log:
5 Silence errors from modprobe unix.
6 (Portage version: 2.2_rc8/cvs/Linux 2.6.25-tuxonice-r6 i686)
7
8 Revision Changes Path
9 1.1 sys-fs/udev/files/udev-start-126.sh
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/udev-start-126.sh?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/udev-start-126.sh?rev=1.1&content-type=text/plain
13
14 Index: udev-start-126.sh
15 ===================================================================
16 # Copyright 1999-2007 Gentoo Foundation
17 # Distributed under the terms of the GNU General Public License v2
18
19 [ -e /etc/udev/udev.conf ] && . /etc/udev/udev.conf
20 . /lib/udev/shell-compat.sh
21
22 rc_coldplug=${rc_coldplug:-${RC_COLDPLUG:-YES}}
23 rc_device_tarball=${rc_device_tarball:-${RC_DEVICE_TARBALL:-NO}}
24
25 cleanup()
26 {
27 # fail more gracely and not leave udevd running
28 start-stop-daemon --stop --exec /sbin/udevd
29 exit 1
30 }
31
32 # FIXME
33 # Instead of this script testing kernel version, udev itself should
34 # Maybe something like udevd --test || exit $?
35 check_kernel()
36 {
37 if [ $(get_KV) -lt $(KV_to_int '2.6.15') ]; then
38 eerror "Your kernel is too old to work with this version of udev."
39 eerror "Current udev only supports Linux kernel 2.6.15 and newer."
40 return 1
41 fi
42 if [ $(get_KV) -lt $(KV_to_int '2.6.18') ]; then
43 ewarn "You need at least Linux kernel 2.6.18 for reliable operation of udev."
44 fi
45 return 0
46 }
47
48
49 mount_dev_directory()
50 {
51 # No options are processed here as they should all be in /etc/fstab
52 ebegin "Mounting /dev"
53 if fstabinfo --quiet /dev; then
54 mount -n /dev
55 else
56 # Some devices require exec, Bug #92921
57 mount -n -t tmpfs -o "exec,nosuid,mode=0755,size=10M" udev /dev
58 fi
59 eend $?
60 }
61
62 unpack_device_tarball()
63 {
64 local device_tarball=/lib/udev/state/devices.tar.bz2
65 if yesno "${rc_device_tarball}" && \
66 [ -s "${device_tarball}" ]
67 then
68 ebegin "Populating /dev with saved device nodes"
69 tar -jxpf "${device_tarball}" -C /dev
70 eend $?
71 fi
72 }
73
74 seed_dev()
75 {
76 # Seed /dev with some things that we know we need
77
78 # creating /dev/console and /dev/tty1 to be able to write
79 # to $CONSOLE with/without bootsplash before udevd creates it
80 [ -c /dev/console ] || mknod /dev/console c 5 1
81 [ -c /dev/tty1 ] || mknod /dev/tty1 c 4 1
82
83 # udevd will dup its stdin/stdout/stderr to /dev/null
84 # and we do not want a file which gets buffered in ram
85 [ -c /dev/null ] || mknod /dev/null c 1 3
86
87 # copy over any persistant things
88 if [ -d /lib/udev/devices ]; then
89 cp -RPp /lib/udev/devices/* /dev 2>/dev/null
90 fi
91
92 # Not provided by sysfs but needed
93 ln -snf /proc/self/fd /dev/fd
94 ln -snf fd/0 /dev/stdin
95 ln -snf fd/1 /dev/stdout
96 ln -snf fd/2 /dev/stderr
97 [ -e /proc/kcore ] && ln -snf /proc/kcore /dev/core
98
99 # Create problematic directories
100 mkdir -p /dev/pts /dev/shm
101 return 0
102 }
103
104 disable_hotplug_agent()
105 {
106 if [ -e /proc/sys/kernel/hotplug ]; then
107 echo "" >/proc/sys/kernel/hotplug
108 fi
109 }
110
111 root_link()
112 {
113 /lib/udev/write_root_link_rule
114 }
115
116 start_udevd()
117 {
118 # load unix domain sockets if built as module, Bug #221253
119 if [ -e /proc/modules ] ; then
120 modprobe -q unix 2>/dev/null
121 fi
122 ebegin "Starting udevd"
123 start-stop-daemon --start --exec /sbin/udevd -- --daemon
124 eend $?
125 }
126
127 # populate /dev with devices already found by the kernel
128 populate_dev()
129 {
130 if get_bootparam "nocoldplug" ; then
131 rc_coldplug="NO"
132 ewarn "Skipping udev coldplug as requested in kernel cmdline"
133 fi
134
135 ebegin "Populating /dev with existing devices through uevents"
136 if yesno "${rc_coldplug}"; then
137 udevadm trigger
138 else
139 # Do not run any init-scripts, Bug #206518
140 udevadm control --env do_not_run_plug_service=1
141
142 # only create device nodes
143 udevadm trigger --attr-match=dev
144
145 # run persistent-net stuff, bug 191466
146 udevadm trigger --subsystem-match=net
147 fi
148 eend $?
149
150 ebegin "Waiting for uevents to be processed"
151 udevadm settle --timeout=60
152 eend $?
153
154 udevadm control --env do_not_run_plug_service=
155 return 0
156 }
157
158 compat_volume_nodes()
159 {
160 # Only do this for baselayout-1*
161 if [ ! -e /lib/librc.so ]; then
162
163 # Create nodes that udev can't
164 [ -x /sbin/lvm ] && \
165 /sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null
166 # Running evms_activate on a LiveCD causes lots of headaches
167 [ -z "${CDBOOT}" -a -x /sbin/evms_activate ] && \
168 /sbin/evms_activate -q &>/dev/null
169 fi
170 }
171
172 check_persistent_net()
173 {
174 # check if there are problems with persistent-net
175 local syspath= devs= problem=false
176 for syspath in /sys/class/net/*_rename*; do
177 if [ -d "${syspath}" ]; then
178 devs="${devs} ${syspath##*/}"
179 problem=true
180 fi
181 done
182
183 ${problem} || return 0
184
185 eerror "UDEV: Your system has a problem assigning persistent names"
186 eerror "to these network interfaces: ${devs}"
187
188 einfo "Checking persistent-net rules:"
189 # the sed-expression lists all duplicate lines
190 # from the input, like "uniq -d" does, but uniq
191 # is installed into /usr/bin and not available at boot.
192 dups=$(
193 RULES_FILE='/etc/udev/rules.d/70-persistent-net.rules'
194 . /lib/udev/rule_generator.functions
195 find_all_rules 'NAME=' '.*' | \
196 tr ' ' '\n' | \
197 sort | \
198 sed '$!N; s/^\(.*\)\n\1$/\1/; t; D'
199 )
200 if [ -n "${dups}" ]; then
201 ewarn "The rules create multiple entries assigning these names:"
202 eindent
203 ewarn "${dups}"
204 eoutdent
205 else
206 ewarn "Found no duplicate names in persistent-net rules,"
207 ewarn "there must be some other problem!"
208 fi
209 return 1
210 }
211
212 check_udev_works()
213 {
214 # should exist on every system, else udev failed
215 if [ ! -e /dev/zero ]; then
216 eerror "Assuming udev failed somewhere, as /dev/zero does not exist."
217 return 1
218 fi
219 return 0
220 }
221
222
223
224 check_kernel || cleanup
225 mount_dev_directory || cleanup
226
227 # Create a file so that our rc system knows it's still in sysinit.
228 # Existance means init scripts will not directly run.
229 # rc will remove the file when done with sysinit.
230 touch /dev/.rcsysinit
231
232 # Selinux lovin; /selinux should be mounted by selinux-patched init
233 if [ -x /sbin/restorecon -a -c /selinux/null ]; then
234 restorecon /dev > /selinux/null
235 fi
236
237 unpack_device_tarball
238 seed_dev
239 root_link
240 disable_hotplug_agent
241
242 start_udevd || cleanup
243 populate_dev || cleanup
244
245 compat_volume_nodes
246 check_persistent_net
247
248 # trigger executing initscript when /etc is writable
249 IN_HOTPLUG=1 /etc/init.d/udev-postmount start >/dev/null 2>&1
250
251 check_udev_works || cleanup
252
253 # udev started successfully
254 exit 0