From 0f78864a674092097f0be320f21fcfe687a517db Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sat, 2 Aug 2025 17:15:41 +0900 Subject: 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 --- container/ops.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'container/ops.go') 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 } -- cgit v1.3.1