diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-03-21 17:12:10 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-03-21 17:12:10 +0900 |
| commit | d21d9c5b1d38596bcab438061598f27a6a94d191 (patch) | |
| tree | b9d22519a02134fc198298e3d6a1e8a56ab7c1e5 /sandbox/vfs/mountinfo.go | |
| parent | a70daf22504f80c4e3dfbc2f34cf95db4dbb5879 (diff) | |
sandbox/vfs: parse vfs options
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'sandbox/vfs/mountinfo.go')
| -rw-r--r-- | sandbox/vfs/mountinfo.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sandbox/vfs/mountinfo.go b/sandbox/vfs/mountinfo.go index 2f609b1e..df2940a4 100644 --- a/sandbox/vfs/mountinfo.go +++ b/sandbox/vfs/mountinfo.go @@ -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 |
