public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "William Hubbs" <williamh@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/udev-gentoo-scripts:master commit in: init.d/, /
Date: Sun,  9 Oct 2011 15:24:31 +0000 (UTC)	[thread overview]
Message-ID: <5726b21454f7300677447ab7a2d0484fbbe8d43c.WilliamH@gentoo> (raw)

commit:     5726b21454f7300677447ab7a2d0484fbbe8d43c
Author:     William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Fri Oct  7 16:24:11 2011 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Oct  8 17:52:53 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/udev-gentoo-scripts.git;a=commit;h=5726b214

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
 
 check-git-repository:
 	git diff --quiet || { echo 'STOP, you have uncommitted changes in the working 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=/sbin/udevd
 command_args="--daemon ${udev_opts}"
 description="Run udevd and create the device-nodes"
+extra_commands="udev_mount"
+description_udev_mount="mount devtmpfs or tmpfs on /dev"
 
 persistent_cd_disable="${persistent_cd_disable:-no}"
 persistent_net_disable="${persistent_net_disable:-no}"
@@ -13,17 +15,40 @@ udev_debug="${udev_debug:-no}"
 udev_monitor="${udev_monitor:-no}"
 udev_monitor_keep_running="${udev_monitor_keep_running:-no}"
 udev_settle_timeout="${udev_settle_timeout:-60}"
+unreliable_kernel_warning="${unreliable_kernel_warning:-yes}"
 
 depend()
 {
 	provide dev
-	need sysfs udev-mount
+	need sysfs
 	before checkfs fsck
 
 	# udev does not work inside vservers
 	keyword -vserver -lxc
 }
 
+# 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 operation of udev."
+	fi
+	return 0
+}
+
 get_rundir()
 {
 	echo $(udevadm info --run)
@@ -36,6 +61,69 @@ cleanup()
 	exit 1
 }
 
+mount_dev_directory()
+{
+	if mountinfo -q /dev; then
+		if [ "${RC_CMD}" != "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=tmpfs
+		grep -qs devtmpfs /proc/filesystems && fs=devtmpfs
+
+		# Some devices require exec, Bug #92921
+		mount -n -t "$fs" -o "exec,nosuid,mode=0755,size=10M" 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=true
+		restorecon /dev > /selinux/null
+	else
+		HAVE_SELINUX=false
+	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
 
+	udev_mount || return 1
 	/lib/udev/write_root_link_rule
 
 	rules_disable_switch 75-persistent-net-generator.rules "${persistent_net_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="Mount tmpfs on /dev"
-[ -e /etc/conf.d/udev ] && . /etc/conf.d/udev
-unreliable_kernel_warning="${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 operation 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=tmpfs
-		grep -qs devtmpfs /proc/filesystems && fs=devtmpfs
-
-		# Some devices require exec, Bug #92921
-		mount -n -t "$fs" -o "exec,nosuid,mode=0755,size=10M" 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=true
-		restorecon /dev > /selinux/null
-	else
-		HAVE_SELINUX=false
-	fi
-
-	seed_dev
-
-	return 0
-}



             reply	other threads:[~2011-10-09 15:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-09 15:24 William Hubbs [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-10-29 20:24 [gentoo-commits] proj/udev-gentoo-scripts:master commit in: init.d/, / William Hubbs
2012-08-07 17:29 William Hubbs
2012-08-08 18:37 William Hubbs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5726b21454f7300677447ab7a2d0484fbbe8d43c.WilliamH@gentoo \
    --to=williamh@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox