diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-03-23 22:17:36 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-03-23 22:17:36 +0900 |
| commit | e8809125d40b5086dc8adc1b9d75d99a9755278d (patch) | |
| tree | 512992fd7d11b34ea37ffe58cba7d90f6a6891ee /sandbox/vfs | |
| parent | 806ce18c0a610254a957a4e11113d14b1095f911 (diff) | |
sandbox: verify outcome via mountinfo
This contains much more information than /proc/mounts and allows for more fields to be checked. This also removes the dependency on the test package.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'sandbox/vfs')
| -rw-r--r-- | sandbox/vfs/mountinfo.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sandbox/vfs/mountinfo.go b/sandbox/vfs/mountinfo.go index c834b0e9..e0c9d411 100644 --- a/sandbox/vfs/mountinfo.go +++ b/sandbox/vfs/mountinfo.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "iter" + "slices" "strconv" "strings" "syscall" @@ -236,3 +237,22 @@ func parseMountInfoLine(s string, ent *MountInfoEntry) error { return nil } + +func (e *MountInfoEntry) EqualWithIgnore(want *MountInfoEntry) 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") +} + +func (e *MountInfoEntry) String() string { + return fmt.Sprintf("%d %d %d:%d %s %s %s %s %s %s %s", + e.ID, e.Parent, e.Devno[0], e.Devno[1], e.Root, e.Target, e.VfsOptstr, + strings.Join(append(e.OptFields, "-"), " "), e.FsType, e.Source, e.FsOptstr) +} |
