aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-08-04 04:00:05 +0900
committerOphestra <cat@gensokyo.uk>2025-08-04 04:00:05 +0900
commit9a25542c6d23fd4dc12f25fa914e6f560f4d7324 (patch)
treeb22c301ddc8f5a27711daeb68adbf9c5ca52c938
parentc6be82bcf91fc4b6e61d9df40213e80367addbd8 (diff)
container/init: use mount string constants
These literals were missed when the constants were first defined. Signed-off-by: Ophestra <cat@gensokyo.uk>
-rw-r--r--container/init.go8
-rw-r--r--container/mount.go2
2 files changed, 6 insertions, 4 deletions
diff --git a/container/init.go b/container/init.go
index 68132437..c8274317 100644
--- a/container/init.go
+++ b/container/init.go
@@ -117,7 +117,7 @@ func Init(prepare func(prefix string), setVerbose func(verbose bool)) {
// cache sysctl before pivot_root
LastCap()
- if err := Mount("", FHSRoot, "", MS_SILENT|MS_SLAVE|MS_REC, ""); err != nil {
+ if err := Mount(zeroString, FHSRoot, zeroString, MS_SILENT|MS_SLAVE|MS_REC, zeroString); err != nil {
log.Fatalf("cannot make / rslave: %v", err)
}
@@ -138,7 +138,7 @@ func Init(prepare func(prefix string), setVerbose func(verbose bool)) {
}
}
- if err := Mount("rootfs", intermediateHostPath, "tmpfs", MS_NODEV|MS_NOSUID, ""); err != nil {
+ if err := Mount(SourceTmpfsRootfs, intermediateHostPath, FstypeTmpfs, MS_NODEV|MS_NOSUID, zeroString); err != nil {
log.Fatalf("cannot mount intermediate root: %v", err)
}
if err := os.Chdir(intermediateHostPath); err != nil {
@@ -148,7 +148,7 @@ func Init(prepare func(prefix string), setVerbose func(verbose bool)) {
if err := os.Mkdir(sysrootDir, 0755); err != nil {
log.Fatalf("%v", err)
}
- if err := Mount(sysrootDir, sysrootDir, "", MS_SILENT|MS_MGC_VAL|MS_BIND|MS_REC, ""); err != nil {
+ if err := Mount(sysrootDir, sysrootDir, zeroString, MS_SILENT|MS_BIND|MS_REC, zeroString); err != nil {
log.Fatalf("cannot bind sysroot: %v", err)
}
@@ -179,7 +179,7 @@ func Init(prepare func(prefix string), setVerbose func(verbose bool)) {
}
// setup requiring host root complete at this point
- if err := Mount(hostDir, hostDir, "", MS_SILENT|MS_REC|MS_PRIVATE, ""); err != nil {
+ if err := Mount(hostDir, hostDir, zeroString, MS_SILENT|MS_REC|MS_PRIVATE, zeroString); err != nil {
log.Fatalf("cannot make host root rprivate: %v", err)
}
if err := Unmount(hostDir, MNT_DETACH); err != nil {
diff --git a/container/mount.go b/container/mount.go
index 919b6e02..821cdc0e 100644
--- a/container/mount.go
+++ b/container/mount.go
@@ -41,6 +41,8 @@ const (
// Note that any source value is allowed when fstype is [FstypeMqueue].
SourceMqueue = "mqueue"
+ // SourceTmpfsRootfs is used when mounting the tmpfs instance backing the intermediate root.
+ SourceTmpfsRootfs = "rootfs"
// SourceTmpfsDevtmpfs is used when mounting tmpfs representing a subset of host devtmpfs.
SourceTmpfsDevtmpfs = "devtmpfs"
// SourceTmpfsEphemeral is used when mounting a writable instance of tmpfs.