2008-10-10 14:07:21 +05:30
|
|
|
#!@PREFIX@/sbin/runscript
|
2009-05-01 19:41:40 +05:30
|
|
|
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
|
2011-06-30 05:16:31 +05:30
|
|
|
# Released under the 2-clause BSD license.
|
2008-10-10 14:07:21 +05:30
|
|
|
|
|
|
|
description="Mount the sys filesystem."
|
|
|
|
|
|
|
|
depend()
|
|
|
|
{
|
2009-07-01 04:37:32 +05:30
|
|
|
keyword -prefix -vserver
|
2008-10-10 14:07:21 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2009-04-27 13:21:18 +05:30
|
|
|
if [ -d /sys/kernel/security ] && \
|
|
|
|
! mountinfo -q /sys/kernel/security; then
|
2008-10-10 14:07:21 +05:30
|
|
|
if grep -qs securityfs /proc/filesystems; then
|
|
|
|
ebegin "Mounting security filesystem"
|
2008-11-04 22:37:32 +05:30
|
|
|
mount -n -t securityfs -o nodev,noexec,nosuid \
|
2008-10-10 14:07:21 +05:30
|
|
|
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"
|
2008-11-04 22:37:32 +05:30
|
|
|
mount -n -t debugfs -o nodev,noexec,nosuid \
|
2008-10-10 14:07:21 +05:30
|
|
|
debugfs /sys/kernel/debug
|
|
|
|
eend $?
|
|
|
|
fi
|
|
|
|
fi
|
2011-10-26 02:35:00 +05:30
|
|
|
|
|
|
|
# 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
|
2011-12-19 01:03:27 +05:30
|
|
|
|
2011-12-20 13:12:36 +05:30
|
|
|
# set up kernel support for cgroups
|
2011-12-19 01:03:27 +05:30
|
|
|
if [ -d /sys/fs/cgroup ] && ! mountinfo -q /sys/fs/cgroup; then
|
|
|
|
if grep -qs cgroup /proc/filesystems; then
|
2011-10-26 02:35:00 +05:30
|
|
|
ebegin "Mounting cgroup filesystem"
|
2011-12-29 21:31:28 +05:30
|
|
|
local opts="nodev,noexec,nosuid,mode=755,size=${rc_cgroupsize:-10m}"
|
|
|
|
mount -n -t tmpfs -o ${opts} cgroup_root /sys/fs/cgroup
|
2011-10-26 02:35:00 +05:30
|
|
|
eend $?
|
|
|
|
fi
|
|
|
|
fi
|
2011-12-20 13:12:36 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
mount_cgroups()
|
|
|
|
{
|
2012-01-26 22:32:00 +05:30
|
|
|
yesno ${rc_cgroups:-YES} && [ -e /proc/cgroups ] && \
|
|
|
|
mountinfo -q /sys/fs/cgroup || return 0
|
2011-12-19 01:03:27 +05:30
|
|
|
|
2012-01-24 09:16:33 +05:30
|
|
|
local agent="@LIBEXECDIR@/sh/cgroup-release-agent.sh"
|
|
|
|
mkdir /sys/fs/cgroup/openrc
|
2012-01-27 22:44:50 +05:30
|
|
|
mount -n -t cgroup \
|
2012-01-24 09:16:33 +05:30
|
|
|
-o none,nodev,noexec,nosuid,name=openrc,release_agent="$agent" \
|
|
|
|
openrc /sys/fs/cgroup/openrc
|
2012-01-24 09:30:08 +05:30
|
|
|
echo 1 > /sys/fs/cgroup/openrc/notify_on_release
|
2011-12-19 01:03:27 +05:30
|
|
|
while read name hier groups enabled rest; do
|
|
|
|
case "${enabled}" in
|
|
|
|
1) mkdir /sys/fs/cgroup/${name}
|
2012-01-27 22:44:50 +05:30
|
|
|
mount -n -t cgroup -o nodev,noexec,nosuid,${name} \
|
2011-12-19 01:03:27 +05:30
|
|
|
${name} /sys/fs/cgroup/${name}
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done < /proc/cgroups
|
2008-10-10 14:07:21 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
start()
|
|
|
|
{
|
|
|
|
local retval
|
|
|
|
mount_sys
|
|
|
|
retval=$?
|
2009-04-27 13:21:18 +05:30
|
|
|
if [ $retval -eq 0 ]; then
|
2008-10-10 14:07:21 +05:30
|
|
|
mount_misc
|
2011-12-19 01:03:27 +05:30
|
|
|
retval=$?
|
|
|
|
fi
|
|
|
|
if [ $retval -eq 0 ]; then
|
|
|
|
mount_cgroups
|
|
|
|
retval=$?
|
2008-10-10 14:07:21 +05:30
|
|
|
fi
|
2009-04-27 13:21:18 +05:30
|
|
|
return $retval
|
2008-10-10 14:07:21 +05:30
|
|
|
}
|