diff options
author | Zach Koopmans <zkoopmans@google.com> | 2021-08-13 17:14:36 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-08-13 17:16:52 -0700 |
commit | ce58d71fd526587c0ed5e898e3a680c30c02c6d2 (patch) | |
tree | 831dce518d66ba8acd53afa7f45b7b7577218b3d /pkg/safecopy | |
parent | 868ed0e807239635bd3aa6b964bb4fc0913916be (diff) |
[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
Diffstat (limited to 'pkg/safecopy')
-rw-r--r-- | pkg/safecopy/BUILD | 3 | ||||
-rw-r--r-- | pkg/safecopy/safecopy.go | 9 |
2 files changed, 7 insertions, 5 deletions
diff --git a/pkg/safecopy/BUILD b/pkg/safecopy/BUILD index db5787302..0a045fc8e 100644 --- a/pkg/safecopy/BUILD +++ b/pkg/safecopy/BUILD @@ -19,7 +19,8 @@ go_library( visibility = ["//:sandbox"], deps = [ "//pkg/abi/linux", - "//pkg/syserror", + "//pkg/errors", + "//pkg/errors/linuxerr", "@org_golang_x_sys//unix:go_default_library", ], ) diff --git a/pkg/safecopy/safecopy.go b/pkg/safecopy/safecopy.go index df63dd5f1..5e6f903ff 100644 --- a/pkg/safecopy/safecopy.go +++ b/pkg/safecopy/safecopy.go @@ -21,7 +21,8 @@ import ( "runtime" "golang.org/x/sys/unix" - "gvisor.dev/gvisor/pkg/syserror" + "gvisor.dev/gvisor/pkg/errors" + "gvisor.dev/gvisor/pkg/errors/linuxerr" ) // SegvError is returned when a safecopy function receives SIGSEGV. @@ -137,12 +138,12 @@ func init() { if err := ReplaceSignalHandler(unix.SIGBUS, addrOfSignalHandler(), &savedSigBusHandler); err != nil { panic(fmt.Sprintf("Unable to set handler for SIGBUS: %v", err)) } - syserror.AddErrorUnwrapper(func(e error) (unix.Errno, bool) { + linuxerr.AddErrorUnwrapper(func(e error) (*errors.Error, bool) { switch e.(type) { case SegvError, BusError, AlignmentError: - return unix.EFAULT, true + return linuxerr.EFAULT, true default: - return 0, false + return nil, false } }) } |