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