aboutsummaryrefslogtreecommitdiffhomepage
path: root/sandbox
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-03-24 13:21:55 +0900
committerOphestra <cat@gensokyo.uk>2025-03-24 13:21:55 +0900
commita11237b15848cc99d117ca6eb832eed0c92c64ec (patch)
tree37b098dd88b56fa373a26909052caaae9a515eb2 /sandbox
parent40f00d570e10ba03910d16b734cc75817b83d00e (diff)
sandbox/vfs: add doc comments
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/container_test.go2
-rw-r--r--sandbox/vfs/mountinfo.go18
-rw-r--r--sandbox/vfs/unfold.go (renamed from sandbox/vfs/mount.go)0
-rw-r--r--sandbox/vfs/unfold_test.go (renamed from sandbox/vfs/mount_test.go)0
4 files changed, 11 insertions, 9 deletions
diff --git a/sandbox/container_test.go b/sandbox/container_test.go
index 5ed9fee4..f6e6562d 100644
--- a/sandbox/container_test.go
+++ b/sandbox/container_test.go
@@ -231,7 +231,7 @@ func TestHelperCheckContainer(t *testing.T) {
mnt[i].VfsOptstr = strings.TrimSuffix(mnt[i].VfsOptstr, ",relatime")
mnt[i].VfsOptstr = strings.TrimSuffix(mnt[i].VfsOptstr, ",noatime")
- if !cur.EqualWithIgnore(mnt[i]) {
+ if !cur.EqualWithIgnore(mnt[i], "\x00") {
t.Errorf("[FAIL] %s", cur)
} else {
t.Logf("[ OK ] %s", cur)
diff --git a/sandbox/vfs/mountinfo.go b/sandbox/vfs/mountinfo.go
index e0c9d411..bcb3063f 100644
--- a/sandbox/vfs/mountinfo.go
+++ b/sandbox/vfs/mountinfo.go
@@ -1,3 +1,4 @@
+// Package vfs provides bindings and iterators over proc_pid_mountinfo(5).
package vfs
import (
@@ -68,6 +69,7 @@ type (
DevT [2]int
)
+// Flags interprets VfsOptstr and returns the resulting flags and unmatched options.
func (e *MountInfoEntry) Flags() (flags uintptr, unmatched []string) {
for _, s := range strings.Split(e.VfsOptstr, ",") {
switch s {
@@ -238,17 +240,17 @@ func parseMountInfoLine(s string, ent *MountInfoEntry) error {
return nil
}
-func (e *MountInfoEntry) EqualWithIgnore(want *MountInfoEntry) bool {
+func (e *MountInfoEntry) EqualWithIgnore(want *MountInfoEntry, ignore string) bool {
return (e.ID == want.ID || want.ID == -1) &&
(e.Parent == want.Parent || want.Parent == -1) &&
(e.Devno == want.Devno || (want.Devno[0] == -1 && want.Devno[1] == -1)) &&
- (e.Root == want.Root || want.Root == "\x00") &&
- (e.Target == want.Target || want.Target == "\x00") &&
- (e.VfsOptstr == want.VfsOptstr || want.VfsOptstr == "\x00") &&
- (slices.Equal(e.OptFields, want.OptFields) || (len(want.OptFields) == 1 && want.OptFields[0] == "\x00")) &&
- (e.FsType == want.FsType || want.FsType == "\x00") &&
- (e.Source == want.Source || want.Source == "\x00") &&
- (e.FsOptstr == want.FsOptstr || want.FsOptstr == "\x00")
+ (e.Root == want.Root || want.Root == ignore) &&
+ (e.Target == want.Target || want.Target == ignore) &&
+ (e.VfsOptstr == want.VfsOptstr || want.VfsOptstr == ignore) &&
+ (slices.Equal(e.OptFields, want.OptFields) || (len(want.OptFields) == 1 && want.OptFields[0] == ignore)) &&
+ (e.FsType == want.FsType || want.FsType == ignore) &&
+ (e.Source == want.Source || want.Source == ignore) &&
+ (e.FsOptstr == want.FsOptstr || want.FsOptstr == ignore)
}
func (e *MountInfoEntry) String() string {
diff --git a/sandbox/vfs/mount.go b/sandbox/vfs/unfold.go
index ca0e37b7..ca0e37b7 100644
--- a/sandbox/vfs/mount.go
+++ b/sandbox/vfs/unfold.go
diff --git a/sandbox/vfs/mount_test.go b/sandbox/vfs/unfold_test.go
index 4a262567..4a262567 100644
--- a/sandbox/vfs/mount_test.go
+++ b/sandbox/vfs/unfold_test.go