From c83a7e2efc0ae87a6a3d300f18212e4f46c950a2 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Mon, 17 Mar 2025 15:42:40 +0900 Subject: sandbox: mount container /dev/mqueue Signed-off-by: Ophestra --- sandbox/sequential.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'sandbox/sequential.go') diff --git a/sandbox/sequential.go b/sandbox/sequential.go index 45fd27d8..9b6e34b8 100644 --- a/sandbox/sequential.go +++ b/sandbox/sequential.go @@ -151,6 +151,35 @@ func (f *Ops) Dev(dest string) *Ops { return f } +func init() { gob.Register(new(MountMqueue)) } + +// MountMqueue mounts a private mqueue instance on container Path. +type MountMqueue string + +func (m MountMqueue) apply(*InitParams) error { + v := string(m) + + if !path.IsAbs(v) { + return msg.WrapErr(syscall.EBADE, + fmt.Sprintf("path %q is not absolute", v)) + } + + target := toSysroot(v) + if err := os.MkdirAll(target, 0755); err != nil { + return msg.WrapErr(err, err.Error()) + } + return wrapErrSuffix(syscall.Mount("mqueue", target, "mqueue", + syscall.MS_NOSUID|syscall.MS_NOEXEC|syscall.MS_NODEV, ""), + fmt.Sprintf("cannot mount mqueue on %q:", v)) +} + +func (m MountMqueue) Is(op Op) bool { vm, ok := op.(MountMqueue); return ok && m == vm } +func (m MountMqueue) String() string { return fmt.Sprintf("mqueue on %q", string(m)) } +func (f *Ops) Mqueue(dest string) *Ops { + *f = append(*f, MountMqueue(dest)) + return f +} + func init() { gob.Register(new(MountTmpfs)) } // MountTmpfs mounts tmpfs on container Path. -- cgit v1.3.1