From ad0302ab8213e35070e50beba03d8da5c57f4fc4 Mon Sep 17 00:00:00 2001 From: uxtbd Date: Tue, 18 Aug 2026 10:41:53 -0300 Subject: 4suite: move to shinobi --- 4rc/4rc.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 4rc/4rc.c (limited to '4rc/4rc.c') diff --git a/4rc/4rc.c b/4rc/4rc.c new file mode 100644 index 0000000..68a5d9f --- /dev/null +++ b/4rc/4rc.c @@ -0,0 +1,56 @@ +#define _POSIX_C_SOURCE 200809L + +#include +#include +#include +#include +#include + +void create_vfs(void) { + mkdir("/proc", 0755); + mkdir("/sys", 0755); + mkdir("/dev", 0755); + mkdir("/run", 0755); +} + +void mount_vfs(void) { + if (mount("proc", "/proc", "proc", + MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_RELATIME, NULL) != 0) { + perror("mount /proc"); + } + + if (mount("sys", "/sys", "sysfs", + MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_RELATIME, NULL) != 0) { + perror("mount /sys"); + } + + if (mount("dev", "/dev", "devtmpfs", MS_NOSUID | MS_RELATIME, "mode=755") != + 0) { + perror("mount /dev"); + } + + if (mount("run", "/run", "tmpfs", MS_NOSUID | MS_NODEV | MS_RELATIME, + "mode=755") != 0) { + perror("mount /run"); + } + + mkdir("/dev/pts", 0755); + mkdir("/dev/shm", 1777); + + if (mount("devpts", "/dev/pts", "devpts", + MS_NOSUID | MS_NOEXEC | MS_RELATIME, "gid=5,mode=620") != 0) { + perror("mount /dev/pts"); + } + + if (mount("shm", "/dev/shm", "tmpfs", MS_NOSUID | MS_NODEV | MS_RELATIME, + "mode=1777") != 0) { + perror("mount /dev/shm"); + } +} + +int main(void) { + create_vfs(); + mount_vfs(); + + return 0; +} -- cgit v1.3.1