2013-12-22 02:21:11 +05:30
|
|
|
#!@SBINDIR@/openrc-run
|
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."
|
|
|
|
|
2013-02-02 01:19:02 +05:30
|
|
|
sysfs_opts=nodev,noexec,nosuid
|
|
|
|
|
2008-10-10 14:07:21 +05:30
|
|
|
depend()
|
|
|
|
{
|
2015-04-29 06:33:49 +05:30
|
|
|
keyword -lxc -prefix -systemd-nspawn -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
|
2013-02-02 01:19:02 +05:30
|
|
|
mount -n -t sysfs -o ${sysfs_opts} sysfs /sys
|
2008-10-10 14:07:21 +05:30
|
|
|
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"
|
2013-02-02 01:19:02 +05:30
|
|
|
mount -n -t securityfs -o ${sysfs_opts} \
|
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"
|
2013-02-02 01:19:02 +05:30
|
|
|
mount -n -t debugfs -o ${sysfs_opts} debugfs /sys/kernel/debug
|
2008-10-10 14:07:21 +05:30
|
|
|
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"
|
2013-02-02 01:19:02 +05:30
|
|
|
mount -n -t configfs -o ${sysfs_opts} configfs /sys/kernel/config
|
2011-10-26 02:35:00 +05:30
|
|
|
eend $?
|
|
|
|
fi
|
|
|
|
fi
|
2011-12-19 01:03:27 +05:30
|
|
|
|
2013-02-02 01:19:02 +05:30
|
|
|
# set up kernel support for fusectl
|
|
|
|
if [ -d /sys/fs/fuse/connections ] \
|
|
|
|
&& ! mountinfo -q /sys/fs/fuse/connections; then
|
|
|
|
if grep -qs fusectl /proc/filesystems; then
|
|
|
|
ebegin "Mounting fuse control filesystem"
|
|
|
|
mount -n -t fusectl -o ${sysfs_opts} \
|
|
|
|
fusectl /sys/fs/fuse/connections
|
|
|
|
eend $?
|
|
|
|
fi
|
|
|
|
fi
|
2013-06-25 01:01:58 +05:30
|
|
|
|
2015-04-12 02:59:58 +05:30
|
|
|
# Setup Kernel Support for SELinux
|
|
|
|
if [ -d /sys/fs/selinux ] && ! mountinfo -q /sys/fs/selinux; then
|
|
|
|
if grep -qs selinuxfs /proc/filesystems; then
|
|
|
|
ebegin "Mounting SELinux filesystem"
|
|
|
|
mount -t selinuxfs selinuxfs /sys/fs/selinux
|
|
|
|
eend $?
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2013-06-25 01:01:58 +05:30
|
|
|
# setup up kernel support for efivarfs
|
|
|
|
# slightly complicated, as if it's build as a module but NOT yet loaded,
|
|
|
|
# it will NOT appear in /proc/filesystems yet
|
|
|
|
if [ -d /sys/firmware/efi/efivars ] \
|
|
|
|
&& ! mountinfo -q /sys/firmware/efi/efivars; then
|
|
|
|
modprobe -q efivarfs
|
|
|
|
if grep -qs efivarfs /proc/filesystems; then
|
|
|
|
ebegin "Mounting efivarfs filesystem"
|
|
|
|
mount -n -t efivarfs -o ${sysfs_opts} \
|
|
|
|
efivarfs /sys/firmware/efi/efivars
|
|
|
|
eend $?
|
|
|
|
fi
|
|
|
|
fi
|
2011-12-20 13:12:36 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
mount_cgroups()
|
|
|
|
{
|
2015-10-14 01:23:43 +05:30
|
|
|
# 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="${sysfs_opts},mode=755,size=${rc_cgroupsize:-10m}"
|
|
|
|
mount -n -t tmpfs -o ${opts} cgroup_root /sys/fs/cgroup
|
|
|
|
eend $?
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2014-07-15 02:28:50 +05:30
|
|
|
mountinfo -q /sys/fs/cgroup || return 0
|
2014-08-22 23:11:55 +05:30
|
|
|
|
|
|
|
if ! mountinfo -q /sys/fs/cgroup/openrc; then
|
|
|
|
local agent="@LIBEXECDIR@/sh/cgroup-release-agent.sh"
|
|
|
|
mkdir /sys/fs/cgroup/openrc
|
|
|
|
mount -n -t cgroup \
|
2014-09-17 04:14:30 +05:30
|
|
|
-o none,${sysfs_opts},name=openrc,release_agent="$agent" \
|
2014-08-22 23:11:55 +05:30
|
|
|
openrc /sys/fs/cgroup/openrc
|
2015-10-07 00:01:43 +05:30
|
|
|
printf 1 > /sys/fs/cgroup/openrc/notify_on_release
|
2014-08-22 23:11:55 +05:30
|
|
|
fi
|
2012-07-04 00:19:58 +05:30
|
|
|
|
|
|
|
yesno ${rc_controller_cgroups:-YES} && [ -e /proc/cgroups ] || return 0
|
2011-12-19 01:03:27 +05:30
|
|
|
while read name hier groups enabled rest; do
|
|
|
|
case "${enabled}" in
|
2014-11-23 21:58:21 +05:30
|
|
|
1) mountinfo -q /sys/fs/cgroup/${name} && continue
|
|
|
|
mkdir /sys/fs/cgroup/${name}
|
2014-09-17 04:14:30 +05:30
|
|
|
mount -n -t cgroup -o ${sysfs_opts},${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
|
|
|
}
|
|
|
|
|
2014-07-17 04:37:18 +05:30
|
|
|
restorecon_sys()
|
|
|
|
{
|
|
|
|
if [ -x /sbin/restorecon ]; then
|
|
|
|
ebegin "Restoring SELinux contexts in /sys"
|
|
|
|
restorecon -F /sys/devices/system/cpu/online >/dev/null 2>&1
|
|
|
|
restorecon -rF /sys/fs/cgroup >/dev/null 2>&1
|
|
|
|
eend $?
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2008-10-10 14:07:21 +05:30
|
|
|
start()
|
|
|
|
{
|
|
|
|
mount_sys
|
2014-11-23 21:58:21 +05:30
|
|
|
mount_misc
|
|
|
|
mount_cgroups
|
2014-07-17 04:37:18 +05:30
|
|
|
restorecon_sys
|
2014-11-23 21:58:21 +05:30
|
|
|
return 0
|
2008-10-10 14:07:21 +05:30
|
|
|
}
|