summary refs log tree commit diff
path: root/os/etc/s6-rc/src/mount-devfs/up
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2023-09-25 11:56:34 +0200
committerRobert Günzler <r@gnzler.io>2023-09-25 11:56:34 +0200
commitf5c219983c0f60a07f1bd52b6f6071e86f35455e (patch)
treeb7520a02b9822481f29aea4ccb404744a73414b1 /os/etc/s6-rc/src/mount-devfs/up
parent91ba318df1ff9b04d08af373ae904f61a91bf489 (diff)
add os config
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to 'os/etc/s6-rc/src/mount-devfs/up')
-rw-r--r--os/etc/s6-rc/src/mount-devfs/up52
1 files changed, 52 insertions, 0 deletions
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
+}