summaryrefslogtreecommitdiffhomepage
path: root/pkg/p9/handlers.go
diff options
context:
space:
mode:
authorZach Koopmans <zkoopmans@google.com>2021-10-29 14:00:52 -0700
committergVisor bot <gvisor-bot@google.com>2021-10-29 14:03:16 -0700
commitb822923b706d6d2c5206451040f51a8c2f961353 (patch)
tree393f215aa879b909c9c9debd5e893bddb61ee50a /pkg/p9/handlers.go
parent1953d2ad28d405a3ab028feba7b6fca18339e9be (diff)
[syserr] Covert all linuxerr returns to error type.
Change the linuxerr.ErrorFromErrno to return an error type and not a *errors.Error type. The latter results in problems comparing to nil as <nil><nil> != <nil><*errors.Error>. In a follow up, there will be a change to remove *errors.Error.Errno(), which will also encourage users to not use Errnos to reference linuxerr. PiperOrigin-RevId: 406444419
Diffstat (limited to 'pkg/p9/handlers.go')
-rw-r--r--pkg/p9/handlers.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/pkg/p9/handlers.go b/pkg/p9/handlers.go
index a8f8a9d03..2657081e3 100644
--- a/pkg/p9/handlers.go
+++ b/pkg/p9/handlers.go
@@ -23,7 +23,6 @@ import (
"sync/atomic"
"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/fd"
@@ -46,7 +45,7 @@ func ExtractErrno(err error) unix.Errno {
// Attempt to unwrap.
switch e := err.(type) {
case *errors.Error:
- return unix.Errno(e.Errno())
+ return linuxerr.ToUnix(e)
case unix.Errno:
return e
case *os.PathError:
@@ -69,7 +68,7 @@ func newErr(err error) *Rlerror {
// ExtractLinuxerrErrno extracts a *errors.Error from a error, best effort.
// TODO(b/34162363): Merge this with ExtractErrno.
-func ExtractLinuxerrErrno(err error) *errors.Error {
+func ExtractLinuxerrErrno(err error) error {
switch err {
case os.ErrNotExist:
return linuxerr.ENOENT
@@ -84,9 +83,9 @@ func ExtractLinuxerrErrno(err error) *errors.Error {
// Attempt to unwrap.
switch e := err.(type) {
case *errors.Error:
- return e
+ return linuxerr.ToError(e)
case unix.Errno:
- return linuxerr.ErrorFromErrno(errno.Errno(e))
+ return linuxerr.ErrorFromUnix(e)
case *os.PathError:
return ExtractLinuxerrErrno(e.Err)
case *os.SyscallError:
@@ -103,7 +102,7 @@ func ExtractLinuxerrErrno(err error) *errors.Error {
// newErrFromLinuxerr returns an Rlerror from the linuxerr list.
// TODO(b/34162363): Merge this with newErr.
func newErrFromLinuxerr(err error) *Rlerror {
- return &Rlerror{Error: uint32(ExtractLinuxerrErrno(err).Errno())}
+ return &Rlerror{Error: uint32(ExtractErrno(err))}
}
// handler is implemented for server-handled messages.