os: test and fix ReadDir("/dev/fd") on macOS
ReadDir("/dev/fd") on macOS fails during tests with EBADF.
There is a kernel bug where fstat(N) works but lstat("/dev/fd/N")
and fstatat(open("/dev/fd"), "N") both fail when N is a kqueue fd.
Treat EBADF the same way as ENOENT for purposes of continuing
the ReadDir loop. The effect will be that we don't report the open
kqueue fd, but at least we will report everything else.
While we are here, change the lstatat error path to include
the name being lstat'ed, even though it still has operation "fstatat".
This changes the error from:
read_test.go:157: fstatat /dev/fd: bad file descriptor
to:
read_test.go:157: fstatat /dev/fd/3: bad file descriptor
which is more helpful. It also more closely matches older
Go versions that failed with:
read_test.go:157: lstat /dev/fd/3: bad file descriptor
Of course, with the EBADF workaround we should no longer
see any form of this message, but clean it up anyway.
For #80143.| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |