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