summary refs log tree commit diff
path: root/os/etc/s6-rc/src/mount
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xos/etc/s6-rc/src/mount-cgroups/cgroup-release-agent.sh19
-rw-r--r--os/etc/s6-rc/src/mount-cgroups/dependencies.d/mount-procfs0
-rwxr-xr-xos/etc/s6-rc/src/mount-cgroups/shell-up178
-rw-r--r--os/etc/s6-rc/src/mount-cgroups/type1
-rw-r--r--os/etc/s6-rc/src/mount-cgroups/up3
-rw-r--r--os/etc/s6-rc/src/mount-devfs/dependencies.d/mount-procfs0
-rw-r--r--os/etc/s6-rc/src/mount-devfs/type1
-rw-r--r--os/etc/s6-rc/src/mount-devfs/up52
-rw-r--r--os/etc/s6-rc/src/mount-filesystems/dependencies.d/modules0
-rw-r--r--os/etc/s6-rc/src/mount-filesystems/type1
-rw-r--r--os/etc/s6-rc/src/mount-filesystems/up3
-rw-r--r--os/etc/s6-rc/src/mount-procfs/type1
-rw-r--r--os/etc/s6-rc/src/mount-procfs/up7
-rw-r--r--os/etc/s6-rc/src/mount-sysfs/dependencies.d/mount-procfs0
-rw-r--r--os/etc/s6-rc/src/mount-sysfs/type1
-rw-r--r--os/etc/s6-rc/src/mount-sysfs/up66
-rw-r--r--os/etc/s6-rc/src/mount-tmpfs/type1
-rw-r--r--os/etc/s6-rc/src/mount-tmpfs/up2
-rw-r--r--os/etc/s6-rc/src/mount/contents.d/mount-cgroups0
-rw-r--r--os/etc/s6-rc/src/mount/contents.d/mount-devfs0
-rw-r--r--os/etc/s6-rc/src/mount/contents.d/mount-filesystems0
-rw-r--r--os/etc/s6-rc/src/mount/contents.d/mount-procfs0
-rw-r--r--os/etc/s6-rc/src/mount/contents.d/mount-sysfs0
-rw-r--r--os/etc/s6-rc/src/mount/contents.d/mount-tmpfs0
-rw-r--r--os/etc/s6-rc/src/mount/contents.d/remount-root0
-rw-r--r--os/etc/s6-rc/src/mount/contents.d/swap0
-rw-r--r--os/etc/s6-rc/src/mount/type1
27 files changed, 337 insertions, 0 deletions
diff --git a/os/etc/s6-rc/src/mount-cgroups/cgroup-release-agent.sh b/os/etc/s6-rc/src/mount-cgroups/cgroup-release-agent.sh
new file mode 100755
index 0000000..0a6ec17
--- /dev/null
+++ b/os/etc/s6-rc/src/mount-cgroups/cgroup-release-agent.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+# This is run by the kernel after the last task is removed from a
+# control group in the openrc hierarchy.
+
+# 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/HEAD/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/HEAD/LICENSE
+# This file may not be copied, modified, propagated, or distributed
+#    except according to the terms contained in the LICENSE file.
+
+cgroup=/sys/fs/cgroup/openrc
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+if [ -d ${cgroup}/"$1" ]; then
+	rmdir ${cgroup}/"$1"
+fi
diff --git a/os/etc/s6-rc/src/mount-cgroups/dependencies.d/mount-procfs b/os/etc/s6-rc/src/mount-cgroups/dependencies.d/mount-procfs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/os/etc/s6-rc/src/mount-cgroups/dependencies.d/mount-procfs
diff --git a/os/etc/s6-rc/src/mount-cgroups/shell-up b/os/etc/s6-rc/src/mount-cgroups/shell-up
new file mode 100755
index 0000000..f26a99e
--- /dev/null
+++ b/os/etc/s6-rc/src/mount-cgroups/shell-up
@@ -0,0 +1,178 @@
+#!/bin/sh
+# Copyright (c) 2017 The OpenRC Authors.
+# See the Authors file at the top-level directory of this distribution and
+# https://github.com/OpenRC/openrc/blob/HEAD/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/HEAD/LICENSE
+# This file may not be copied, modified, propagated, or distributed
+# except according to the terms contained in the LICENSE file.
+
+set -eux
+
+cgroup_opts=${cgroup_opts:-nodev,noexec,nosuid}
+rc_cgroup_mode=${cgroup_mode:-hybrid}
+rc_cgroup_controllers=${cgroup_controllers:-}
+rc_cgroup_memory_use_hierarchy=${cgroup_memory_use_hierarchy:-no}
+rc_cgroupsize=${cgroupsize:-10m}
+
+yesno()
+{
+	[ -z "$1" ] && return 1
+
+	case "$1" in
+	[Yy][Ee][Ss]|[Tt][Rr][Uu]|[Oo][Nn]|1) return 0 ;;
+	[Nn][Oo]|[Ff][Aa][Ll][Ss]|[Oo][Ff][Ff]|0) return 1 ;;
+	esac
+
+	local value=
+	eval value=\"\$$1\"
+	case "$value" in
+	[Yy][Ee][Ss]|[Tt][Rr][Uu]|[Oo][Nn]|1) return 0 ;;
+	[Nn][Oo]|[Ff][Aa][Ll][Ss]|[Oo][Ff][Ff]|0) return 1 ;;
+	*) echo "\$$1 is not set properly" >&2; return 2 ;;
+	esac
+}
+
+cgroup2_find_path()
+{
+	if grep -qw cgroup2 /proc/filesystems; then
+		case "${rc_cgroup_mode}" in
+		hybrid) printf "/sys/fs/cgroup/unified" ;;
+		unified) printf "/sys/fs/cgroup" ;;
+		esac
+	fi
+	return 0
+}
+
+cgroup1_base()
+{
+	grep -qw cgroup /proc/filesystems || return 0
+	if ! mountpoint -q /sys/fs/cgroup; then
+		local opts="${cgroup_opts},mode=755,size=${rc_cgroupsize:-10m}"
+		mount -n -t tmpfs -o "${opts}" cgroup_root /sys/fs/cgroup
+	fi
+
+	if ! mountpoint -q /sys/fs/cgroup/openrc; then
+		local agent="/etc/s6-rc/src/mount-cgroups/cgroup-release-agent.sh"
+		mkdir /sys/fs/cgroup/openrc
+		mount -n -t cgroup \
+			-o none,${cgroup_opts},name=openrc,release_agent="$agent" \
+			openrc /sys/fs/cgroup/openrc
+		printf 1 > /sys/fs/cgroup/openrc/notify_on_release
+	fi
+	return 0
+}
+
+cgroup1_controllers()
+{
+	yesno "${rc_controller_cgroups:-YES}" && [ -e /proc/cgroups ]  &&
+	grep -qw cgroup /proc/filesystems || return 0
+	while read -r name _ _ enabled _; do
+		case "${enabled}" in
+			1)	mountpoint -q "/sys/fs/cgroup/${name}" && continue
+				local x
+				for x in $rc_cgroup_controllers; do
+				[ "${name}" = "blkio" ] && [ "${x}" = "io" ] &&
+					continue 2
+				[ "${name}" = "${x}" ] &&
+				continue 2
+				done
+				mkdir "/sys/fs/cgroup/${name}"
+				mount -n -t cgroup -o "${cgroup_opts},${name}" \
+					"${name}" "/sys/fs/cgroup/${name}"
+				yesno "${rc_cgroup_memory_use_hierarchy:-no}" &&
+					[ "${name}" = memory ] &&
+					echo 1 > /sys/fs/cgroup/memory/memory.use_hierarchy
+				;;
+		esac
+	done < /proc/cgroups
+	return 0
+}
+
+cgroup2_base()
+{
+	grep -qw cgroup2 /proc/filesystems || return 0
+	local base
+	base="$(cgroup2_find_path)"
+	if ! mountpoint -q "${base}"; then
+		mkdir -p "${base}"
+		mount -t cgroup2 none -o "${cgroup_opts},nsdelegate" "${base}" 2> /dev/null ||
+			mount -t cgroup2 none -o "${cgroup_opts}" "${base}"
+	fi
+	return 0
+}
+
+cgroup2_controllers()
+{
+	grep -qw cgroup2 /proc/filesystems || return 0
+	local active cgroup_path x y
+	cgroup_path="$(cgroup2_find_path)"
+	[ -z "${cgroup_path}" ] && return 0
+	[ ! -e "${cgroup_path}/cgroup.controllers" ] && return 0
+	[ ! -e "${cgroup_path}/cgroup.subtree_control" ]&& return 0
+	read -r active < "${cgroup_path}/cgroup.controllers"
+	for x in ${active}; do
+	case "${rc_cgroup_mode}" in
+		unified)
+			echo "+${x}"  > "${cgroup_path}/cgroup.subtree_control"
+			;;
+		hybrid)
+			for y in ${rc_cgroup_controllers}; do
+				if [ "$x" = "$y" ]; then
+					echo "+${x}"  > "${cgroup_path}/cgroup.subtree_control"
+				fi
+			done
+			;;
+		esac
+	done
+	return 0
+}
+
+cgroups_hybrid()
+{
+	cgroup1_base
+	cgroup2_base
+	cgroup2_controllers
+	cgroup1_controllers
+	return 0
+}
+
+cgroups_legacy()
+{
+	cgroup1_base
+	cgroup1_controllers
+	return 0
+}
+
+cgroups_unified()
+{
+	cgroup2_base
+	cgroup2_controllers
+	return 0
+}
+
+mount_cgroups()
+{
+	case "${rc_cgroup_mode}" in
+	hybrid) cgroups_hybrid ;;
+	unified) cgroups_unified ;;
+	legacy) cgroups_legacy ;;
+	esac
+	return 0
+}
+
+restorecon_cgroups()
+{
+	if [ -x /sbin/restorecon ]; then
+		restorecon -rF /sys/fs/cgroup >/dev/null 2>&1
+	fi
+	return 0
+}
+
+# set up kernel support for cgroups
+if [ -d /sys/fs/cgroup ]; then
+	mount_cgroups
+	restorecon_cgroups
+fi
diff --git a/os/etc/s6-rc/src/mount-cgroups/type b/os/etc/s6-rc/src/mount-cgroups/type
new file mode 100644
index 0000000..bdd22a1
--- /dev/null
+++ b/os/etc/s6-rc/src/mount-cgroups/type
@@ -0,0 +1 @@
+oneshot
diff --git a/os/etc/s6-rc/src/mount-cgroups/up b/os/etc/s6-rc/src/mount-cgroups/up
new file mode 100644
index 0000000..87c9a66
--- /dev/null
+++ b/os/etc/s6-rc/src/mount-cgroups/up
@@ -0,0 +1,3 @@
+#!/bin/execlineb -P
+envfile /etc/s6-rc/config/cgroups.conf
+exec sh /etc/s6-rc/src/mount-cgroups/shell-up
diff --git a/os/etc/s6-rc/src/mount-devfs/dependencies.d/mount-procfs b/os/etc/s6-rc/src/mount-devfs/dependencies.d/mount-procfs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/os/etc/s6-rc/src/mount-devfs/dependencies.d/mount-procfs
diff --git a/os/etc/s6-rc/src/mount-devfs/type b/os/etc/s6-rc/src/mount-devfs/type
new file mode 100644
index 0000000..bdd22a1
--- /dev/null
+++ b/os/etc/s6-rc/src/mount-devfs/type
@@ -0,0 +1 @@
+oneshot
diff --git a/os/etc/s6-rc/src/mount-devfs/up b/os/etc/s6-rc/src/mount-devfs/up
new file mode 100644
index 0000000..bbb8ec5
--- /dev/null
+++ b/os/etc/s6-rc/src/mount-devfs/up
@@ -0,0 +1,52 @@
+#!/bin/execlineb -P
+
+# mount /dev through fstab
+foreground {
+	if -n { mountpoint -q /dev }
+		if -t { fstabinfo -q /dev } fstabinfo -q --mount /dev
+}
+# or manually
+foreground {
+	if -n { mountpoint -q /dev }
+		ifelse -n { grep -q devtmpfs /proc/filesystems } { echo "This kernel doesn't have support for devtmpfs! This means /dev will not be mounted." }
+			mount -n -t devtmpfs dev /dev -o mode=0755,noexec,nosuid,size=10M
+}
+
+# creating console, tty1 and tty to be able to write to console
+# with/without bootsplash before udevd creates it
+foreground { if -n { test -c /dev/console } mknod -m 600 /dev/console c 5 1 }
+foreground { if -n { test -c /dev/tty1 } mknod -m 620 /dev/tty1 c 4 1 }
+foreground { if -n { test -c /dev/tty } mknod -m 666 /dev/tty c 5 0 }
+
+# udevd will dup it's std{in,out,err} to /dev/null
+# and we don't want a file which gets buffered in ram
+foreground { if -n { test -c /dev/null } mknod -m 666 /dev/null c 1 3 }
+
+# so udev can add it's start message to dmesg
+foreground { if -n { test -c /dev/kmesg } mknod -m 660 /dev/kmesg c 1 11 }
+
+# extra symlinks
+foreground { ln -snf /proc/self/fd /dev/fd }
+foreground { ln -snf /proc/self/fd/0 /dev/stdin }
+foreground { ln -snf /proc/self/fd/1 /dev/stdout }
+foreground { ln -snf /proc/self/fd/2 /dev/stderr }
+foreground { ln -snf /proc/kcore /dev/core }
+
+# mount required dirs that may not be in /etc/fstab
+foreground { mkdir -m 1777 -p /dev/mqueue }
+foreground {
+	if -n { mountpoint -q /dev/mqueue }
+		mount -n -t mqueue mqueue /dev/mqueue -o nosuid,noexec,nodev
+}
+
+foreground { mkdir -m 0755 -p /dev/pts }
+foreground {
+	if -n { mountpoint -q /dev/pts }
+		mount -n -t devpts devpts /dev/pts -o gid=5,mode=0620,nosuid,noexec
+}
+
+foreground { mkdir -m 1777 -p /dev/shm }
+foreground {
+	if -n { mountpoint -q /dev/shm }
+		mount -n -t tmpfs shm /dev/shm -o mode=1777,nosuid,noexec,nodev
+}
diff --git a/os/etc/s6-rc/src/mount-filesystems/dependencies.d/modules b/os/etc/s6-rc/src/mount-filesystems/dependencies.d/modules
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/os/etc/s6-rc/src/mount-filesystems/dependencies.d/modules
diff --git a/os/etc/s6-rc/src/mount-filesystems/type b/os/etc/s6-rc/src/mount-filesystems/type
new file mode 100644
index 0000000..bdd22a1
--- /dev/null
+++ b/os/etc/s6-rc/src/mount-filesystems/type
@@ -0,0 +1 @@
+oneshot
diff --git a/os/etc/s6-rc/src/mount-filesystems/up b/os/etc/s6-rc/src/mount-filesystems/up
new file mode 100644
index 0000000..25fcdf7
--- /dev/null
+++ b/os/etc/s6-rc/src/mount-filesystems/up
@@ -0,0 +1,3 @@
+#!/bin/execlineb -P
+
+foreground { mount -a -O no_netdev }
diff --git a/os/etc/s6-rc/src/mount-procfs/type b/os/etc/s6-rc/src/mount-procfs/type
new file mode 100644
index 0000000..bdd22a1
--- /dev/null
+++ b/os/etc/s6-rc/src/mount-procfs/type
@@ -0,0 +1 @@
+oneshot
diff --git a/os/etc/s6-rc/src/mount-procfs/up b/os/etc/s6-rc/src/mount-procfs/up
new file mode 100644
index 0000000..d950f34
--- /dev/null
+++ b/os/etc/s6-rc/src/mount-procfs/up
@@ -0,0 +1,7 @@
+#!/bin/execlineb -P
+
+foreground {
+	if -n { test -e /proc/mounts }
+		if -n { mountpoint -q /proc }
+			mount -t proc proc /proc -o nosuid,noexec,nodev
+}
diff --git a/os/etc/s6-rc/src/mount-sysfs/dependencies.d/mount-procfs b/os/etc/s6-rc/src/mount-sysfs/dependencies.d/mount-procfs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/os/etc/s6-rc/src/mount-sysfs/dependencies.d/mount-procfs
diff --git a/os/etc/s6-rc/src/mount-sysfs/type b/os/etc/s6-rc/src/mount-sysfs/type
new file mode 100644
index 0000000..bdd22a1
--- /dev/null
+++ b/os/etc/s6-rc/src/mount-sysfs/type
@@ -0,0 +1 @@
+oneshot
diff --git a/os/etc/s6-rc/src/mount-sysfs/up b/os/etc/s6-rc/src/mount-sysfs/up
new file mode 100644
index 0000000..d84627f
--- /dev/null
+++ b/os/etc/s6-rc/src/mount-sysfs/up
@@ -0,0 +1,66 @@
+#!/bin/execlineb -P
+
+# /sys
+foreground {
+	if -n { test -d /sys } mkdir -m 0755 /sys
+	if -n { mountpoint -q /sys }
+		mount -t sysfs sys /sys -o nosuid,noexec,nodev
+
+}
+
+# securityfs
+foreground {
+	if -t { test -d /sys/kernel/security }
+	if -t { grep -qs securityfs /proc/filesystems }
+	if -n { mountpoint -q /sys/kernel/security }
+		mount -t securityfs securityfs /sys/kernel/security -o nosuid,noexec,nodev
+}
+
+# debugfs
+foreground {
+	if -t { test -d /sys/kernel/debug }
+	if -t { grep -qs debugfs /proc/filesystems }
+	if -n { mountpoint -q /sys/kernel/debug }
+		mount -t debugfs debugfs /sys/kernel/debug -o nosuid,noexec,nodev
+}
+
+# configfs
+foreground {
+	if -t { test -d /sys/kernel/config }
+	if -t { grep -qs configfs /proc/filesystems }
+	if -n { mountpoint -q /sys/kernel/config }
+		mount -t configfs configfs /sys/kernel/config -o nosuid,noexec,nodev
+}
+
+# fusectl
+foreground {
+	if -t { test -d /sys/fs/fuse/connections }
+	if -t { grep -qs fusectl /proc/filesystems }
+	if -n { mountpoint -q /sys/fs/fuse/connections }
+		mount -t fusectl fusectl /sys/fs/fuse/connections -o nosuid,noexec,nodev
+}
+
+# pstore
+foreground {
+	if -t { test -d /sys/fs/pstore }
+	if -t { grep -qs 'pstore$' /proc/filesystems }
+	if -n { mountpoint -q /sys/fs/pstore }
+		mount -t pstore pstore /sys/fs/pstore -o nosuid,noexec,nodev
+}
+
+# selinux
+foreground {
+	if -t { test -d /sys/fs/selinux }
+	if -t { grep -qs selinuxfs /proc/filesystems }
+	if -n { mountpoint -q /sys/fs/selinux }
+		mount -t selinuxfs selinuxfs /sys/fs/selinux -o nosuid,noexec,nodev
+}
+
+# efivarfs
+foreground {
+	if -t { test -d /sys/firmware/efi }
+	if -t { grep -qs efivarfs /proc/filesystems }
+	if { test -d /sys/firmware/efi }
+		if -n { mountpoint -q /sys/firmware/efi/efivars }
+			mount -n -t efivarfs efivarfs /sys/firmware/efi/efivars -o ro,nosuid,noexec,nodev
+}
diff --git a/os/etc/s6-rc/src/mount-tmpfs/type b/os/etc/s6-rc/src/mount-tmpfs/type
new file mode 100644
index 0000000..bdd22a1
--- /dev/null
+++ b/os/etc/s6-rc/src/mount-tmpfs/type
@@ -0,0 +1 @@
+oneshot
diff --git a/os/etc/s6-rc/src/mount-tmpfs/up b/os/etc/s6-rc/src/mount-tmpfs/up
new file mode 100644
index 0000000..f93bc72
--- /dev/null
+++ b/os/etc/s6-rc/src/mount-tmpfs/up
@@ -0,0 +1,2 @@
+#!/bin/execlineb -P
+foreground { if -n { mountpoint -q /tmp } mount -t tmpfs tmpfs /tmp }
diff --git a/os/etc/s6-rc/src/mount/contents.d/mount-cgroups b/os/etc/s6-rc/src/mount/contents.d/mount-cgroups
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/os/etc/s6-rc/src/mount/contents.d/mount-cgroups
diff --git a/os/etc/s6-rc/src/mount/contents.d/mount-devfs b/os/etc/s6-rc/src/mount/contents.d/mount-devfs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/os/etc/s6-rc/src/mount/contents.d/mount-devfs
diff --git a/os/etc/s6-rc/src/mount/contents.d/mount-filesystems b/os/etc/s6-rc/src/mount/contents.d/mount-filesystems
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/os/etc/s6-rc/src/mount/contents.d/mount-filesystems
diff --git a/os/etc/s6-rc/src/mount/contents.d/mount-procfs b/os/etc/s6-rc/src/mount/contents.d/mount-procfs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/os/etc/s6-rc/src/mount/contents.d/mount-procfs
diff --git a/os/etc/s6-rc/src/mount/contents.d/mount-sysfs b/os/etc/s6-rc/src/mount/contents.d/mount-sysfs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/os/etc/s6-rc/src/mount/contents.d/mount-sysfs
diff --git a/os/etc/s6-rc/src/mount/contents.d/mount-tmpfs b/os/etc/s6-rc/src/mount/contents.d/mount-tmpfs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/os/etc/s6-rc/src/mount/contents.d/mount-tmpfs
diff --git a/os/etc/s6-rc/src/mount/contents.d/remount-root b/os/etc/s6-rc/src/mount/contents.d/remount-root
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/os/etc/s6-rc/src/mount/contents.d/remount-root
diff --git a/os/etc/s6-rc/src/mount/contents.d/swap b/os/etc/s6-rc/src/mount/contents.d/swap
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/os/etc/s6-rc/src/mount/contents.d/swap
diff --git a/os/etc/s6-rc/src/mount/type b/os/etc/s6-rc/src/mount/type
new file mode 100644
index 0000000..757b422
--- /dev/null
+++ b/os/etc/s6-rc/src/mount/type
@@ -0,0 +1 @@
+bundle