mirror of
https://github.com/golang/go
synced 2024-11-11 17:21:38 -07:00
os: treat Getwd result of EINVAL/ERANGE the same as ENAMETOOLONG
At least Darwin and OpenBSD seem to return EINVAL if the resulting name would be too long. Solaris seems to return ERANGE. Fixes #69233 Fixes #69234 Change-Id: I9b51d41461e9576c633bf2fc0e96ca3e4d986255 Reviewed-on: https://go-review.googlesource.com/c/go/+/609579 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
8eefc3b8f0
commit
57f4cf2099
@ -11,3 +11,4 @@ import "syscall"
|
||||
type syscallErrorType = syscall.Errno
|
||||
|
||||
const errENOSYS = syscall.ENOSYS
|
||||
const errERANGE = syscall.ERANGE
|
||||
|
@ -9,3 +9,4 @@ import "syscall"
|
||||
type syscallErrorType = syscall.ErrorString
|
||||
|
||||
var errENOSYS = syscall.NewError("function not implemented")
|
||||
var errERANGE = syscall.NewError("out of range")
|
||||
|
@ -59,7 +59,10 @@ func Getwd() (dir string, err error) {
|
||||
break
|
||||
}
|
||||
}
|
||||
if err != syscall.ENAMETOOLONG {
|
||||
// Linux returns ENAMETOOLONG if the result is too long.
|
||||
// BSD systems appear to return EINVAL.
|
||||
// Solaris appears to use ERANGE.
|
||||
if err != syscall.ENAMETOOLONG && err != syscall.EINVAL && err != errERANGE {
|
||||
return dir, NewSyscallError("getwd", err)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user