diff options
-rw-r--r-- | conf.d/udev | 38 | ||||
-rw-r--r-- | conf.d/udev-settle | 5 | ||||
-rw-r--r-- | conf.d/udev-trigger | 32 | ||||
-rw-r--r-- | init.d/udev | 92 | ||||
-rw-r--r-- | init.d/udev-settle | 17 | ||||
-rw-r--r-- | init.d/udev-trigger | 91 |
6 files changed, 145 insertions, 130 deletions
diff --git a/conf.d/udev b/conf.d/udev index 41f6b9b..a714032 100644 --- a/conf.d/udev +++ b/conf.d/udev @@ -1,31 +1,5 @@ # /etc/conf.d/udev: config file for udev -# udev can trigger coldplug events which cause services to start and -# kernel modules to be loaded. -# Services are deferred to start in the boot runlevel. -# Set rc_coldplug="NO" if you don't want this. -# If you want module coldplugging but not coldplugging of services then you -# can disable service coldplugging in baselayout/openrc config files. -# The setting is named different in different versions. -# in /etc/rc.conf: rc_hotplug="!*" or -# in /etc/conf.d/rc: rc_plug_services="!*" -#rc_coldplug="YES" - -# We can create a /dev/root symbolic link to point to the root device in -# some situations. This is on by default because some software relies on -# it,. However, this software should be fixed to not do this. -# For more information, see -# https://bugs.gentoo.org/show_bug.cgi?id=438380. -# If you are not using any affected software, you do not need this, so -# feel free to turn it off. -#rc_dev_root_symlink="YES" - -# Expert options: - -# Timeout in seconds to wait for processing of uevents at boot. -# There should be no need to change this. -#udev_settle_timeout="60" - # Add extra command line options to udevd, use with care # udevd --help for possible values #udev_opts="" @@ -33,15 +7,3 @@ # Run udevd --debug and write output to /run/udevdebug.log # Should not be kept on as it fills diskspace slowly #udev_debug="YES" - -# Run udevadmin monitor to get a log of all events -# in /run/udevmonitor.log -#udev_monitor="YES" - -# Keep udevmonitor running after populating /dev. -#udev_monitor_keep_running="no" - -# Set cmdline options for udevmonitor. -# could be some of --env --kernel --udev -#udev_monitor_opts="--env" - diff --git a/conf.d/udev-settle b/conf.d/udev-settle new file mode 100644 index 0000000..b83580a --- /dev/null +++ b/conf.d/udev-settle @@ -0,0 +1,5 @@ +# /etc/conf.d/udev-settle: config file for udev-settle + +# Timeout in seconds to wait for processing of uevents at boot. +# There should be no need to change this. +#udev_settle_timeout="60" diff --git a/conf.d/udev-trigger b/conf.d/udev-trigger new file mode 100644 index 0000000..5850b8b --- /dev/null +++ b/conf.d/udev-trigger @@ -0,0 +1,32 @@ +# /etc/conf.d/udev-trigger: config file for udev-trigger + +# udev can trigger coldplug events which cause services to start and +# kernel modules to be loaded. +# Services are deferred to start in the boot runlevel. +# Set rc_coldplug="NO" if you don't want this. +# If you want module coldplugging but not coldplugging of services then you +# can disable service coldplugging in baselayout/openrc config files. +# The setting is named different in different versions. +# in /etc/rc.conf: rc_hotplug="!*" or +# in /etc/conf.d/rc: rc_plug_services="!*" +#rc_coldplug="YES" + +# We can create a /dev/root symbolic link to point to the root device in +# some situations. This is on by default because some software relies on +# it,. However, this software should be fixed to not do this. +# For more information, see +# https://bugs.gentoo.org/show_bug.cgi?id=438380. +# If you are not using any affected software, you do not need this, so +# feel free to turn it off. +#rc_dev_root_symlink="YES" + +# Run udevadmin monitor to get a log of all events +# in /run/udevmonitor.log +#udev_monitor="YES" + +# Keep udevmonitor running after populating /dev. +#udev_monitor_keep_running="no" + +# Set cmdline options for udevmonitor. +# could be some of --env --kernel --udev +#udev_monitor_opts="--env" diff --git a/init.d/udev b/init.d/udev index 654eee3..57fae76 100644 --- a/init.d/udev +++ b/init.d/udev @@ -7,12 +7,8 @@ description="udev manages device permissions and symbolic links in /dev" extra_started_commands="reload" description_reload="Reload the udev rules and databases" -udevmonitor_log=/run/udevmonitor.log -udevmonitor_pid=/run/udevmonitor.pid - depend() { - provide dev need sysfs dev-mount before checkfs fsck @@ -73,94 +69,6 @@ start_pre() return 0 } -start_udevmonitor() -{ - yesno "${udev_monitor:-no}" || return 0 - - einfo "udev: Running udevadm monitor ${udev_monitor_opts} to log all events" - start-stop-daemon --start --stdout "${udevmonitor_log}" \ - --make-pidfile --pidfile "${udevmonitor_pid}" \ - --background --exec /bin/udevadm -- monitor ${udev_monitor_opts} -} - -# This is here because some software expects /dev/root to exist. -# For more information, see this bug: -# https://bugs.gentoo.org/show_bug.cgi?id=438380 -dev_root_link() -{ - local RULESDIR=/run/udev/rules.d - [ -d $RULESDIR ] || mkdir -p $RULESDIR - eval $(udevadm info --export --export-prefix=ROOT_ --device-id-of-file=/ || - true) - [ "$ROOT_MAJOR" -a "$ROOT_MINOR" ] || return 0 - - # btrfs filesystems have bogus major/minor numbers - [ "$ROOT_MAJOR" != 0 ] || return 0 - - echo 'ACTION=="add|change", SUBSYSTEM=="block", ENV{MAJOR}=="'$ROOT_MAJOR'", ENV{MINOR}=="'$ROOT_MINOR'", SYMLINK+="root"' > $RULESDIR/61-dev-root-link.rules -} - -populate_dev() -{ - if yesno ${rc_dev_root_symlink:-yes}; then - ebegin "Generating a rule to create a /dev/root symlink" - dev_root_link - eend $? - fi - - get_bootparam "nocoldplug" && rc_coldplug="no" - if ! yesno ${rc_coldplug:-${RC_COLDPLUG:-yes}}; then - einfo "Setting /dev permissions and symbolic links" - udevadm trigger --attr-match=dev --action=add - udevadm trigger --subsystem-match=net --action=add - ewarn "Skipping udev coldplug sequence" - return 0 - fi - - ebegin "Populating /dev with existing devices through uevents" - udevadm trigger --type=subsystems --action=add - udevadm trigger --type=devices --action=add - eend $? - - ebegin "Waiting for uevents to be processed" - udevadm settle --timeout=${udev_settle_timeout:-60} - eend $? - return 0 -} - -stop_udevmonitor() -{ - yesno "${udev_monitor:-no}" || return 0 - - if yesno "${udev_monitor_keep_running:-no}"; then - ewarn "udev: udevmonitor is still running and writing into ${udevmonitor_log}" - else - einfo "udev: Stopping udevmonitor: Log is in ${udevmonitor_log}" - start-stop-daemon --stop --pidfile "${udevmonitor_pid}" --exec /bin/udevadm - fi -} - -display_hotplugged_services() -{ - local svcfile= svc= services= - for svcfile in "${RC_SVCDIR}"/hotplugged/*; do - svc="${svcfile##*/}" - [ -x "${svcfile}" ] || continue - - services="${services} ${svc}" - done - [ -n "${services}" ] && einfo "Device initiated services:${HILITE}${services}${NORMAL}" -} - -start_post() -{ - start_udevmonitor - populate_dev - stop_udevmonitor - display_hotplugged_services - return 0 -} - stop() { local rc=0 diff --git a/init.d/udev-settle b/init.d/udev-settle new file mode 100644 index 0000000..dd3fe4b --- /dev/null +++ b/init.d/udev-settle @@ -0,0 +1,17 @@ +#!/sbin/openrc-run +# Copyright 2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +depend() +{ +need udev +after udev-trigger + keyword -vserver -lxc +} + +start() +{ + ebegin "Waiting for uevents to be processed" + udevadm settle --timeout=${udev_settle_timeout:-60} + eend $? +} diff --git a/init.d/udev-trigger b/init.d/udev-trigger new file mode 100644 index 0000000..abc4540 --- /dev/null +++ b/init.d/udev-trigger @@ -0,0 +1,91 @@ +#!/sbin/openrc-run +# Copyright 2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +description="udev Coldplug all Devices" + +udevmonitor_log=/run/udevmonitor.log +udevmonitor_pid=/run/udevmonitor.pid + +depend() +{ + need udev + provide dev + keyword -vserver -lxc +} + +start_pre() +{ + if yesno "${udev_monitor:-no}"; then + einfo "Running udevadm monitor ${udev_monitor_opts} to log all events" + start-stop-daemon --start --stdout "${udevmonitor_log}" \ + --make-pidfile --pidfile "${udevmonitor_pid}" \ + --background --exec /bin/udevadm -- monitor ${udev_monitor_opts} + fi +} + +display_hotplugged_services() +{ + local svcfile= svc= services= + for svcfile in "${RC_SVCDIR}"/hotplugged/*; do + svc="${svcfile##*/}" + [ -x "${svcfile}" ] || continue + + services="${services} ${svc}" + done + [ -n "${services}" ] && einfo "Device initiated services:${HILITE}${services}${NORMAL}" +} + +start_post() +{ + if yesno "${udev_monitor}:-no}"; then + if yesno "${udev_monitor_keep_running:-no}"; then + ewarn "udevmonitor is still writing into ${udevmonitor_log}" + else + einfo "Stopping udevmonitor: Log is in ${udevmonitor_log}" + start-stop-daemon --stop --pidfile "${udevmonitor_pid}" \ + --exec /bin/udevadm + fi + fi + display_hotplugged_services +} + +# This is here because some software expects /dev/root to exist. +# For more information, see this bug: +# https://bugs.gentoo.org/show_bug.cgi?id=438380 +dev_root_link() +{ + local RULESDIR=/run/udev/rules.d + [ -d $RULESDIR ] || mkdir -p $RULESDIR + eval $(udevadm info --export --export-prefix=ROOT_ --device-id-of-file=/ || + true) + [ "$ROOT_MAJOR" -a "$ROOT_MINOR" ] || return 0 + + # btrfs filesystems have bogus major/minor numbers + [ "$ROOT_MAJOR" != 0 ] || return 0 + + echo 'ACTION=="add|change", SUBSYSTEM=="block", ENV{MAJOR}=="'$ROOT_MAJOR'", ENV{MINOR}=="'$ROOT_MINOR'", SYMLINK+="root"' > $RULESDIR/61-dev-root-link.rules +} + +start() +{ + if yesno ${rc_dev_root_symlink:-yes}; then + ebegin "Generating a rule to create a /dev/root symlink" + dev_root_link + eend $? + fi + + get_bootparam "nocoldplug" && rc_coldplug="no" + if ! yesno ${rc_coldplug:-${RC_COLDPLUG:-yes}}; then + einfo "Setting /dev permissions and symbolic links" + udevadm trigger --attr-match=dev --action=add + udevadm trigger --subsystem-match=net --action=add + ewarn "Skipping udev coldplug sequence" + return 0 + fi + + ebegin "Populating /dev with existing devices through uevents" + udevadm trigger --type=subsystems --action=add + udevadm trigger --type=devices --action=add + eend $? +} |