diff options
author | Zach Koopmans <zkoopmans@google.com> | 2021-06-29 15:05:27 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-06-29 15:08:46 -0700 |
commit | 54b71221c0b7a9159f369263ea6189bdba4eac3a (patch) | |
tree | e98758fee397eafad8373af92f3813e9fcc13e9b /pkg/syserr | |
parent | d205926f235258468bfe206388fa1b55cb1ea7fa (diff) |
[syserror] Change syserror to linuxerr for E2BIG, EADDRINUSE, and EINVAL
Remove three syserror entries duplicated in linuxerr. Because of the
linuxerr.Equals method, this is a mere change of return values from
syserror to linuxerr definitions.
Done with only these three errnos as CLs removing all grow to a significantly
large size.
PiperOrigin-RevId: 382173835
Diffstat (limited to 'pkg/syserr')
-rw-r--r-- | pkg/syserr/BUILD | 1 | ||||
-rw-r--r-- | pkg/syserr/syserr.go | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/pkg/syserr/BUILD b/pkg/syserr/BUILD index 5205fa7e4..ceee494fc 100644 --- a/pkg/syserr/BUILD +++ b/pkg/syserr/BUILD @@ -12,6 +12,7 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/abi/linux/errno", + "//pkg/errors", "//pkg/errors/linuxerr", "//pkg/syserror", "//pkg/tcpip", diff --git a/pkg/syserr/syserr.go b/pkg/syserr/syserr.go index 7d0a5125b..765128ff0 100644 --- a/pkg/syserr/syserr.go +++ b/pkg/syserr/syserr.go @@ -22,6 +22,7 @@ import ( "golang.org/x/sys/unix" "gvisor.dev/gvisor/pkg/abi/linux/errno" + "gvisor.dev/gvisor/pkg/errors" "gvisor.dev/gvisor/pkg/errors/linuxerr" "gvisor.dev/gvisor/pkg/syserror" ) @@ -281,6 +282,11 @@ func FromError(err error) *Error { if errno, ok := err.(unix.Errno); ok { return FromHost(errno) } + + if linuxErr, ok := err.(*errors.Error); ok { + return FromHost(unix.Errno(linuxErr.Errno())) + } + if errno, ok := syserror.TranslateError(err); ok { return FromHost(errno) } |