1 |
zzam 10/05/05 19:35:07 |
2 |
|
3 |
Added: shell-compat-KV.sh udev-postmount.initd udev.initd |
4 |
udev-stop.sh udev.confd udev-start.sh |
5 |
udev-dev-tarball.initd shell-compat-addon.sh |
6 |
udev-mount.initd |
7 |
Log: |
8 |
Updated init-scripts. Now support setting debug and trace options in config file. Explicitly send add-event for initial population (newer udevds will default to change). Set property STARTUP while booting for compatibility with new eg. lvm2 init-scripts. Sync udev-9999.ebuild. |
9 |
(Portage version: 2.1.8.3/cvs/Linux x86_64) |
10 |
|
11 |
Revision Changes Path |
12 |
1.1 sys-fs/udev/files/151-r4/shell-compat-KV.sh |
13 |
|
14 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/151-r4/shell-compat-KV.sh?rev=1.1&view=markup |
15 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/151-r4/shell-compat-KV.sh?rev=1.1&content-type=text/plain |
16 |
|
17 |
Index: shell-compat-KV.sh |
18 |
=================================================================== |
19 |
# Copyright 1999-2008 Gentoo Foundation |
20 |
# Distributed under the terms of the GNU General Public License v2 |
21 |
|
22 |
# provides get_KV and KV_to_int as not all openrc-versions installed via ebuild have these |
23 |
|
24 |
cmd_exist() |
25 |
{ |
26 |
type "$1" >/dev/null 2>&1 |
27 |
} |
28 |
|
29 |
# does exist in baselayout-1 |
30 |
# does not exist in openrc, but is added by openrc-ebuild since some time |
31 |
if ! cmd_exist KV_to_int; then |
32 |
KV_to_int() { |
33 |
[ -z $1 ] && return 1 |
34 |
|
35 |
local x=${1%%-*} |
36 |
local KV_MAJOR=${x%%.*} |
37 |
x=${x#*.} |
38 |
local KV_MINOR=${x%%.*} |
39 |
x=${x#*.} |
40 |
local KV_MICRO=${x%%.*} |
41 |
local KV_int=$((${KV_MAJOR} * 65536 + ${KV_MINOR} * 256 + ${KV_MICRO} )) |
42 |
|
43 |
# We make version 2.2.0 the minimum version we will handle as |
44 |
# a sanity check ... if its less, we fail ... |
45 |
[ "${KV_int}" -lt 131584 ] && return 1 |
46 |
|
47 |
echo "${KV_int}" |
48 |
} |
49 |
fi |
50 |
|
51 |
# same as KV_to_int |
52 |
if ! cmd_exist get_KV; then |
53 |
_RC_GET_KV_CACHE="" |
54 |
get_KV() { |
55 |
[ -z "${_RC_GET_KV_CACHE}" ] \ |
56 |
&& _RC_GET_KV_CACHE="$(uname -r)" |
57 |
|
58 |
echo "$(KV_to_int "${_RC_GET_KV_CACHE}")" |
59 |
|
60 |
return $? |
61 |
} |
62 |
fi |
63 |
|
64 |
|
65 |
|
66 |
|
67 |
1.1 sys-fs/udev/files/151-r4/udev-postmount.initd |
68 |
|
69 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/151-r4/udev-postmount.initd?rev=1.1&view=markup |
70 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/151-r4/udev-postmount.initd?rev=1.1&content-type=text/plain |
71 |
|
72 |
Index: udev-postmount.initd |
73 |
=================================================================== |
74 |
#!/sbin/runscript |
75 |
# Copyright 1999-2007 Gentoo Foundation |
76 |
# Distributed under the terms of the GNU General Public License v2 |
77 |
# $Header: /var/cvsroot/gentoo-x86/sys-fs/udev/files/151-r4/udev-postmount.initd,v 1.1 2010/05/05 19:35:07 zzam Exp $ |
78 |
|
79 |
depend() { |
80 |
need localmount |
81 |
after dbus # for trigger failed |
82 |
} |
83 |
|
84 |
dir_writeable() |
85 |
{ |
86 |
mkdir "$1"/.test.$$ 2>/dev/null && rmdir "$1"/.test.$$ |
87 |
} |
88 |
|
89 |
start() { |
90 |
# check if this system uses udev |
91 |
[ -d /dev/.udev/ ] || return 0 |
92 |
|
93 |
# Run the events that failed at first udev trigger |
94 |
udevadm trigger --type=failed -v |
95 |
|
96 |
# only continue if rules-directory is writable |
97 |
dir_writeable /etc/udev/rules.d || return 0 |
98 |
|
99 |
# store persistent-rules that got created while booting |
100 |
# when / was still read-only |
101 |
/lib/udev/move_tmp_persistent_rules.sh |
102 |
} |
103 |
|
104 |
stop() { |
105 |
: |
106 |
} |
107 |
|
108 |
# vim:ts=4 |
109 |
|
110 |
|
111 |
|
112 |
1.1 sys-fs/udev/files/151-r4/udev.initd |
113 |
|
114 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/151-r4/udev.initd?rev=1.1&view=markup |
115 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/151-r4/udev.initd?rev=1.1&content-type=text/plain |
116 |
|
117 |
Index: udev.initd |
118 |
=================================================================== |
119 |
#!/sbin/runscript |
120 |
# Copyright 1999-2008 Gentoo Foundation |
121 |
# Distributed under the terms of the GNU General Public License v2 |
122 |
|
123 |
description="Run udevd and create the device-nodes" |
124 |
|
125 |
[ -e /etc/udev/udev.conf ] && . /etc/udev/udev.conf |
126 |
|
127 |
rc_coldplug=${rc_coldplug:-${RC_COLDPLUG:-YES}} |
128 |
|
129 |
depend() |
130 |
{ |
131 |
if [ -f /etc/init.d/sysfs ]; then |
132 |
# require new enough openrc with sysinit being extra runlevel |
133 |
# on linux we just check if sysfs init-script exists |
134 |
# this is to silence out ugly warnings about not-existing sysfs script |
135 |
provide dev |
136 |
if yesno "${rc_device_tarball:-no}"; then |
137 |
need sysfs udev-mount udev-dev-tarball |
138 |
else |
139 |
need sysfs udev-mount |
140 |
fi |
141 |
before checkfs fsck |
142 |
|
143 |
# udev does not work inside vservers |
144 |
keyword novserver nolxc noopenvz |
145 |
fi |
146 |
} |
147 |
|
148 |
cleanup() |
149 |
{ |
150 |
# fail more gracely and not leave udevd running |
151 |
start-stop-daemon --stop --exec /sbin/udevd |
152 |
exit 1 |
153 |
} |
154 |
|
155 |
disable_hotplug_agent() |
156 |
{ |
157 |
if [ -e /proc/sys/kernel/hotplug ]; then |
158 |
echo "" >/proc/sys/kernel/hotplug |
159 |
fi |
160 |
} |
161 |
|
162 |
root_link() |
163 |
{ |
164 |
/lib/udev/write_root_link_rule |
165 |
} |
166 |
|
167 |
rules_disable_switch() |
168 |
{ |
169 |
# this function disables rules files |
170 |
# by creating new files with the same name |
171 |
# in a temp rules directory with higher priority |
172 |
local f=/dev/.udev/rules.d/"$1" bname="$1" onoff="$2" |
173 |
|
174 |
if yesno "${onoff}"; then |
175 |
echo "# This file disables ${bname} due to /etc/conf.d/udev" \ |
176 |
> "${f}" |
177 |
else |
178 |
rm -f "${f}" |
179 |
fi |
180 |
} |
181 |
|
182 |
# only called on openrc |
183 |
is_service_enabled() { |
184 |
local svc="$1" |
185 |
|
186 |
[ ! -e "/etc/init.d/${svc}" ] && return 1 |
187 |
|
188 |
[ -e "/etc/runlevels/${RC_BOOTLEVEL}/${svc}" ] && return 0 |
189 |
[ -e "/etc/runlevels/${RC_DEFAULTLEVEL}/${svc}" ] && return 0 |
190 |
return 1 |
191 |
} |
192 |
|
193 |
check_openrc_net() |
194 |
{ |
195 |
local f=/dev/.udev/rules.d/90-network.rules |
196 |
is_service_enabled network || return 0 |
197 |
|
198 |
# disable network hotplugging |
199 |
echo "# This file disables network hotplug events calling old-style openrc net scripts" >> "${f}" |
200 |
echo "# as we use new-style network init script /etc/init.d/network" >> "${f}" |
201 |
} |
202 |
|
203 |
start_udevd() |
204 |
{ |
205 |
# load unix domain sockets if built as module, Bug #221253 |
206 |
if [ -e /proc/modules ] ; then |
207 |
modprobe -q unix 2>/dev/null |
208 |
fi |
209 |
local opts="" |
210 |
yesno "${udev_trace:-no}" && opts="${opts} --debug-trace" |
211 |
|
212 |
ebegin "Starting udevd" |
213 |
if yesno "${udev_debug:-no}"; then |
214 |
/sbin/udevd --daemon ${opts} --debug 2>/dev/.udev/udev.log |
215 |
else |
216 |
start-stop-daemon --start --exec /sbin/udevd -- --daemon ${opts} |
217 |
fi |
218 |
|
219 |
eend $? |
220 |
} |
221 |
|
222 |
# populate /dev with devices already found by the kernel |
223 |
populate_dev() |
224 |
{ |
225 |
if get_bootparam "nocoldplug" ; then |
226 |
rc_coldplug="NO" |
227 |
ewarn "Skipping udev coldplug as requested in kernel cmdline" |
228 |
fi |
229 |
|
230 |
ebegin "Populating /dev with existing devices through uevents" |
231 |
udevadm control --property=STARTUP=1 |
232 |
if yesno "${rc_coldplug}"; then |
233 |
udevadm trigger --action="add" |
234 |
else |
235 |
# Do not run any init-scripts, Bug #206518 |
236 |
udevadm control --property=do_not_run_plug_service=1 |
237 |
|
238 |
# only create device nodes |
239 |
udevadm trigger --action="add" --attr-match=dev |
240 |
|
241 |
# run persistent-net stuff, bug 191466 |
242 |
udevadm trigger --action="add" --subsystem-match=net |
243 |
fi |
244 |
eend $? |
245 |
|
246 |
# we can speed up booting under these conditions: |
247 |
# * using devtmpfs so kernel creates device nodes for us |
248 |
# * only using kernel created device nodes at boot (in /etc/fstab and elsewhere) |
249 |
# |
250 |
ebegin "Waiting for uevents to be processed" |
251 |
udevadm settle --timeout=${udev_settle_timeout:-60} |
252 |
eend $? |
253 |
|
254 |
udevadm control --property=do_not_run_plug_service= |
255 |
udevadm control --property=STARTUP= |
256 |
return 0 |
257 |
} |
258 |
|
259 |
# for debugging |
260 |
start_udevmonitor() |
261 |
{ |
262 |
yesno "${udev_monitor:-no}" || return 0 |
263 |
|
264 |
udevmonitor_log=/dev/.udev/udevmonitor.log |
265 |
udevmonitor_pid=/dev/.udev/udevmonitor.pid |
266 |
|
267 |
einfo "udev: Running udevadm monitor ${udev_monitor_opts} to get a log of all events" |
268 |
start-stop-daemon --start --stdout "${udevmonitor_log}" \ |
269 |
--make-pidfile --pidfile "${udevmonitor_pid}" \ |
270 |
--background --exec /sbin/udevadm -- monitor ${udev_monitor_opts} |
271 |
} |
272 |
|
273 |
stop_udevmonitor() |
274 |
{ |
275 |
yesno "${udev_monitor:-no}" || return 0 |
276 |
|
277 |
if yesno "${udev_monitor_keep_running:-no}"; then |
278 |
ewarn "udev: udevmonitor is still running and writing into ${udevmonitor_log}" |
279 |
else |
280 |
einfo "udev: Stopping udevmonitor: Log is in ${udevmonitor_log}" |
281 |
start-stop-daemon --stop --pidfile "${udevmonitor_pid}" --exec /sbin/udevadm |
282 |
fi |
283 |
} |
284 |
|
285 |
display_hotplugged_services() { |
286 |
local svcfile= svc= services= |
287 |
for svcfile in "${RC_SVCDIR}"/hotplugged/*; do |
288 |
svc="${svcfile##*/}" |
289 |
[ -x "${svcfile}" ] || continue |
290 |
|
291 |
services="${services} ${svc}" |
292 |
done |
293 |
[ -n "${services}" ] && einfo "Device initiated services:${HILITE}${services}${NORMAL}" |
294 |
} |
295 |
|
296 |
check_persistent_net() |
297 |
{ |
298 |
# check if there are problems with persistent-net |
299 |
local syspath= devs= problem=false |
300 |
for syspath in /sys/class/net/*_rename*; do |
301 |
if [ -d "${syspath}" ]; then |
302 |
devs="${devs} ${syspath##*/}" |
303 |
problem=true |
304 |
fi |
305 |
done |
306 |
|
307 |
${problem} || return 0 |
308 |
|
309 |
eerror "UDEV: Your system has a problem assigning persistent names" |
310 |
eerror "to these network interfaces: ${devs}" |
311 |
|
312 |
einfo "Checking persistent-net rules:" |
313 |
# the sed-expression lists all duplicate lines |
314 |
# from the input, like "uniq -d" does, but uniq |
315 |
# is installed into /usr/bin and not available at boot. |
316 |
dups=$( |
317 |
RULES_FILE='/etc/udev/rules.d/70-persistent-net.rules' |
318 |
. /lib/udev/rule_generator.functions |
319 |
find_all_rules 'NAME=' '.*' | \ |
320 |
tr ' ' '\n' | \ |
321 |
sort | \ |
322 |
sed '$!N; s/^\(.*\)\n\1$/\1/; t; D' |
323 |
) |
324 |
if [ -n "${dups}" ]; then |
325 |
ewarn "The rules create multiple entries assigning these names:" |
326 |
eindent |
327 |
ewarn "${dups}" |
328 |
eoutdent |
329 |
else |
330 |
ewarn "Found no duplicate names in persistent-net rules," |
331 |
ewarn "there must be some other problem!" |
332 |
fi |
333 |
return 1 |
334 |
} |
335 |
|
336 |
check_udev_works() |
337 |
{ |
338 |
# should exist on every system, else udev failed |
339 |
if [ ! -e /dev/zero ]; then |
340 |
eerror "Assuming udev failed somewhere, as /dev/zero does not exist." |
341 |
return 1 |
342 |
fi |
343 |
return 0 |
344 |
} |
345 |
|
346 |
start() |
347 |
{ |
348 |
# do not run this on old baselayout where udev-addon gets loaded |
349 |
if [ ! -f /etc/init.d/sysfs ]; then |
350 |
eerror "The $SVCNAME init-script is written for baselayout-2!" |
351 |
eerror "Please do not use it with baselayout-1!". |
352 |
return 1 |
353 |
fi |
354 |
|
355 |
check_openrc_net |
356 |
_start |
357 |
|
358 |
display_hotplugged_services |
359 |
|
360 |
return 0 |
361 |
} |
362 |
|
363 |
_start() |
364 |
{ |
365 |
if [ ! -e /etc/runlevels/${RC_DEFAULTLEVEL:-default}/udev-postmount ]; then |
366 |
ewarn "You should add udev-postmount service to your default runlevel." |
367 |
fi |
368 |
|
369 |
root_link |
370 |
rules_disable_switch 75-persistent-net-generator.rules "${persistent_net_disable:-no}" |
371 |
rules_disable_switch 75-cd-aliases-generator.rules ${persistent_cd_disable:-no} |
372 |
|
373 |
disable_hotplug_agent |
374 |
start_udevd || cleanup |
375 |
start_udevmonitor |
376 |
populate_dev || cleanup |
377 |
|
378 |
check_persistent_net |
379 |
|
380 |
check_udev_works || cleanup |
381 |
stop_udevmonitor |
382 |
|
383 |
return 0 |
384 |
} |
385 |
|
386 |
stop() { |
387 |
ebegin "Stopping udevd" |
388 |
start-stop-daemon --stop --exec /sbin/udevd |
389 |
eend $? |
390 |
} |
391 |
|
392 |
|
393 |
|
394 |
|
395 |
1.1 sys-fs/udev/files/151-r4/udev-stop.sh |
396 |
|
397 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/151-r4/udev-stop.sh?rev=1.1&view=markup |
398 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/151-r4/udev-stop.sh?rev=1.1&content-type=text/plain |
399 |
|
400 |
Index: udev-stop.sh |
401 |
=================================================================== |
402 |
# Copyright 1999-2007 Gentoo Foundation |
403 |
# Distributed under the terms of the GNU General Public License v2 |
404 |
|
405 |
# for function yesno |
406 |
. /lib/udev/shell-compat-addon.sh |
407 |
|
408 |
# store device tarball |
409 |
( |
410 |
. /etc/init.d/udev-dev-tarball |
411 |
stop |
412 |
) |
413 |
|
414 |
exit 0 |
415 |
|
416 |
|
417 |
|
418 |
1.1 sys-fs/udev/files/151-r4/udev.confd |
419 |
|
420 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/151-r4/udev.confd?rev=1.1&view=markup |
421 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/151-r4/udev.confd?rev=1.1&content-type=text/plain |
422 |
|
423 |
Index: udev.confd |
424 |
=================================================================== |
425 |
# /etc/conf.d/udev: config file for udev |
426 |
|
427 |
# We discourage to disable persistent-net!! |
428 |
# this may lead to random interface naming |
429 |
|
430 |
# Disable adding new rules for persistent-net |
431 |
persistent_net_disable="no" |
432 |
|
433 |
# Disable adding new rules for persistent-cd |
434 |
# Disabling this will stop new cdrom devices to appear |
435 |
# as /dev/{cdrom,cdrw,dvd,dvdrw} |
436 |
persistent_cd_disable="no" |
437 |
|
438 |
# Set to "yes" if you want to save /dev to a tarball on shutdown |
439 |
# and restore it on startup. This is useful if you have a lot of |
440 |
# custom device nodes that udev does not handle/know about. |
441 |
# |
442 |
# As this option is fragile, we recommend you |
443 |
# to create your devices in /lib/udev/devices. |
444 |
# These will be copied to /dev on boot. |
445 |
#rc_device_tarball="NO" |
446 |
|
447 |
# udev can trigger coldplug events which cause services to start and |
448 |
# kernel modules to be loaded. |
449 |
# Services are deferred to start in the boot runlevel. |
450 |
# Set rc_coldplug="NO" if you don't want this. |
451 |
# If you want module coldplugging but not coldplugging of services then you |
452 |
# can disable service coldplugging in baselayout/openrc config files. |
453 |
# The setting is named different in different versions. |
454 |
# in /etc/rc.conf: rc_hotplug="!*" or |
455 |
# in /etc/conf.d/rc: rc_plug_services="!*" |
456 |
#rc_coldplug="YES" |
457 |
|
458 |
|
459 |
|
460 |
|
461 |
# Expert options: |
462 |
|
463 |
# Disable warning about unreliable kernel/udev combination |
464 |
#unreliable_kernel_warning="no" |
465 |
|
466 |
# Timeout in seconds to wait for processing of uevents at boot. |
467 |
# There should be no need to change this. |
468 |
#udev_settle_timeout="60" |
469 |
|
470 |
# Run udevd so that all events are serialized, read more in man udevd at --debug-trace |
471 |
#udev_trace="YES" |
472 |
|
473 |
# Run udevd --debug and write output to /dev/.udev/udev.log |
474 |
# Should not be kept on as it fills diskspace slowly |
475 |
#udev_debug="YES" |
476 |
|
477 |
# Run udevadmin monitor to get a log of all events |
478 |
# in /dev/.udev/udevmonitor.log |
479 |
#udev_monitor="YES" |
480 |
|
481 |
# Keep udevmonitor running after populating /dev. |
482 |
#udev_monitor_keep_running="no" |
483 |
|
484 |
# Set cmdline options for udevmonitor. |
485 |
# could be some of --env --kernel --udev |
486 |
#udev_monitor_opts="--env" |
487 |
|
488 |
|
489 |
|
490 |
|
491 |
1.1 sys-fs/udev/files/151-r4/udev-start.sh |
492 |
|
493 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/151-r4/udev-start.sh?rev=1.1&view=markup |
494 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/151-r4/udev-start.sh?rev=1.1&content-type=text/plain |
495 |
|
496 |
Index: udev-start.sh |
497 |
=================================================================== |
498 |
# Copyright 1999-2007 Gentoo Foundation |
499 |
# Distributed under the terms of the GNU General Public License v2 |
500 |
|
501 |
[ -e /etc/conf.d/udev ] && . /etc/conf.d/udev |
502 |
|
503 |
. /lib/udev/shell-compat-addon.sh |
504 |
|
505 |
compat_volume_nodes() |
506 |
{ |
507 |
# Only do this for baselayout-1* |
508 |
# This check is likely to get false positives due to some multilib stuff, |
509 |
# but that should not matter, as this can only happen on old openrc versions |
510 |
# no longer available as ebuilds. |
511 |
if [ ! -e /lib/librc.so ]; then |
512 |
|
513 |
# Create nodes that udev can't |
514 |
[ -x /sbin/lvm ] && \ |
515 |
/sbin/lvm vgscan -P --mknodes --ignorelockingfailure &>/dev/null |
516 |
# Running evms_activate on a LiveCD causes lots of headaches |
517 |
[ -z "${CDBOOT}" -a -x /sbin/evms_activate ] && \ |
518 |
/sbin/evms_activate -q &>/dev/null |
519 |
fi |
520 |
} |
521 |
|
522 |
start_initd() |
523 |
{ |
524 |
( |
525 |
. /etc/init.d/"$1" |
526 |
_start |
527 |
) |
528 |
} |
529 |
|
530 |
# set it as openrc does |
531 |
RC_BOOTLEVEL=${BOOTLEVEL:-default} |
532 |
RC_DEFAULTLEVEL=${DEFAULTLEVEL:-default} |
533 |
|
534 |
# mount tmpfs on /dev |
535 |
start_initd udev-mount || exit 1 |
536 |
|
537 |
# Create a file so that our rc system knows it's still in sysinit. |
538 |
# Existance means init scripts will not directly run. |
539 |
# rc will remove the file when done with sysinit. |
540 |
# this is no longer needed as of openrc-0.4.0 |
541 |
touch /dev/.rcsysinit |
542 |
|
543 |
# load device tarball |
544 |
start_initd udev-dev-tarball |
545 |
|
546 |
# run udevd |
547 |
start_initd udev || exit 1 |
548 |
|
549 |
compat_volume_nodes |
550 |
|
551 |
# udev started successfully |
552 |
exit 0 |
553 |
|
554 |
|
555 |
|
556 |
1.1 sys-fs/udev/files/151-r4/udev-dev-tarball.initd |
557 |
|
558 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/151-r4/udev-dev-tarball.initd?rev=1.1&view=markup |
559 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/151-r4/udev-dev-tarball.initd?rev=1.1&content-type=text/plain |
560 |
|
561 |
Index: udev-dev-tarball.initd |
562 |
=================================================================== |
563 |
#!/sbin/runscript |
564 |
# Copyright 1999-2008 Gentoo Foundation |
565 |
# Distributed under the terms of the GNU General Public License v2 |
566 |
|
567 |
description="Maintain a tarball of not udev managed device nodes" |
568 |
[ -e /etc/conf.d/udev ] && . /etc/conf.d/udev |
569 |
|
570 |
rc_device_tarball=${rc_device_tarball:-${RC_DEVICE_TARBALL:-NO}} |
571 |
device_tarball=/lib/udev/state/devices.tar.bz2 |
572 |
|
573 |
depend() { |
574 |
if [ -f /etc/init.d/sysfs ]; then |
575 |
need udev-mount |
576 |
fi |
577 |
} |
578 |
|
579 |
start() |
580 |
{ |
581 |
_start |
582 |
} |
583 |
|
584 |
_start() { |
585 |
if yesno "${rc_device_tarball}" && \ |
586 |
[ -s "${device_tarball}" ] |
587 |
then |
588 |
ebegin "Populating /dev with saved device nodes" |
589 |
tar -jxpf "${device_tarball}" -C /dev |
590 |
eend $? |
591 |
fi |
592 |
} |
593 |
|
594 |
stop() { |
595 |
if [ -e /dev/.devfsd ] || [ ! -e /dev/.udev ] || [ ! -z "${CDBOOT}" ] || \ |
596 |
! yesno "${rc_device_tarball}" || \ |
597 |
! touch "${device_tarball}" 2>/dev/null |
598 |
then |
599 |
return 0 |
600 |
fi |
601 |
|
602 |
ebegin "Saving device nodes" |
603 |
# Handle our temp files |
604 |
save_tmp_base=/tmp/udev.savedevices."$$" |
605 |
devices_udev="${save_tmp_base}"/devices.udev |
606 |
devices_real="${save_tmp_base}"/devices.real |
607 |
devices_totar="${save_tmp_base}"/devices.totar |
608 |
device_tmp_tarball="${save_tmp_base}"/devices |
609 |
|
610 |
rm -rf "${save_tmp_base}" |
611 |
mkdir "${save_tmp_base}" |
612 |
touch "${devices_udev}" "${devices_real}" \ |
613 |
"${devices_totar}" "${device_tmp_tarball}" |
614 |
|
615 |
if [ -f "${devices_udev}" -a -f "${devices_real}" -a \ |
616 |
-f "${devices_totar}" -a -f "${device_tmp_tarball}" ] |
617 |
then |
618 |
cd /dev |
619 |
# Find all devices, but ignore .udev directory |
620 |
find . -xdev -type b -or -type c -or -type l | \ |
621 |
cut -d/ -f2- | \ |
622 |
grep -v ^\\.udev >"${devices_real}" |
623 |
|
624 |
# Figure out what udev created |
625 |
udevadm info --export-db | sed -ne 's,^[SN]: \(.*\),\1,p' >"${devices_udev}" |
626 |
# These ones we also do not want in there |
627 |
for x in MAKEDEV core fd initctl pts shm stderr stdin stdout root; do |
628 |
echo "${x}" >> "${devices_udev}" |
629 |
done |
630 |
if [ -d /lib/udev/devices ]; then |
631 |
cd /lib/udev/devices |
632 |
find . -xdev -type b -or -type c -or -type l | \ |
633 |
cut -d/ -f2- >> "${devices_udev}" |
634 |
cd /dev |
635 |
fi |
636 |
|
637 |
fgrep -x -v -f "${devices_udev}" "${devices_real}" > "${devices_totar}" |
638 |
|
639 |
# Now only tarball those not created by udev if we have any |
640 |
if [ -s "${devices_totar}" ]; then |
641 |
# we dont want to descend into mounted filesystems (e.g. devpts) |
642 |
# looking up username may involve NIS/network |
643 |
# and net may be down |
644 |
tar --one-file-system --numeric-owner \ |
645 |
-jcpf "${device_tmp_tarball}" -T "${devices_totar}" |
646 |
mv -f "${device_tmp_tarball}" "${device_tarball}" |
647 |
else |
648 |
rm -f "${device_tarball}" |
649 |
fi |
650 |
eend 0 |
651 |
else |
652 |
eend 1 "Could not create temporary files!" |
653 |
fi |
654 |
|
655 |
rm -rf "${save_tmp_base}" |
656 |
} |
657 |
|
658 |
|
659 |
|
660 |
|
661 |
1.1 sys-fs/udev/files/151-r4/shell-compat-addon.sh |
662 |
|
663 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/151-r4/shell-compat-addon.sh?rev=1.1&view=markup |
664 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/151-r4/shell-compat-addon.sh?rev=1.1&content-type=text/plain |
665 |
|
666 |
Index: shell-compat-addon.sh |
667 |
=================================================================== |
668 |
# Copyright 1999-2008 Gentoo Foundation |
669 |
# Distributed under the terms of the GNU General Public License v2 |
670 |
|
671 |
# functions that may not be defined, but are used by the udev-start and udev-stop addon |
672 |
# used by baselayout-1 and openrc before version 0.4.0 |
673 |
|
674 |
cmd_exist() |
675 |
{ |
676 |
type "$1" >/dev/null 2>&1 |
677 |
} |
678 |
|
679 |
# does not exist in baselayout-1, does exist in openrc |
680 |
if ! cmd_exist yesno; then |
681 |
yesno() { |
682 |
[ -z "$1" ] && return 1 |
683 |
case "$1" in |
684 |
yes|Yes|YES) return 0 ;; |
685 |
esac |
686 |
return 1 |
687 |
} |
688 |
fi |
689 |
|
690 |
# does not exist in baselayout-1, does exist in openrc |
691 |
# |
692 |
# mountinfo <path> |
693 |
# check if some filesystem is mounted at mountpoint <path> |
694 |
# |
695 |
# return value: |
696 |
# 0 filesystem is mounted at <path> |
697 |
# 1 no filesystem is mounted exactly at <path> |
698 |
if ! cmd_exist mountinfo; then |
699 |
mountinfo() { |
700 |
[ "$1" = "-q" ] && shift |
701 |
local dir="$1" |
702 |
|
703 |
# check if entry is in /proc/mounts |
704 |
local ret=$(gawk 'BEGIN { found="false"; } |
705 |
$1 ~ "^#" { next } |
706 |
$2 == "'$dir'" { found="true"; } |
707 |
END { print found; } |
708 |
' /proc/mounts) |
709 |
|
710 |
"${ret}" |
711 |
} |
712 |
fi |
713 |
|
714 |
# does not exist in baselayout-1, does exist in openrc |
715 |
# |
716 |
# used syntax: fstabinfo --mount /dev |
717 |
# it should mount /dev if an entry exists in /etc/fstab |
718 |
# |
719 |
# return value: |
720 |
# 0 mount succeeded |
721 |
# 1 mount failed or no entry exists |
722 |
# |
723 |
if ! cmd_exist fstabinfo; then |
724 |
fstabinfo() { |
725 |
[ "$1" = "--mount" ] || return 1 |
726 |
local dir="$2" |
727 |
|
728 |
# RC_USE_FSTAB does only exist in baselayout-1 |
729 |
# this emulation is only needed on bl-1, so check always |
730 |
yesno "${RC_USE_FSTAB}" || return 1 |
731 |
|
732 |
# no need to check fstab, mount does this already for us |
733 |
|
734 |
# try mounting - better first check fstab and then mount without surpressing errors |
735 |
mount -n "${dir}" 2>/dev/null |
736 |
return $? |
737 |
} |
738 |
fi |
739 |
|
740 |
|
741 |
|
742 |
1.1 sys-fs/udev/files/151-r4/udev-mount.initd |
743 |
|
744 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/151-r4/udev-mount.initd?rev=1.1&view=markup |
745 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/udev/files/151-r4/udev-mount.initd?rev=1.1&content-type=text/plain |
746 |
|
747 |
Index: udev-mount.initd |
748 |
=================================================================== |
749 |
#!/sbin/runscript |
750 |
# Copyright 1999-2008 Gentoo Foundation |
751 |
# Distributed under the terms of the GNU General Public License v2 |
752 |
|
753 |
description="Mount tmpfs on /dev" |
754 |
[ -e /etc/conf.d/udev ] && . /etc/conf.d/udev |
755 |
|
756 |
# get_KV and KV_to_int |
757 |
. /lib/udev/shell-compat-KV.sh |
758 |
|
759 |
# FIXME |
760 |
# Instead of this script testing kernel version, udev itself should |
761 |
# Maybe something like udevd --test || exit $? |
762 |
check_kernel() |
763 |
{ |
764 |
if [ $(get_KV) -lt $(KV_to_int '%KV_MIN%') ]; then |
765 |
eerror "Your kernel is too old to work with this version of udev." |
766 |
eerror "Current udev only supports Linux kernel %KV_MIN% and newer." |
767 |
return 1 |
768 |
fi |
769 |
|
770 |
yesno "${unreliable_kernel_warning:-yes}" || return 0 |
771 |
|
772 |
if [ $(get_KV) -lt $(KV_to_int '%KV_MIN_RELIABLE%') ]; then |
773 |
ewarn "You need at least Linux kernel %KV_MIN_RELIABLE% for reliable operation of udev." |
774 |
fi |
775 |
return 0 |
776 |
} |
777 |
|
778 |
|
779 |
mount_dev_directory() |
780 |
{ |
781 |
if mountinfo -q /dev; then |
782 |
einfo "/dev is already mounted" |
783 |
return 0 |
784 |
fi |
785 |
|
786 |
# No options are processed here as they should all be in /etc/fstab |
787 |
ebegin "Mounting /dev" |
788 |
if ! fstabinfo --mount /dev; then |
789 |
# we mount devtmpfs if supported |
790 |
local fs=tmpfs |
791 |
grep -qs devtmpfs /proc/filesystems && fs=devtmpfs |
792 |
|
793 |
# Some devices require exec, Bug #92921 |
794 |
mount -n -t "$fs" -o "exec,nosuid,mode=0755,size=10M" udev /dev |
795 |
fi |
796 |
eend $? |
797 |
} |
798 |
|
799 |
seed_dev() |
800 |
{ |
801 |
# Seed /dev with some things that we know we need |
802 |
|
803 |
# creating /dev/console, /dev/tty and /dev/tty1 to be able to write |
804 |
# to $CONSOLE with/without bootsplash before udevd creates it |
805 |
[ -c /dev/console ] || mknod -m 600 /dev/console c 5 1 |
806 |
[ -c /dev/tty1 ] || mknod -m 620 /dev/tty1 c 4 1 |
807 |
[ -c /dev/tty ] || mknod -m 666 /dev/tty c 5 0 |
808 |
|
809 |
# udevd will dup its stdin/stdout/stderr to /dev/null |
810 |
# and we do not want a file which gets buffered in ram |
811 |
[ -c /dev/null ] || mknod -m 666 /dev/null c 1 3 |
812 |
${HAVE_SELINUX} && restorecon /dev/null |
813 |
|
814 |
# so udev can add its start-message to dmesg |
815 |
[ -c /dev/kmsg ] || mknod -m 660 /dev/kmsg c 1 11 |
816 |
|
817 |
# copy over any persistant things |
818 |
if [ -d /lib/udev/devices ]; then |
819 |
cp -RPp /lib/udev/devices/* /dev 2>/dev/null |
820 |
fi |
821 |
|
822 |
# Not provided by sysfs but needed |
823 |
ln -snf /proc/self/fd /dev/fd |
824 |
ln -snf fd/0 /dev/stdin |
825 |
ln -snf fd/1 /dev/stdout |
826 |
ln -snf fd/2 /dev/stderr |
827 |
[ -e /proc/kcore ] && ln -snf /proc/kcore /dev/core |
828 |
|
829 |
# Create problematic directories |
830 |
mkdir -p /dev/pts /dev/shm |
831 |
${HAVE_SELINUX} && restorecon -R /dev >/dev/null |
832 |
return 0 |
833 |
} |
834 |
|
835 |
|
836 |
start() |
837 |
{ |
838 |
# do not run this on too old baselayout - udev-addon is already loaded! |
839 |
if [ ! -f /etc/init.d/sysfs ]; then |
840 |
eerror "The $SVCNAME init-script is written for baselayout-2!" |
841 |
eerror "Please do not use it with baselayout-1!". |
842 |
return 1 |
843 |
fi |
844 |
|
845 |
_start |
846 |
} |
847 |
|
848 |
_start() |
849 |
{ |
850 |
check_kernel || return 1 |
851 |
mount_dev_directory || return 1 |
852 |
|
853 |
# Selinux lovin; /selinux should be mounted by selinux-patched init |
854 |
if [ -x /sbin/restorecon -a -c /selinux/null ]; then |
855 |
HAVE_SELINUX=true |
856 |
restorecon /dev > /selinux/null |
857 |
else |
858 |
HAVE_SELINUX=false |
859 |
fi |
860 |
|
861 |
# make sure it exists |
862 |
mkdir -p /dev/.udev /dev/.udev/rules.d |
863 |
|
864 |
seed_dev |
865 |
|
866 |
return 0 |
867 |
} |