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
This commit is contained in:
parent
3470eda3f5
commit
8352082eb6
@ -15,7 +15,7 @@ include ${MK}/os.mk
|
|||||||
|
|
||||||
CONF-FreeBSD= ipfw moused powerd rarpd savecore syscons
|
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
|
CONF-NetBSD= moused rarpd savecore
|
||||||
|
|
||||||
|
2
conf.d/devfs
Normal file
2
conf.d/devfs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Set this to yes if your /dev is not a devtmpfs or tmpfs.
|
||||||
|
# static_dev="NO"
|
@ -2,15 +2,71 @@
|
|||||||
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
|
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
|
||||||
# Released under the 2-clause BSD license.
|
# Released under the 2-clause BSD license.
|
||||||
|
|
||||||
description="Mount system critical filesystems in /dev."
|
description="Set up the /dev directory"
|
||||||
|
|
||||||
depend() {
|
depend()
|
||||||
use dev-mount
|
{
|
||||||
|
provide dev-mount
|
||||||
before dev
|
before dev
|
||||||
keyword -prefix -vserver -lxc
|
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
|
# Mount required stuff as user may not have then in /etc/fstab
|
||||||
for x in \
|
for x in \
|
||||||
"mqueue /dev/mqueue 1777 ,nodev mqueue" \
|
"mqueue /dev/mqueue 1777 ,nodev mqueue" \
|
||||||
@ -34,5 +90,11 @@ start() {
|
|||||||
eend $?
|
eend $?
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
start()
|
||||||
|
{
|
||||||
|
mount_dev
|
||||||
|
seed_dev
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user