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