2008-02-27 20:29:32 +00:00
|
|
|
#!@SHELL@
|
2009-05-01 15:11:40 +01:00
|
|
|
# Copyright (c) 1999-2007 Gentoo Foundation
|
|
|
|
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
|
2008-01-11 15:31:10 +00:00
|
|
|
# All rights reserved. Released under the 2-clause BSD license.
|
2007-11-14 15:22:04 +00:00
|
|
|
|
2008-11-03 15:31:01 +00:00
|
|
|
# This basically mounts $RC_SVCDIR as a ramdisk.
|
2007-04-05 11:18:42 +00:00
|
|
|
# The tricky part is finding something our kernel supports
|
2008-02-03 17:21:11 +00:00
|
|
|
# tmpfs and ramfs are easy, so force one or the other.
|
2008-01-11 12:13:46 +00:00
|
|
|
mount_svcdir()
|
|
|
|
{
|
2008-10-10 08:37:21 +00:00
|
|
|
local fs= fsopts="-o rw,noexec,nodev,nosuid"
|
2008-11-03 15:31:01 +00:00
|
|
|
local devdir="rc-svcdir" x=
|
2008-01-31 09:48:58 +00:00
|
|
|
local svcsize=${rc_svcsize:-1024}
|
2007-04-05 11:18:42 +00:00
|
|
|
|
2007-09-26 10:09:27 +00:00
|
|
|
if grep -Eq "[[:space:]]+tmpfs$" /proc/filesystems; then
|
2007-04-05 11:18:42 +00:00
|
|
|
fs="tmpfs"
|
2009-04-26 21:13:26 +00:00
|
|
|
fsopts="$fsopts,mode=0755,size=${svcsize}k"
|
2007-09-26 10:09:27 +00:00
|
|
|
elif grep -Eq "[[:space:]]+ramfs$" /proc/filesystems; then
|
2007-04-05 11:18:42 +00:00
|
|
|
fs="ramfs"
|
2007-04-14 09:27:29 +00:00
|
|
|
# ramfs has no special options
|
2008-11-03 15:31:01 +00:00
|
|
|
elif [ -e /dev/ram0 ] \
|
2007-09-26 10:09:27 +00:00
|
|
|
&& grep -Eq "[[:space:]]+ext2$" /proc/filesystems; then
|
2007-04-05 11:18:42 +00:00
|
|
|
devdir="/dev/ram0"
|
|
|
|
fs="ext2"
|
2009-04-26 21:13:26 +00:00
|
|
|
dd if=/dev/zero of="$devdir" bs=1k count="$svcsize"
|
|
|
|
mkfs -t "$fs" -i 1024 -vm0 "$devdir" "$svcsize"
|
2007-04-05 11:18:42 +00:00
|
|
|
else
|
|
|
|
echo
|
2008-11-03 15:31:01 +00:00
|
|
|
eerror "OpenRC requires tmpfs, ramfs or a ramdisk + ext2"
|
2007-04-05 11:18:42 +00:00
|
|
|
eerror "compiled into the kernel"
|
|
|
|
echo
|
2008-01-31 09:48:58 +00:00
|
|
|
return 1
|
2007-04-05 11:18:42 +00:00
|
|
|
fi
|
|
|
|
|
2008-01-31 09:48:58 +00:00
|
|
|
# If we have no entry in fstab for $RC_SVCDIR, provide our own
|
2009-04-26 21:13:26 +00:00
|
|
|
if ! fstabinfo --mount "$RC_SVCDIR"; then
|
|
|
|
mount -n -t "$fs" $fsopts "$devdir" "$RC_SVCDIR"
|
2007-09-26 10:09:27 +00:00
|
|
|
fi
|
2007-04-05 11:18:42 +00:00
|
|
|
}
|
|
|
|
|
2009-05-23 20:38:12 +01:00
|
|
|
. "$RC_LIBEXECDIR"/sh/functions.sh
|
2007-11-23 12:04:11 +00:00
|
|
|
[ -r /etc/rc.conf ] && . /etc/rc.conf
|
2007-04-05 11:18:42 +00:00
|
|
|
|
|
|
|
# By default VServer already has /proc mounted, but OpenVZ does not!
|
2007-05-23 14:12:06 +00:00
|
|
|
# However, some of our users have an old proc image in /proc
|
|
|
|
# NFC how they managed that, but the end result means we have to test if
|
|
|
|
# /proc actually works or not. We to this by comparing uptime to one a second
|
|
|
|
# ago
|
|
|
|
mountproc=true
|
2007-09-26 10:09:27 +00:00
|
|
|
if [ -e /proc/uptime ]; then
|
2007-05-23 14:12:06 +00:00
|
|
|
up="$(cat /proc/uptime)"
|
|
|
|
sleep 1
|
2009-04-26 21:13:26 +00:00
|
|
|
if [ "$up" = "$(cat /proc/uptime)" ]; then
|
2007-05-23 14:12:06 +00:00
|
|
|
eerror "You have cruft in /proc that should be deleted"
|
|
|
|
else
|
|
|
|
einfo "/proc is already mounted, skipping"
|
|
|
|
mountproc=false
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2009-04-26 21:13:26 +00:00
|
|
|
if $mountproc; then
|
2007-04-05 11:18:42 +00:00
|
|
|
procfs="proc"
|
2009-04-26 21:13:26 +00:00
|
|
|
[ "$RC_UNAME" = "GNU/kFreeBSD" ] && proc="linprocfs"
|
2008-03-11 13:55:39 +00:00
|
|
|
ebegin "Mounting /proc"
|
2008-03-11 13:39:20 +00:00
|
|
|
if ! fstabinfo --mount /proc; then
|
2009-04-26 21:13:26 +00:00
|
|
|
mount -n -t "$procfs" -o noexec,nosuid,nodev proc /proc
|
2007-09-26 10:09:27 +00:00
|
|
|
fi
|
2007-04-05 11:18:42 +00:00
|
|
|
eend $?
|
|
|
|
fi
|
|
|
|
|
2009-05-23 20:38:12 +01:00
|
|
|
. "$RC_LIBEXECDIR"/sh/init-common-post.sh
|