diff --git a/sandbox/container_test.go b/sandbox/container_test.go index 5ed9fee..f6e6562 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 e0c9d41..bcb3063 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 similarity index 100% rename from sandbox/vfs/mount.go rename to sandbox/vfs/unfold.go diff --git a/sandbox/vfs/mount_test.go b/sandbox/vfs/unfold_test.go similarity index 100% rename from sandbox/vfs/mount_test.go rename to sandbox/vfs/unfold_test.go