sandbox/vfs: parse vfs options
All checks were successful
Test / Create distribution (push) Successful in 25s
Test / Fortify (push) Successful in 2m36s
Test / Fpkg (push) Successful in 3m20s
Test / Data race detector (push) Successful in 4m4s
Test / Flake checks (push) Successful in 50s

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-03-21 17:12:10 +09:00
parent a70daf2250
commit d21d9c5b1d
2 changed files with 117 additions and 54 deletions

View File

@@ -7,6 +7,7 @@ import (
"io"
"strconv"
"strings"
"syscall"
)
var (
@@ -51,6 +52,31 @@ type (
DevT [2]int
)
func (e *MountInfoEntry) Flags() (flags uintptr, unmatched []string) {
for _, s := range strings.Split(e.VfsOptstr, ",") {
switch s {
case "rw":
case "ro":
flags |= syscall.MS_RDONLY
case "nosuid":
flags |= syscall.MS_NOSUID
case "nodev":
flags |= syscall.MS_NODEV
case "noexec":
flags |= syscall.MS_NOEXEC
case "noatime":
flags |= syscall.MS_NOATIME
case "nodiratime":
flags |= syscall.MS_NODIRATIME
case "relatime":
flags |= syscall.MS_RELATIME
default:
unmatched = append(unmatched, s)
}
}
return
}
// ParseMountInfo parses a mountinfo file according to proc_pid_mountinfo(5).
func ParseMountInfo(r io.Reader) (*MountInfo, int, error) {
var m, cur *MountInfo