From 8905d653ba8ac5f2a70a6df654ebfa2a17206729 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sat, 14 Mar 2026 19:42:43 +0900 Subject: [PATCH] cmd/earlyinit: mount pseudo-filesystems The proposal for merging both init programs was unanimously accepted, so this is set up here alongside devtmpfs. Signed-off-by: Ophestra --- cmd/earlyinit/main.go | 36 ++++++++++++++++++++++++++++++++++++ internal/rosa/all.go | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/cmd/earlyinit/main.go b/cmd/earlyinit/main.go index 6dc0803..4088330 100644 --- a/cmd/earlyinit/main.go +++ b/cmd/earlyinit/main.go @@ -72,4 +72,40 @@ func main() { } } + // staying in rootfs, these are no longer used + must(os.Remove("/root")) + must(os.Remove("/init")) + + must(os.Mkdir("/proc", 0)) + mustSyscall("mount proc", Mount( + "proc", + "/proc", + "proc", + MS_NOSUID|MS_NOEXEC|MS_NODEV, + "hidepid=1", + )) + + must(os.Mkdir("/sys", 0)) + mustSyscall("mount sysfs", Mount( + "sysfs", + "/sys", + "sysfs", + 0, + "", + )) + +} + +// mustSyscall calls [log.Fatalln] if err is non-nil. +func mustSyscall(action string, err error) { + if err != nil { + log.Fatalln("cannot "+action+":", err) + } +} + +// must calls [log.Fatal] with err if it is non-nil. +func must(err error) { + if err != nil { + log.Fatal(err) + } } diff --git a/internal/rosa/all.go b/internal/rosa/all.go index 7f4f1a9..13bc83a 100644 --- a/internal/rosa/all.go +++ b/internal/rosa/all.go @@ -20,7 +20,7 @@ const ( LLVMRuntimes LLVMClang - // EarlyInit is the Rosa OS initramfs init program. + // EarlyInit is the Rosa OS init program. EarlyInit // ImageSystem is the Rosa OS /system image. ImageSystem