aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-11-08 18:55:19 +0900
committerOphestra <cat@gensokyo.uk>2026-11-08 19:17:35 +0900
commit8c15959571568b231afe1eb3358ca3da7c00b026 (patch)
treeb4d1b33e2fc06da00cc47beadad740b86113acca
parent085498b62ca37414d7c97fca9063526032c1f36e (diff)
cmd/hsu: move Rosa OS hsurc
This file is generated by the operating system. Pointing it to /system requires ugly tricks to bind mount over it. Signed-off-by: Ophestra <cat@gensokyo.uk>
-rw-r--r--cmd/earlyinit/hsu.go32
-rw-r--r--cmd/earlyinit/main.go26
-rw-r--r--cmd/hsu/conf.go2
-rw-r--r--cmd/hsu/conf_rosa.go7
-rw-r--r--cmd/hsu/config_rosa.go7
5 files changed, 66 insertions, 8 deletions
diff --git a/cmd/earlyinit/hsu.go b/cmd/earlyinit/hsu.go
new file mode 100644
index 00000000..ea25c1a9
--- /dev/null
+++ b/cmd/earlyinit/hsu.go
@@ -0,0 +1,32 @@
+package main
+
+import (
+ "os"
+ "strconv"
+)
+
+// updateHsu replaces the hsurc file.
+func updateHsu(pairs [][2]uint32) error {
+ w, err := os.OpenFile(
+ "/misc/hsurc",
+ os.O_CREATE|os.O_TRUNC|os.O_WRONLY,
+ 0400,
+ )
+ if err != nil {
+ return err
+ }
+
+ buf := make([]byte, 0, os.Getpagesize())
+ for _, pair := range pairs {
+ buf = buf[:0]
+ buf = strconv.AppendUint(buf, uint64(pair[0]), 10)
+ buf = append(buf, ' ')
+ buf = strconv.AppendUint(buf, uint64(pair[1]), 10)
+ buf = append(buf, '\n')
+ if _, err = w.Write(buf); err != nil {
+ _ = w.Close()
+ return err
+ }
+ }
+ return w.Close()
+}
diff --git a/cmd/earlyinit/main.go b/cmd/earlyinit/main.go
index fff80bd8..62f87833 100644
--- a/cmd/earlyinit/main.go
+++ b/cmd/earlyinit/main.go
@@ -102,6 +102,8 @@ const (
flagMountTmp = "mount_tmp"
// flag9P arranges for a host directory to be mounted at /host/.
flag9P = "9p"
+ // flagEarlyHsu arranges for hardcoded hsurc pairings to be set early.
+ flagEarlyHsu = "early_hsurc"
)
func main() {
@@ -280,6 +282,30 @@ func main() {
must(os.MkdirAll("/usr/bin", 0555))
must(os.Symlink("../../system/bin/env", "/usr/bin/env"))
+ must(os.Mkdir("/misc", 0))
+ mustSyscall("mount misc", Mount(
+ "misc",
+ "/misc",
+ "tmpfs",
+ MS_NOATIME|MS_NODEV|MS_NOEXEC|MS_NOSUID,
+ "size=16M,mode=0555,noswap",
+ ))
+ mustSyscall("set misc MS_UNBINDABLE", Mount(
+ "",
+ "/misc",
+ "",
+ MS_UNBINDABLE,
+ "",
+ ))
+
+ // for testsuite
+ if slices.Contains(flags, flagEarlyHsu) {
+ must(updateHsu([][2]uint32{
+ {1000, 0},
+ {9999, 10},
+ }))
+ }
+
if slices.Contains(flags, flag9P) {
// avoid having to wait for the uevent loop
modprobe("-a", "9p", "9pnet_virtio", "virtio_pci")
diff --git a/cmd/hsu/conf.go b/cmd/hsu/conf.go
index 683bdc8a..79f5091a 100644
--- a/cmd/hsu/conf.go
+++ b/cmd/hsu/conf.go
@@ -2,6 +2,6 @@
package main
-// hsuConfPath is an absolute pathname to the hsu configuration file. Its
+// hsuConfPath is an absolute pathname of the hsu configuration file. Its
// contents are interpreted by parseConfig.
const hsuConfPath = "/etc/hsurc"
diff --git a/cmd/hsu/conf_rosa.go b/cmd/hsu/conf_rosa.go
new file mode 100644
index 00000000..4aef572d
--- /dev/null
+++ b/cmd/hsu/conf_rosa.go
@@ -0,0 +1,7 @@
+//go:build rosa
+
+package main
+
+// hsuConfPath is the absolute pathname of the hsu configuration file, specific
+// to Rosa OS. Its contents are interpreted by parseConfig.
+const hsuConfPath = "/misc/hsurc"
diff --git a/cmd/hsu/config_rosa.go b/cmd/hsu/config_rosa.go
deleted file mode 100644
index 30303dba..00000000
--- a/cmd/hsu/config_rosa.go
+++ /dev/null
@@ -1,7 +0,0 @@
-//go:build rosa
-
-package main
-
-// hsuConfPath is the pathname to the hsu configuration file, specific to
-// Rosa OS. Its contents are interpreted by parseConfig.
-const hsuConfPath = "/system/etc/hsurc"