diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-08-01 18:58:42 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-08-01 18:59:06 +0900 |
| commit | 547a2adaa488556f0504e186c5c1dfb0e679c935 (patch) | |
| tree | 8c2f0fd5190d3e460672f5f7be50024baac15372 /container/ops.go | |
| parent | c02948e1557551a94b5366bf186148b8275598c1 (diff) | |
container/mount: pass tmpfs flags
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/ops.go')
| -rw-r--r-- | container/ops.go | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/container/ops.go b/container/ops.go index 85291da3..1fd4963c 100644 --- a/container/ops.go +++ b/container/ops.go @@ -170,7 +170,7 @@ func (d MountDevOp) apply(params *Params) error { } target := toSysroot(v) - if err := mountTmpfs("devtmpfs", v, 0, params.ParentPerm); err != nil { + if err := mountTmpfs("devtmpfs", v, MS_NOSUID|MS_NODEV, 0, params.ParentPerm); err != nil { return err } @@ -280,14 +280,22 @@ 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{dest, size, perm}) + *f = append(*f, &MountTmpfsOp{"ephemeral", 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}) return f } type MountTmpfsOp struct { - Path string - Size int - Perm os.FileMode + FSName string + Path string + Flags uintptr + Size int + Perm os.FileMode } func (t *MountTmpfsOp) early(*Params) error { return nil } @@ -298,7 +306,7 @@ func (t *MountTmpfsOp) apply(*Params) error { if t.Size < 0 || t.Size > math.MaxUint>>1 { return msg.WrapErr(EBADE, fmt.Sprintf("size %d out of bounds", t.Size)) } - return mountTmpfs("tmpfs", t.Path, t.Size, t.Perm) + return mountTmpfs(t.FSName, t.Path, t.Flags, t.Size, t.Perm) } func (t *MountTmpfsOp) Is(op Op) bool { vt, ok := op.(*MountTmpfsOp); return ok && *t == *vt } |
