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
|
2021-12-21 06:37:00 +05:30
|
|
|
# https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS
|
2015-12-05 04:22:19 +05:30
|
|
|
#
|
|
|
|
# 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
|
2021-12-21 06:37:00 +05:30
|
|
|
# distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE
|
2015-12-05 04:22:19 +05:30
|
|
|
# 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
|
2017-03-13 00:25:49 +05:30
|
|
|
if [ -d /sys/firmware/efi/efivars ] &&
|
|
|
|
! mountinfo -q /sys/firmware/efi/efivars; then
|
|
|
|
ebegin "Mounting efivarfs filesystem"
|
2018-08-14 20:51:27 +05:30
|
|
|
mount -n -t efivarfs -o ${sysfs_opts} \
|
2017-03-13 00:25:49 +05:30
|
|
|
efivarfs /sys/firmware/efi/efivars 2> /dev/null
|
|
|
|
eend 0
|
2013-06-25 01:01:58 +05:30
|
|
|
fi
|
2011-12-20 13:12:36 +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
|
|
|
|
eend $?
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2008-10-10 14:07:21 +05:30
|
|
|
start()
|
|
|
|
{
|
|
|
|
mount_sys
|
2014-11-23 21:58:21 +05:30
|
|
|
mount_misc
|
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
|
|
|
}
|