From ce58d71fd526587c0ed5e898e3a680c30c02c6d2 Mon Sep 17 00:00:00 2001 From: Zach Koopmans Date: Fri, 13 Aug 2021 17:14:36 -0700 Subject: [syserror] Remove pkg syserror. Removes package syserror and moves still relevant code to either linuxerr or to syserr (to be later removed). Internal errors are converted from random types to *errors.Error types used in linuxerr. Internal errors are in linuxerr/internal.go. PiperOrigin-RevId: 390724202 --- pkg/syserr/syserr.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'pkg/syserr/syserr.go') diff --git a/pkg/syserr/syserr.go b/pkg/syserr/syserr.go index 558240008..a5e386e38 100644 --- a/pkg/syserr/syserr.go +++ b/pkg/syserr/syserr.go @@ -24,7 +24,6 @@ import ( "gvisor.dev/gvisor/pkg/abi/linux/errno" "gvisor.dev/gvisor/pkg/errors" "gvisor.dev/gvisor/pkg/errors/linuxerr" - "gvisor.dev/gvisor/pkg/syserror" ) // Error represents an internal error. @@ -52,12 +51,12 @@ func New(message string, linuxTranslation errno.Errno) *Error { } e := error(unix.Errno(err.errno)) - // syserror.ErrWouldBlock gets translated to linuxerr.EWOULDBLOCK and + // linuxerr.ErrWouldBlock gets translated to linuxerr.EWOULDBLOCK and // enables proper blocking semantics. This should temporary address the // class of blocking bugs that keep popping up with the current state of // the error space. if err.errno == linuxerr.EWOULDBLOCK.Errno() { - e = syserror.ErrWouldBlock + e = linuxerr.ErrWouldBlock } linuxBackwardsTranslations[err.errno] = linuxBackwardsTranslation{err: e, ok: true} @@ -287,8 +286,14 @@ func FromError(err error) *Error { return FromHost(unix.Errno(linuxErr.Errno())) } - if errno, ok := syserror.TranslateError(err); ok { - return FromHost(errno) - } panic("unknown error: " + err.Error()) } + +// ConvertIntr converts the provided error code (err) to another one (intr) if +// the first error corresponds to an interrupted operation. +func ConvertIntr(err, intr error) error { + if err == linuxerr.ErrInterrupted { + return intr + } + return err +} -- cgit v1.2.3