From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RCvF2-0002rY-85 for garchives@archives.gentoo.org; Sun, 09 Oct 2011 15:24:40 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 09EA621C073; Sun, 9 Oct 2011 15:24:32 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id A5AB521C073 for ; Sun, 9 Oct 2011 15:24:32 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0CF741B4009 for ; Sun, 9 Oct 2011 15:24:32 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 4CE7780042 for ; Sun, 9 Oct 2011 15:24:31 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: <5726b21454f7300677447ab7a2d0484fbbe8d43c.WilliamH@gentoo> Subject: [gentoo-commits] proj/udev-gentoo-scripts:master commit in: init.d/, / X-VCS-Repository: proj/udev-gentoo-scripts X-VCS-Files: Makefile init.d/udev init.d/udev-mount X-VCS-Directories: init.d/ / X-VCS-Committer: WilliamH X-VCS-Committer-Name: William Hubbs X-VCS-Revision: 5726b21454f7300677447ab7a2d0484fbbe8d43c Date: Sun, 9 Oct 2011 15:24:31 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 3bd97d81251104a9f4b5eac763513116 commit: 5726b21454f7300677447ab7a2d0484fbbe8d43c Author: William Hubbs gentoo org> AuthorDate: Fri Oct 7 16:24:11 2011 +0000 Commit: William Hubbs gentoo org> CommitDate: Sat Oct 8 17:52:53 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/udev-gentoo-s= cripts.git;a=3Dcommit;h=3D5726b214 encorporate udev-mount script into udev script udev-mount was a separate init script which mounted devtmpfs or a tmpfs filesystem on /dev for use with udev. This commit removes the separate udev-mount script and encorporates that code into the udev script. If you need to run it separately, you can do so with rc-service udev udev_mount or /etc/init.d/udev udev_mount. --- Makefile | 2 +- init.d/udev | 91 +++++++++++++++++++++++++++++++++++++++++++++++= - init.d/udev-mount | 100 -----------------------------------------------= ------ 3 files changed, 91 insertions(+), 102 deletions(-) diff --git a/Makefile b/Makefile index b88c1bd..fc23e82 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ install: @install -m 0644 modprobe.d/* $(DESTDIR)$(MODPROBE_DIR) @sed -e "s/%KV_MIN%/$(KV_min)/" \ -e "s/%KV_MIN_RELIABLE%/$(KV_reliable)/" \ - -i "$(DESTDIR)$(INITD)"/udev-mount + -i "$(DESTDIR)$(INITD)"/udev =20 check-git-repository: git diff --quiet || { echo 'STOP, you have uncommitted changes in the w= orking directory' ; false ; } diff --git a/init.d/udev b/init.d/udev index 57aa580..cb1ad02 100644 --- a/init.d/udev +++ b/init.d/udev @@ -5,6 +5,8 @@ command=3D/sbin/udevd command_args=3D"--daemon ${udev_opts}" description=3D"Run udevd and create the device-nodes" +extra_commands=3D"udev_mount" +description_udev_mount=3D"mount devtmpfs or tmpfs on /dev" =20 persistent_cd_disable=3D"${persistent_cd_disable:-no}" persistent_net_disable=3D"${persistent_net_disable:-no}" @@ -13,17 +15,40 @@ udev_debug=3D"${udev_debug:-no}" udev_monitor=3D"${udev_monitor:-no}" udev_monitor_keep_running=3D"${udev_monitor_keep_running:-no}" udev_settle_timeout=3D"${udev_settle_timeout:-60}" +unreliable_kernel_warning=3D"${unreliable_kernel_warning:-yes}" =20 depend() { provide dev - need sysfs udev-mount + need sysfs before checkfs fsck =20 # udev does not work inside vservers keyword -vserver -lxc } =20 +# get_KV and KV_to_int +. /lib/udev/shell-compat-KV.sh + +# FIXME +# Instead of this script testing kernel version, udev itself should +# Maybe something like udevd --test || exit $? +check_kernel() +{ + if [ $(get_KV) -lt $(KV_to_int '%KV_MIN%') ]; then + eerror "Your kernel is too old to work with this version of udev." + eerror "Current udev only supports Linux kernel %KV_MIN% and newer." + return 1 + fi + + yesno "${unreliable_kernel_warning}" || return 0 + + if [ $(get_KV) -lt $(KV_to_int '%KV_MIN_RELIABLE%') ]; then + ewarn "You need at least Linux kernel %KV_MIN_RELIABLE% for reliable o= peration of udev." + fi + return 0 +} + get_rundir() { echo $(udevadm info --run) @@ -36,6 +61,69 @@ cleanup() exit 1 } =20 +mount_dev_directory() +{ + if mountinfo -q /dev; then + if [ "${RC_CMD}" !=3D "start" ]; then + einfo "/dev is already mounted" + fi + return 0 + fi + + # No options are processed here as they should all be in /etc/fstab + ebegin "Mounting /dev" + if ! fstabinfo --mount /dev; then + # we mount devtmpfs if supported + local fs=3Dtmpfs + grep -qs devtmpfs /proc/filesystems && fs=3Ddevtmpfs + + # Some devices require exec, Bug #92921 + mount -n -t "$fs" -o "exec,nosuid,mode=3D0755,size=3D10M" udev /dev + fi + eend $? +} + +seed_dev() +{ + # Seed /dev with some things that we know we need + + # creating /dev/console, /dev/tty and /dev/tty1 to be able to write + # to $CONSOLE with/without bootsplash before udevd creates it + [ -c /dev/console ] || mknod -m 600 /dev/console c 5 1 + [ -c /dev/tty1 ] || mknod -m 620 /dev/tty1 c 4 1 + [ -c /dev/tty ] || mknod -m 666 /dev/tty c 5 0 + + # udevd will dup its stdin/stdout/stderr to /dev/null + # and we do not want a file which gets buffered in ram + [ -c /dev/null ] || mknod -m 666 /dev/null c 1 3 + ${HAVE_SELINUX} && restorecon /dev/null + + # so udev can add its start-message to dmesg + [ -c /dev/kmsg ] || mknod -m 660 /dev/kmsg c 1 11 + + # Create problematic directories + mkdir -p /dev/pts /dev/shm + ${HAVE_SELINUX} && restorecon -R /dev >/dev/null + return 0 +} + +udev_mount() +{ + check_kernel || return 1 + mount_dev_directory || return 1 + + # Selinux lovin; /selinux should be mounted by selinux-patched init + if [ -x /sbin/restorecon -a -c /selinux/null ]; then + HAVE_SELINUX=3Dtrue + restorecon /dev > /selinux/null + else + HAVE_SELINUX=3Dfalse + fi + + seed_dev + return 0 +} + rules_disable_switch() { # this function disables rules files @@ -80,6 +168,7 @@ start_pre() ewarn "You should add udev-postmount service to your default runlevel.= " fi =20 + udev_mount || return 1 /lib/udev/write_root_link_rule =20 rules_disable_switch 75-persistent-net-generator.rules "${persistent_ne= t_disable}" diff --git a/init.d/udev-mount b/init.d/udev-mount deleted file mode 100644 index f81d82d..0000000 --- a/init.d/udev-mount +++ /dev/null @@ -1,100 +0,0 @@ -#!/sbin/runscript -# Copyright 1999-2010 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -description=3D"Mount tmpfs on /dev" -[ -e /etc/conf.d/udev ] && . /etc/conf.d/udev -unreliable_kernel_warning=3D"${unreliable_kernel_warning:-yes}" - -# get_KV and KV_to_int -. /lib/udev/shell-compat-KV.sh - -# FIXME -# Instead of this script testing kernel version, udev itself should -# Maybe something like udevd --test || exit $? -check_kernel() -{ - if [ $(get_KV) -lt $(KV_to_int '%KV_MIN%') ]; then - eerror "Your kernel is too old to work with this version of udev." - eerror "Current udev only supports Linux kernel %KV_MIN% and newer." - return 1 - fi - - yesno "${unreliable_kernel_warning}" || return 0 - - if [ $(get_KV) -lt $(KV_to_int '%KV_MIN_RELIABLE%') ]; then - ewarn "You need at least Linux kernel %KV_MIN_RELIABLE% for reliable o= peration of udev." - fi - return 0 -} - - -mount_dev_directory() -{ - if mountinfo -q /dev; then - einfo "/dev is already mounted" - return 0 - fi - - # No options are processed here as they should all be in /etc/fstab - ebegin "Mounting /dev" - if ! fstabinfo --mount /dev; then - # we mount devtmpfs if supported - local fs=3Dtmpfs - grep -qs devtmpfs /proc/filesystems && fs=3Ddevtmpfs - - # Some devices require exec, Bug #92921 - mount -n -t "$fs" -o "exec,nosuid,mode=3D0755,size=3D10M" udev /dev - fi - eend $? -} - -seed_dev() -{ - # Seed /dev with some things that we know we need - - # creating /dev/console, /dev/tty and /dev/tty1 to be able to write - # to $CONSOLE with/without bootsplash before udevd creates it - [ -c /dev/console ] || mknod -m 600 /dev/console c 5 1 - [ -c /dev/tty1 ] || mknod -m 620 /dev/tty1 c 4 1 - [ -c /dev/tty ] || mknod -m 666 /dev/tty c 5 0 - - # udevd will dup its stdin/stdout/stderr to /dev/null - # and we do not want a file which gets buffered in ram - [ -c /dev/null ] || mknod -m 666 /dev/null c 1 3 - ${HAVE_SELINUX} && restorecon /dev/null - - # so udev can add its start-message to dmesg - [ -c /dev/kmsg ] || mknod -m 660 /dev/kmsg c 1 11 - - # Create problematic directories - mkdir -p /dev/pts /dev/shm - ${HAVE_SELINUX} && restorecon -R /dev >/dev/null - return 0 -} - - -start() -{ - # do not run this on too old baselayout - udev-addon is already loaded! - if [ ! -f /etc/init.d/sysfs ]; then - eerror "The $SVCNAME init-script is written for baselayout-2!" - eerror "Please do not use it with baselayout-1!". - return 1 - fi - - check_kernel || return 1 - mount_dev_directory || return 1 - - # Selinux lovin; /selinux should be mounted by selinux-patched init - if [ -x /sbin/restorecon -a -c /selinux/null ]; then - HAVE_SELINUX=3Dtrue - restorecon /dev > /selinux/null - else - HAVE_SELINUX=3Dfalse - fi - - seed_dev - - return 0 -}