const expectedAtLeastNumFieldsPerMountInfo … const maxListTries … // IsCorruptedMnt return true if err is about corrupted mount point func IsCorruptedMnt(err error) bool { … } type MountInfo … // ParseMountInfo parses /proc/xxx/mountinfo. func ParseMountInfo(filename string) ([]MountInfo, error) { … } // splitMountOptions parses comma-separated list of mount options into an array. // It respects double quotes - commas in them are not considered as the option separator. func splitMountOptions(s string) []string { … } // isMountPointMatch returns true if the path in mp is the same as dir. // Handles case where mountpoint dir has been renamed due to stale NFS mount. func isMountPointMatch(mp MountPoint, dir string) bool { … } // PathExists returns true if the specified path exists. // TODO: clean this up to use pkg/util/file/FileExists func PathExists(path string) (bool, error) { … } var hasMountinfoBug … var checkMountinfoBugOnce … // kernelHasMountinfoBug checks if the kernel bug that can lead to incomplete // mountinfo being read is fixed. It does so by checking the kernel version. // // The bug was fixed by the kernel commit 9f6c61f96f2d97 (since Linux 5.8). // Alas, there is no better way to check if the bug is fixed other than to // rely on the kernel version returned by uname. func kernelHasMountinfoBug() bool { … } func readMountInfo(path string) ([]byte, error) { … }