os: return a *PathError from Readdirnames and Readdir on POSIX platforms

Previously, Readdirnames returned a *PathError on Windows and Plan 9,
but a *SyscallError on POSIX systems.

In contrast, similar methods (such as Stat) return a *PathError on all platforms.

Fixes #38923

Change-Id: I26395905b1e723933f07b792c7aeee7c335949cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/233917
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Bryan C. Mills 2020-05-13 14:59:29 -04:00
parent c78d215ce3
commit b3d9cf7a07
3 changed files with 10 additions and 6 deletions

View file

@ -50,7 +50,7 @@ func (f *File) readdirnames(n int) (names []string, err error) {
d.nbuf, errno = f.pfd.ReadDirent(d.buf)
runtime.KeepAlive(f)
if errno != nil {
return names, wrapSyscallError("readdirent", errno)
return names, &PathError{"readdirent", f.name, errno}
}
if d.nbuf <= 0 {
break // EOF