aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/ops.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-08-02 17:15:41 +0900
committerOphestra <cat@gensokyo.uk>2025-08-02 17:20:09 +0900
commit0f78864a674092097f0be320f21fcfe687a517db (patch)
tree8c6fde36bfebb3822bbfd9c4ad6915831cdfb6a9 /container/ops.go
parentb32b1975a89d60beab75dfca723925131a06065b (diff)
container/mount: export mount string constants
This improves code readability and should also be useful for callers choosing to preserve CAP_SYS_ADMIN. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/ops.go')
-rw-r--r--container/ops.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/container/ops.go b/container/ops.go
index 7456ed38..42e03a9f 100644
--- a/container/ops.go
+++ b/container/ops.go
@@ -169,7 +169,7 @@ func (p MountProcOp) apply(params *Params) error {
if err := os.MkdirAll(target, params.ParentPerm); err != nil {
return wrapErrSelf(err)
}
- return wrapErrSuffix(Mount("proc", target, "proc", MS_NOSUID|MS_NOEXEC|MS_NODEV, ""),
+ return wrapErrSuffix(Mount(SourceProc, target, FstypeProc, MS_NOSUID|MS_NOEXEC|MS_NODEV, zeroString),
fmt.Sprintf("cannot mount proc on %q:", v))
}
@@ -196,7 +196,7 @@ func (d MountDevOp) apply(params *Params) error {
}
target := toSysroot(v)
- if err := mountTmpfs("devtmpfs", v, MS_NOSUID|MS_NODEV, 0, params.ParentPerm); err != nil {
+ if err := mountTmpfs(SourceTmpfsDevtmpfs, v, MS_NOSUID|MS_NODEV, 0, params.ParentPerm); err != nil {
return err
}
@@ -239,7 +239,7 @@ func (d MountDevOp) apply(params *Params) error {
}
}
- if err := Mount("devpts", devPtsPath, "devpts", MS_NOSUID|MS_NOEXEC,
+ if err := Mount(SourceDevpts, devPtsPath, FstypeDevpts, MS_NOSUID|MS_NOEXEC,
"newinstance,ptmxmode=0666,mode=620"); err != nil {
return wrapErrSuffix(err,
fmt.Sprintf("cannot mount devpts on %q:", devPtsPath))
@@ -294,7 +294,7 @@ func (m MountMqueueOp) apply(params *Params) error {
if err := os.MkdirAll(target, params.ParentPerm); err != nil {
return wrapErrSelf(err)
}
- return wrapErrSuffix(Mount("mqueue", target, "mqueue", MS_NOSUID|MS_NOEXEC|MS_NODEV, ""),
+ return wrapErrSuffix(Mount(SourceMqueue, target, FstypeMqueue, MS_NOSUID|MS_NOEXEC|MS_NODEV, zeroString),
fmt.Sprintf("cannot mount mqueue on %q:", v))
}
@@ -306,13 +306,13 @@ func init() { gob.Register(new(MountTmpfsOp)) }
// Tmpfs appends an [Op] that mounts tmpfs on container path [MountTmpfsOp.Path].
func (f *Ops) Tmpfs(dest string, size int, perm os.FileMode) *Ops {
- *f = append(*f, &MountTmpfsOp{"ephemeral", dest, MS_NOSUID | MS_NODEV, size, perm})
+ *f = append(*f, &MountTmpfsOp{SourceTmpfsEphemeral, dest, MS_NOSUID | MS_NODEV, size, perm})
return f
}
// Readonly appends an [Op] that mounts read-only tmpfs on container path [MountTmpfsOp.Path].
func (f *Ops) Readonly(dest string, perm os.FileMode) *Ops {
- *f = append(*f, &MountTmpfsOp{"readonly", dest, MS_RDONLY | MS_NOSUID | MS_NODEV, 0, perm})
+ *f = append(*f, &MountTmpfsOp{SourceTmpfsReadonly, dest, MS_RDONLY | MS_NOSUID | MS_NODEV, 0, perm})
return f
}