From 2eff47009102d53844906aa90fb2b8eddae78c1b Mon Sep 17 00:00:00 2001 From: Ophestra Date: Fri, 14 Mar 2025 02:12:35 +0900 Subject: [PATCH] sandbox/mount: pass custom tmpfs name The tmpfs driver allows arbitrary fsname. Signed-off-by: Ophestra --- internal/sandbox/mount.go | 4 ++-- internal/sandbox/sequential.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/sandbox/mount.go b/internal/sandbox/mount.go index ea781d6..eaede7b 100644 --- a/internal/sandbox/mount.go +++ b/internal/sandbox/mount.go @@ -82,7 +82,7 @@ func bindMount(src, dest string, flags int) error { fmt.Sprintf("cannot bind %q on %q:", src, dest)) } -func mountTmpfs(name string, size int, perm os.FileMode) error { +func mountTmpfs(fsname, name string, size int, perm os.FileMode) error { target := toSysroot(name) if err := os.MkdirAll(target, perm); err != nil { return err @@ -91,7 +91,7 @@ func mountTmpfs(name string, size int, perm os.FileMode) error { if size > 0 { opt += fmt.Sprintf(",size=%d", size) } - return fmsg.WrapErrorSuffix(syscall.Mount("tmpfs", target, "tmpfs", + return fmsg.WrapErrorSuffix(syscall.Mount(fsname, 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 75d6268..719af5f 100644 --- a/internal/sandbox/sequential.go +++ b/internal/sandbox/sequential.go @@ -87,7 +87,7 @@ func (t *MountTmpfs) apply(*InitParams) error { return fmsg.WrapError(syscall.EBADE, fmt.Sprintf("size %d out of bounds", t.Size)) } - return mountTmpfs(t.Path, t.Size, t.Perm) + return mountTmpfs("tmpfs", t.Path, t.Size, t.Perm) } func (t *MountTmpfs) Is(op Op) bool { vt, ok := op.(*MountTmpfs); return ok && *t == *vt }