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/openrc:master commit in: init.d/, conf.d/
Date: Sun,  5 Jan 2014 21:59:17 +0000 (UTC)	[thread overview]
Message-ID: <1388942225.8352082eb6582d6e7adc26fc64dfd2255eadf2a7.williamh@OpenRC> (raw)

commit:     8352082eb6582d6e7adc26fc64dfd2255eadf2a7
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sun Dec  1 22:31:02 2013 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sun Jan  5 17:17:05 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=8352082e

devfs: add code to mount /dev

All Linux systems need /dev to be set up,so add code to devfs to do
this. The process devfs follows is below.

1. If static_dev is yes, nothing is done.
2. if /dev is an entry in fstab it is mounted or remounted based on that
entry.
3. If /dev is not in fstab, it attempts to mount /dev as a devtmpfs or
   tmpfs depending on which is defined in the kernel; devtmpfs is
   preferred.
4. If neither devtmpfs nor tmpfs is defined, it assumes the user wants
static /dev and prints a warning.

X-Gentoo-Bug: 492694
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=492694

---
 conf.d/Makefile |  2 +-
 conf.d/devfs    |  2 ++
 init.d/devfs.in | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
 3 files changed, 69 insertions(+), 5 deletions(-)

diff --git a/conf.d/Makefile b/conf.d/Makefile
index aefb612..93476fc 100644
--- a/conf.d/Makefile
+++ b/conf.d/Makefile
@@ -15,7 +15,7 @@ include ${MK}/os.mk
 
 CONF-FreeBSD=	ipfw moused powerd rarpd savecore syscons
 
-CONF-Linux=	consolefont dmesg hwclock keymaps killprocs modules
+CONF-Linux=	consolefont devfs dmesg hwclock keymaps killprocs modules
 
 CONF-NetBSD=	moused rarpd savecore
 

diff --git a/conf.d/devfs b/conf.d/devfs
new file mode 100644
index 0000000..92a8a99
--- /dev/null
+++ b/conf.d/devfs
@@ -0,0 +1,2 @@
+# Set this to yes if your /dev is not a devtmpfs or tmpfs.
+# static_dev="NO"

diff --git a/init.d/devfs.in b/init.d/devfs.in
index 5c167b0..7fba882 100644
--- a/init.d/devfs.in
+++ b/init.d/devfs.in
@@ -2,15 +2,71 @@
 # Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
 # Released under the 2-clause BSD license.
 
-description="Mount system critical filesystems in /dev."
+description="Set up the /dev directory"
 
-depend() {
-	use dev-mount
+depend()
+{
+	provide dev-mount
 	before dev
 	keyword -prefix -vserver -lxc
 }
 
-start() {
+mount_dev()
+{
+	local action=--mount devfstype msg=Mounting
+	# Some devices require exec, Bug #92921
+	local mountopts="exec,nosuid,mode=0755"
+	if yesno ${static_dev:-no}; then
+		einfo "Using static /dev"
+		return 0
+	fi
+	if mountinfo -q /dev; then
+		action=--remount
+		mountopts="remount,$mountopts"
+		msg=Remounting
+	fi
+	if fstabinfo -q /dev; then
+		ebegin "$msg /dev according to @SYSCONFDIR@/fstab"
+		fstabinfo -q $action /dev
+		eend $?
+		return 0
+	fi
+	if grep -q devtmpfs /proc/filesystems; then
+		devfstype=devtmpfs
+		mountopts="$mountopts,size=10M"
+	elif grep -q tmpfs /proc/filesystems; then
+		devfstype=tmpfs
+		mountopts="$mountopts,size=10M"
+	fi
+	if [ -n "$devfstype" ]; then
+		ebegin "$msg $devfstype on /dev"
+		mount -n -t $devfstype -o $mountopts dev /dev
+		eend $?
+	else
+		ewarn "This kernel does not have devtmpfs or tmpfs support."
+		ewarn "Assuming you want static /dev. If this is not the case,"
+		ewarn "please set the CONFIG_DEVTMPFS or CONFIG_TMPFS option"
+		ewarn "in your kernel."
+	fi
+}
+
+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
+
+	# so udev can add its start-message to dmesg
+	[ -c /dev/kmsg ] || mknod -m 660 /dev/kmsg c 1 11
+
 	# Mount required stuff as user may not have then in /etc/fstab
 	for x in \
 		"mqueue /dev/mqueue 1777 ,nodev mqueue" \
@@ -34,5 +90,11 @@ start() {
 			eend $?
 		fi
 	done
+}
+
+start()
+{
+	mount_dev
+	seed_dev
 	return 0
 }


             reply	other threads:[~2014-01-05 21:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-05 21:59 William Hubbs [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-10-06 19:44 [gentoo-commits] proj/openrc:master commit in: init.d/, conf.d/ William Hubbs
2017-05-22 17:54 William Hubbs
2016-04-25 17:12 William Hubbs
2016-01-19 19:37 William Hubbs
2016-01-13 17:02 William Hubbs
2014-08-22 19:10 William Hubbs
2014-08-08 23:19 ` William Hubbs
2012-10-26  0:58 William Hubbs
2012-02-18 19:11 William Hubbs
2012-02-18 19:11 William Hubbs
2011-11-26 18:22 Mike Frysinger
2011-11-23  0:55 William Hubbs
2011-11-07  4:07 William Hubbs
2011-11-06 20:04 William Hubbs
2011-09-27 16:16 Christian Ruppert
2011-07-04  7:52 Robin H. Johnson
2011-06-24  2:58 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=1388942225.8352082eb6582d6e7adc26fc64dfd2255eadf2a7.williamh@OpenRC \
    --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