aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/sandbox/sequential.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-03-14 00:21:20 +0900
committerOphestra <cat@gensokyo.uk>2025-03-14 00:21:20 +0900
commit5d9e669d97ee53e3b6d4478d315319b59d5b402b (patch)
treee601580ad066b4054e773d473e8a3af2f1176c07 /internal/sandbox/sequential.go
parentf1002157a58a5a0a559ba9295c3193c300a4235d (diff)
sandbox: separate tmpfs function from op
This is useful in the implementation of various other ops. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/sandbox/sequential.go')
-rw-r--r--internal/sandbox/sequential.go18
1 files changed, 4 insertions, 14 deletions
diff --git a/internal/sandbox/sequential.go b/internal/sandbox/sequential.go
index d4a29fa5..445ae8f8 100644
--- a/internal/sandbox/sequential.go
+++ b/internal/sandbox/sequential.go
@@ -75,7 +75,7 @@ func init() { gob.Register(new(MountTmpfs)) }
type MountTmpfs struct {
Path string
Size int
- Mode os.FileMode
+ Perm os.FileMode
}
func (t *MountTmpfs) apply() error {
@@ -87,22 +87,12 @@ func (t *MountTmpfs) apply() error {
return fmsg.WrapError(syscall.EBADE,
fmt.Sprintf("size %d out of bounds", t.Size))
}
- target := toSysroot(t.Path)
- if err := os.MkdirAll(target, 0755); err != nil {
- return err
- }
- opt := fmt.Sprintf("mode=%#o", t.Mode)
- if t.Size > 0 {
- opt += fmt.Sprintf(",size=%d", t.Mode)
- }
- return fmsg.WrapErrorSuffix(syscall.Mount("tmpfs", target, "tmpfs",
- syscall.MS_NOSUID|syscall.MS_NODEV, opt),
- fmt.Sprintf("cannot mount tmpfs on %q:", t.Path))
+ return mountTmpfs(t.Path, t.Size, t.Perm)
}
func (t *MountTmpfs) Is(op Op) bool { vt, ok := op.(*MountTmpfs); return ok && *t == *vt }
func (t *MountTmpfs) String() string { return fmt.Sprintf("tmpfs on %q size %d", t.Path, t.Size) }
-func (f *Ops) Tmpfs(dest string, size int, mode os.FileMode) *Ops {
- *f = append(*f, &MountTmpfs{dest, size, mode})
+func (f *Ops) Tmpfs(dest string, size int, perm os.FileMode) *Ops {
+ *f = append(*f, &MountTmpfs{dest, size, perm})
return f
}