mirror of
https://github.com/golang/go.git
synced 2026-04-01 17:07:17 +09:00
os: allow direntries to have zero inodes on Linux
While such entries have often been skipped, some Linux filesystems return valid enties with zero inodes. This new behavior also puts Go in agreement with recent glibc. Fixes #76428
This commit is contained in:
@@ -112,7 +112,8 @@ func (f *File) readdir(n int, mode readdirMode) (names []string, dirents []DirEn
|
||||
// or might expose a remote file system which does not have the concept
|
||||
// of inodes. Therefore, we cannot make the assumption that it is safe
|
||||
// to skip entries with zero inodes.
|
||||
if ino == 0 && runtime.GOOS != "wasip1" {
|
||||
// Some Linux filesystems (old XFS, FUSE) can return valid files with zero inodes.
|
||||
if ino == 0 && runtime.GOOS != "linux" && runtime.GOOS != "wasip1" {
|
||||
continue
|
||||
}
|
||||
const namoff = uint64(unsafe.Offsetof(syscall.Dirent{}.Name))
|
||||
|
||||
@@ -73,8 +73,8 @@ func ParseDirent(buf []byte, max int, names []string) (consumed int, count int,
|
||||
break
|
||||
}
|
||||
// See src/os/dir_unix.go for the reason why this condition is
|
||||
// excluded on wasip1.
|
||||
if ino == 0 && runtime.GOOS != "wasip1" { // File absent in directory.
|
||||
// excluded on wasip1 and linux.
|
||||
if ino == 0 && runtime.GOOS != "linux" && runtime.GOOS != "wasip1" { // File absent in directory.
|
||||
continue
|
||||
}
|
||||
const namoff = uint64(unsafe.Offsetof(Dirent{}.Name))
|
||||
|
||||
Reference in New Issue
Block a user