tests: Do not allow forced type asserts (#20905)

This commit is contained in:
Klaus Post
2025-02-18 08:25:55 -08:00
committed by GitHub
parent aeabac9181
commit 90f5e1e5f6
100 changed files with 371 additions and 358 deletions

View File

@@ -56,13 +56,13 @@ func IsLikelyMountPoint(path string) bool {
}
// If the directory has a different device as parent, then it is a mountpoint.
if s1.Sys().(*syscall.Stat_t).Dev != s2.Sys().(*syscall.Stat_t).Dev {
// path/.. on a different device as path
return true
}
// path/.. is the same i-node as path - this check is for bind mounts.
return s1.Sys().(*syscall.Stat_t).Ino == s2.Sys().(*syscall.Stat_t).Ino
ss1, ok1 := s1.Sys().(*syscall.Stat_t)
ss2, ok2 := s2.Sys().(*syscall.Stat_t)
return ok1 && ok2 &&
// path/.. on a different device as path
(ss1.Dev != ss2.Dev ||
// path/.. is the same i-node as path - this check is for bind mounts.
ss1.Ino == ss2.Ino)
}
// CheckCrossDevice - check if any list of paths has any sub-mounts at /proc/mounts.

View File

@@ -40,7 +40,9 @@ var mountPointCache sync.Map
func IsLikelyMountPoint(path string) bool {
path = filepath.Dir(path)
if v, ok := mountPointCache.Load(path); ok {
return v.(bool)
if b, ok := v.(bool); ok {
return b
}
}
wpath, _ := windows.UTF16PtrFromString(path)
wvolume := make([]uint16, len(path)+1)