ce4c9b5397
This creates the "openrc" control group with no subsystems attached. The next step will be to add everything openrc starts to this group.
112 lines
2.5 KiB
Plaintext
112 lines
2.5 KiB
Plaintext
#!@PREFIX@/sbin/runscript
|
|
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
|
|
# Released under the 2-clause BSD license.
|
|
|
|
description="Mount the sys filesystem."
|
|
|
|
depend()
|
|
{
|
|
keyword -prefix -vserver
|
|
}
|
|
|
|
mount_sys()
|
|
{
|
|
grep -Eq "[[:space:]]+sysfs$" /proc/filesystems || return 1
|
|
mountinfo -q /sys && return 0
|
|
|
|
if [ ! -d /sys ]; then
|
|
if ! mkdir -m 0755 /sys; then
|
|
ewarn "Could not create /sys!"
|
|
return 1
|
|
fi
|
|
fi
|
|
|
|
ebegin "Mounting /sys"
|
|
if ! fstabinfo --mount /sys; then
|
|
mount -n -t sysfs -o noexec,nosuid,nodev sysfs /sys
|
|
fi
|
|
eend $?
|
|
}
|
|
|
|
mount_misc()
|
|
{
|
|
# Setup Kernel Support for securityfs
|
|
if [ -d /sys/kernel/security ] && \
|
|
! mountinfo -q /sys/kernel/security; then
|
|
if grep -qs securityfs /proc/filesystems; then
|
|
ebegin "Mounting security filesystem"
|
|
mount -n -t securityfs -o nodev,noexec,nosuid \
|
|
securityfs /sys/kernel/security
|
|
eend $?
|
|
fi
|
|
fi
|
|
|
|
# Setup Kernel Support for debugfs
|
|
if [ -d /sys/kernel/debug ] && ! mountinfo -q /sys/kernel/debug; then
|
|
if grep -qs debugfs /proc/filesystems; then
|
|
ebegin "Mounting debug filesystem"
|
|
mount -n -t debugfs -o nodev,noexec,nosuid \
|
|
debugfs /sys/kernel/debug
|
|
eend $?
|
|
fi
|
|
fi
|
|
|
|
# Setup Kernel Support for configfs
|
|
if [ -d /sys/kernel/config ] && ! mountinfo -q /sys/kernel/config; then
|
|
if grep -qs configfs /proc/filesystems; then
|
|
ebegin "Mounting config filesystem"
|
|
mount -n -t configfs -o nodev,noexec,nosuid \
|
|
configfs /sys/kernel/config
|
|
eend $?
|
|
fi
|
|
fi
|
|
|
|
# set up kernel support for cgroups
|
|
if [ -d /sys/fs/cgroup ] && ! mountinfo -q /sys/fs/cgroup; then
|
|
if grep -qs cgroup /proc/filesystems; then
|
|
ebegin "Mounting cgroup filesystem"
|
|
local opts="nodev,noexec,nosuid,mode=755,size=${rc_cgroupsize:-10m}"
|
|
mount -n -t tmpfs -o ${opts} cgroup_root /sys/fs/cgroup
|
|
eend $?
|
|
fi
|
|
fi
|
|
}
|
|
|
|
mount_cgroups()
|
|
{
|
|
yesno ${rc_cgroups:-YES} || return 0
|
|
if [ ! -e /proc/cgroups ]; then
|
|
return 0
|
|
fi
|
|
|
|
local agent="@LIBEXECDIR@/sh/cgroup-release-agent.sh"
|
|
mkdir /sys/fs/cgroup/openrc
|
|
mount -t cgroup \
|
|
-o none,nodev,noexec,nosuid,name=openrc,release_agent="$agent" \
|
|
openrc /sys/fs/cgroup/openrc
|
|
while read name hier groups enabled rest; do
|
|
case "${enabled}" in
|
|
1) mkdir /sys/fs/cgroup/${name}
|
|
mount -t cgroup -o nodev,noexec,nosuid,${name} \
|
|
${name} /sys/fs/cgroup/${name}
|
|
;;
|
|
esac
|
|
done < /proc/cgroups
|
|
}
|
|
|
|
start()
|
|
{
|
|
local retval
|
|
mount_sys
|
|
retval=$?
|
|
if [ $retval -eq 0 ]; then
|
|
mount_misc
|
|
retval=$?
|
|
fi
|
|
if [ $retval -eq 0 ]; then
|
|
mount_cgroups
|
|
retval=$?
|
|
fi
|
|
return $retval
|
|
}
|