Skip to content

Commit cec4d43

Browse files
vasigopherbot
authored andcommitted
os: allow direntries to have zero inodes on Linux
Some Linux filesystems have been known to return valid enties with zero inodes. This new behavior also puts Go in agreement with recent glibc. Fixes #76428 Change-Id: Ieaf50739a294915a3ea2ef8c5a3bb2a91a186881 GitHub-Last-Rev: 8f83d00 GitHub-Pull-Request: #76448 Reviewed-on: https://go-review.googlesource.com/c/go/+/724220 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent f1bbc66 commit cec4d43

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

‎src/os/dir_unix.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ func (f *File) readdir(n int, mode readdirMode) (names []string, dirents []DirEn
112112
// or might expose a remote file system which does not have the concept
113113
// of inodes. Therefore, we cannot make the assumption that it is safe
114114
// to skip entries with zero inodes.
115-
if ino == 0 && runtime.GOOS != "wasip1" {
115+
// Some Linux filesystems (old XFS, FUSE) can return valid files with zero inodes.
116+
if ino == 0 && runtime.GOOS != "linux" && runtime.GOOS != "wasip1" {
116117
continue
117118
}
118119
const namoff = uint64(unsafe.Offsetof(syscall.Dirent{}.Name))

‎src/syscall/dirent.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ func ParseDirent(buf []byte, max int, names []string) (consumed int, count int,
7373
break
7474
}
7575
// See src/os/dir_unix.go for the reason why this condition is
76-
// excluded on wasip1.
77-
if ino == 0 && runtime.GOOS != "wasip1" { // File absent in directory.
76+
// excluded on wasip1 and linux.
77+
if ino == 0 && runtime.GOOS != "linux" && runtime.GOOS != "wasip1" { // File absent in directory.
7878
continue
7979
}
8080
const namoff = uint64(unsafe.Offsetof(Dirent{}.Name))

0 commit comments

Comments
 (0)