aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/sandbox/mount.go14
-rw-r--r--internal/sandbox/sequential.go18
2 files changed, 18 insertions, 14 deletions
diff --git a/internal/sandbox/mount.go b/internal/sandbox/mount.go
index 3c6ae2d8..3d3d63af 100644
--- a/internal/sandbox/mount.go
+++ b/internal/sandbox/mount.go
@@ -79,3 +79,17 @@ func bindMount(src, dest string, flags int) error {
return fmsg.WrapErrorSuffix(syscall.Mount(source, target, "", mf, ""),
fmt.Sprintf("cannot bind %q on %q:", src, dest))
}
+
+func mountTmpfs(name string, size int, perm os.FileMode) error {
+ target := toSysroot(name)
+ if err := os.MkdirAll(target, perm); err != nil {
+ return err
+ }
+ opt := fmt.Sprintf("mode=%#o", perm)
+ if size > 0 {
+ opt += fmt.Sprintf(",size=%d", size)
+ }
+ return fmsg.WrapErrorSuffix(syscall.Mount("tmpfs", target, "tmpfs",
+ syscall.MS_NOSUID|syscall.MS_NODEV, opt),
+ fmt.Sprintf("cannot mount tmpfs on %q:", name))
+}
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
}