diff options
author | gVisor bot <gvisor-bot@google.com> | 2021-08-30 22:39:13 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-08-30 22:39:13 +0000 |
commit | d93cb4e4ef6b37d3279b4ff1e26f358c6c3bd020 (patch) | |
tree | de757fb2c1ecf59513d9ac0e26d8c25c16355c10 | |
parent | a7b5bd75d313e05e60abebc05b1264c981e2be9b (diff) | |
parent | dfbcb8903ae8bd0d1ff984889f1b5cf1e041865e (diff) |
Merge release-20210823.0-32-gdfbcb8903 (automated)
-rw-r--r-- | pkg/syserr/syserr.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/pkg/syserr/syserr.go b/pkg/syserr/syserr.go index a5e386e38..b679f3046 100644 --- a/pkg/syserr/syserr.go +++ b/pkg/syserr/syserr.go @@ -24,6 +24,7 @@ import ( "gvisor.dev/gvisor/pkg/abi/linux/errno" "gvisor.dev/gvisor/pkg/errors" "gvisor.dev/gvisor/pkg/errors/linuxerr" + "gvisor.dev/gvisor/pkg/safecopy" ) // Error represents an internal error. @@ -278,15 +279,18 @@ func FromError(err error) *Error { if err == nil { return nil } - if errno, ok := err.(unix.Errno); ok { - return FromHost(errno) - } - if linuxErr, ok := err.(*errors.Error); ok { - return FromHost(unix.Errno(linuxErr.Errno())) + switch e := err.(type) { + case unix.Errno: + return FromHost(e) + case *errors.Error: + return FromHost(unix.Errno(e.Errno())) + case safecopy.SegvError, safecopy.BusError, safecopy.AlignmentError: + return FromHost(unix.EFAULT) } - panic("unknown error: " + err.Error()) + msg := fmt.Sprintf("err: %s type: %T", err.Error(), err) + panic(msg) } // ConvertIntr converts the provided error code (err) to another one (intr) if |