2013-12-22 02:21:11 +05:30
|
|
|
#!@SBINDIR@/openrc-run
|
2015-12-05 04:22:19 +05:30
|
|
|
# Copyright (c) 2007-2015 The OpenRC Authors.
|
|
|
|
# See the Authors file at the top-level directory of this distribution and
|
|
|
|
# https://github.com/OpenRC/openrc/blob/master/AUTHORS
|
|
|
|
#
|
|
|
|
# This file is part of OpenRC. It is subject to the license terms in
|
|
|
|
# the LICENSE file found in the top-level directory of this
|
|
|
|
# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
|
|
|
|
# This file may not be copied, modified, propagated, or distributed
|
|
|
|
# except according to the terms contained in the LICENSE file.
|
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()
|
|
|
|
{
|
2016-07-31 23:31:17 +05:30
|
|
|
keyword -docker -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
|
|
|
|
|
2016-02-06 06:30:41 +05:30
|
|
|
# Setup Kernel Support for persistent storage
|
|
|
|
if [ -d /sys/fs/pstore ] && ! mountinfo -q /sys/fs/pstore; then
|
|
|
|
if grep -qs 'pstore$' /proc/filesystems; then
|
|
|
|
ebegin "Mounting persistent storage (pstore) filesystem"
|
|
|
|
mount -t pstore pstore -o ${sysfs_opts} /sys/fs/pstore
|
|
|
|
eend $?
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2016-10-04 22:21:24 +05:30
|
|
|
# set up kernel support for efivarfs
|
2016-10-06 09:13:56 +05:30
|
|
|
# The presence of /sys/firmware/efi indicates that the system was
|
|
|
|
# booted in efi mode.
|
|
|
|
if [ -d /sys/firmware/efi ]; then
|
|
|
|
if [ -d /sys/firmware/efi/efivars ] &&
|
|
|
|
! mountinfo -q /sys/firmware/efi/efivars; then
|
2017-03-08 05:10:18 +05:30
|
|
|
ebegin "Mounting efivarfs filesystem"
|
|
|
|
mount -n -t efivarfs -o ${sysfs_opts} \
|
|
|
|
efivarfs /sys/firmware/efi/efivars
|
|
|
|
eend $?
|
2013-06-25 01:01:58 +05:30
|
|
|
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
|
|
|
}
|