summaryrefslogtreecommitdiffhomepage
path: root/pkg/syserr
diff options
context:
space:
mode:
authorIan Gudger <igudger@google.com>2018-08-14 19:02:36 -0700
committerShentubot <shentubot@google.com>2018-08-14 19:03:38 -0700
commita620bea045b018b717fbba3193975e6d97c09bf9 (patch)
treee627299e37b463a00f1eb548725d12ac4662fbad /pkg/syserr
parente8a4f2e133c3a7fb4a2dceb6675ebc57ea4f7350 (diff)
Reduce map lookups in syserr
PiperOrigin-RevId: 208755352 Change-Id: Ia24630f452a4a42940ab73a8113a2fd5ea2cfca2
Diffstat (limited to 'pkg/syserr')
-rw-r--r--pkg/syserr/BUILD1
-rw-r--r--pkg/syserr/host_linux.go150
-rw-r--r--pkg/syserr/linuxabi.go30
-rw-r--r--pkg/syserr/syserr.go342
4 files changed, 210 insertions, 313 deletions
diff --git a/pkg/syserr/BUILD b/pkg/syserr/BUILD
index c0850f3d9..5dd2e90bb 100644
--- a/pkg/syserr/BUILD
+++ b/pkg/syserr/BUILD
@@ -6,7 +6,6 @@ go_library(
name = "syserr",
srcs = [
"host_linux.go",
- "linuxabi.go",
"netstack.go",
"syserr.go",
],
diff --git a/pkg/syserr/host_linux.go b/pkg/syserr/host_linux.go
index ffd78e8f8..22009a799 100644
--- a/pkg/syserr/host_linux.go
+++ b/pkg/syserr/host_linux.go
@@ -17,144 +17,30 @@
package syserr
import (
+ "fmt"
"syscall"
)
-var linuxHostTranslations = map[syscall.Errno]*Error{
- syscall.EPERM: ErrNotPermitted,
- syscall.ENOENT: ErrNoFileOrDir,
- syscall.ESRCH: ErrNoProcess,
- syscall.EINTR: ErrInterrupted,
- syscall.EIO: ErrIO,
- syscall.ENXIO: ErrDeviceOrAddress,
- syscall.E2BIG: ErrTooManyArgs,
- syscall.ENOEXEC: ErrEcec,
- syscall.EBADF: ErrBadFD,
- syscall.ECHILD: ErrNoChild,
- syscall.EAGAIN: ErrTryAgain,
- syscall.ENOMEM: ErrNoMemory,
- syscall.EACCES: ErrPermissionDenied,
- syscall.EFAULT: ErrBadAddress,
- syscall.ENOTBLK: ErrNotBlockDevice,
- syscall.EBUSY: ErrBusy,
- syscall.EEXIST: ErrExists,
- syscall.EXDEV: ErrCrossDeviceLink,
- syscall.ENODEV: ErrNoDevice,
- syscall.ENOTDIR: ErrNotDir,
- syscall.EISDIR: ErrIsDir,
- syscall.EINVAL: ErrInvalidArgument,
- syscall.ENFILE: ErrFileTableOverflow,
- syscall.EMFILE: ErrTooManyOpenFiles,
- syscall.ENOTTY: ErrNotTTY,
- syscall.ETXTBSY: ErrTestFileBusy,
- syscall.EFBIG: ErrFileTooBig,
- syscall.ENOSPC: ErrNoSpace,
- syscall.ESPIPE: ErrIllegalSeek,
- syscall.EROFS: ErrReadOnlyFS,
- syscall.EMLINK: ErrTooManyLinks,
- syscall.EPIPE: ErrBrokenPipe,
- syscall.EDOM: ErrDomain,
- syscall.ERANGE: ErrRange,
- syscall.EDEADLOCK: ErrDeadlock,
- syscall.ENAMETOOLONG: ErrNameTooLong,
- syscall.ENOLCK: ErrNoLocksAvailable,
- syscall.ENOSYS: ErrInvalidSyscall,
- syscall.ENOTEMPTY: ErrDirNotEmpty,
- syscall.ELOOP: ErrLinkLoop,
- syscall.ENOMSG: ErrNoMessage,
- syscall.EIDRM: ErrIdentifierRemoved,
- syscall.ECHRNG: ErrChannelOutOfRange,
- syscall.EL2NSYNC: ErrLevelTwoNotSynced,
- syscall.EL3HLT: ErrLevelThreeHalted,
- syscall.EL3RST: ErrLevelThreeReset,
- syscall.ELNRNG: ErrLinkNumberOutOfRange,
- syscall.EUNATCH: ErrProtocolDriverNotAttached,
- syscall.ENOCSI: ErrNoCSIAvailable,
- syscall.EL2HLT: ErrLevelTwoHalted,
- syscall.EBADE: ErrInvalidExchange,
- syscall.EBADR: ErrInvalidRequestDescriptor,
- syscall.EXFULL: ErrExchangeFull,
- syscall.ENOANO: ErrNoAnode,
- syscall.EBADRQC: ErrInvalidRequestCode,
- syscall.EBADSLT: ErrInvalidSlot,
- syscall.EBFONT: ErrBadFontFile,
- syscall.ENOSTR: ErrNotStream,
- syscall.ENODATA: ErrNoDataAvailable,
- syscall.ETIME: ErrTimerExpired,
- syscall.ENOSR: ErrStreamsResourceDepleted,
- syscall.ENONET: ErrMachineNotOnNetwork,
- syscall.ENOPKG: ErrPackageNotInstalled,
- syscall.EREMOTE: ErrIsRemote,
- syscall.ENOLINK: ErrNoLink,
- syscall.EADV: ErrAdvertise,
- syscall.ESRMNT: ErrSRMount,
- syscall.ECOMM: ErrSendCommunication,
- syscall.EPROTO: ErrProtocol,
- syscall.EMULTIHOP: ErrMultihopAttempted,
- syscall.EDOTDOT: ErrRFS,
- syscall.EBADMSG: ErrInvalidDataMessage,
- syscall.EOVERFLOW: ErrOverflow,
- syscall.ENOTUNIQ: ErrNetworkNameNotUnique,
- syscall.EBADFD: ErrFDInBadState,
- syscall.EREMCHG: ErrRemoteAddressChanged,
- syscall.ELIBACC: ErrSharedLibraryInaccessible,
- syscall.ELIBBAD: ErrCorruptedSharedLibrary,
- syscall.ELIBSCN: ErrLibSectionCorrupted,
- syscall.ELIBMAX: ErrTooManySharedLibraries,
- syscall.ELIBEXEC: ErrSharedLibraryExeced,
- syscall.EILSEQ: ErrIllegalByteSequence,
- syscall.ERESTART: ErrShouldRestart,
- syscall.ESTRPIPE: ErrStreamPipe,
- syscall.EUSERS: ErrTooManyUsers,
- syscall.ENOTSOCK: ErrNotASocket,
- syscall.EDESTADDRREQ: ErrDestinationAddressRequired,
- syscall.EMSGSIZE: ErrMessageTooLong,
- syscall.EPROTOTYPE: ErrWrongProtocolForSocket,
- syscall.ENOPROTOOPT: ErrProtocolNotAvailable,
- syscall.EPROTONOSUPPORT: ErrProtocolNotSupported,
- syscall.ESOCKTNOSUPPORT: ErrSocketNotSupported,
- syscall.EOPNOTSUPP: ErrEndpointOperation,
- syscall.EPFNOSUPPORT: ErrProtocolFamilyNotSupported,
- syscall.EAFNOSUPPORT: ErrAddressFamilyNotSupported,
- syscall.EADDRINUSE: ErrAddressInUse,
- syscall.EADDRNOTAVAIL: ErrAddressNotAvailable,
- syscall.ENETDOWN: ErrNetworkDown,
- syscall.ENETUNREACH: ErrNetworkUnreachable,
- syscall.ENETRESET: ErrNetworkReset,
- syscall.ECONNABORTED: ErrConnectionAborted,
- syscall.ECONNRESET: ErrConnectionReset,
- syscall.ENOBUFS: ErrNoBufferSpace,
- syscall.EISCONN: ErrAlreadyConnected,
- syscall.ENOTCONN: ErrNotConnected,
- syscall.ESHUTDOWN: ErrShutdown,
- syscall.ETOOMANYREFS: ErrTooManyRefs,
- syscall.ETIMEDOUT: ErrTimedOut,
- syscall.ECONNREFUSED: ErrConnectionRefused,
- syscall.EHOSTDOWN: ErrHostDown,
- syscall.EHOSTUNREACH: ErrNoRoute,
- syscall.EALREADY: ErrAlreadyInProgress,
- syscall.EINPROGRESS: ErrInProgress,
- syscall.ESTALE: ErrStaleFileHandle,
- syscall.EUCLEAN: ErrStructureNeedsCleaning,
- syscall.ENOTNAM: ErrIsNamedFile,
- syscall.EREMOTEIO: ErrRemoteIO,
- syscall.EDQUOT: ErrQuotaExceeded,
- syscall.ENOMEDIUM: ErrNoMedium,
- syscall.EMEDIUMTYPE: ErrWrongMediumType,
- syscall.ECANCELED: ErrCanceled,
- syscall.ENOKEY: ErrNoKey,
- syscall.EKEYEXPIRED: ErrKeyExpired,
- syscall.EKEYREVOKED: ErrKeyRevoked,
- syscall.EKEYREJECTED: ErrKeyRejected,
- syscall.EOWNERDEAD: ErrOwnerDied,
- syscall.ENOTRECOVERABLE: ErrNotRecoverable,
+const maxErrno = 134
+
+type linuxHostTranslation struct {
+ err *Error
+ ok bool
}
+var linuxHostTranslations [maxErrno]linuxHostTranslation
+
// FromHost translates a syscall.Errno to a corresponding Error value.
func FromHost(err syscall.Errno) *Error {
- e, ok := linuxHostTranslations[err]
- if !ok {
- panic("Unknown host errno " + err.Error())
+ if err < 0 || int(err) >= len(linuxHostTranslations) || !linuxHostTranslations[err].ok {
+ panic(fmt.Sprintf("unknown host errno %q (%d)", err.Error(), err))
+ }
+ return linuxHostTranslations[err].err
+}
+
+func addLinuxHostTranslation(host syscall.Errno, trans *Error) {
+ if linuxHostTranslations[host].ok {
+ panic(fmt.Sprintf("duplicate translation for host errno %q (%d)", host.Error(), host))
}
- return e
+ linuxHostTranslations[host] = linuxHostTranslation{err: trans, ok: true}
}
diff --git a/pkg/syserr/linuxabi.go b/pkg/syserr/linuxabi.go
deleted file mode 100644
index 71e3d1a81..000000000
--- a/pkg/syserr/linuxabi.go
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2018 Google Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package syserr
-
-import (
- "gvisor.googlesource.com/gvisor/pkg/abi/linux"
-)
-
-var linuxABITranslations = map[*Error]*linux.Errno{}
-
-// ToLinux translates an Error to a corresponding *linux.Errno value.
-func ToLinux(err *Error) *linux.Errno {
- le, ok := linuxABITranslations[err]
- if !ok {
- panic("No Linux ABI translation available for " + err.String())
- }
- return le
-}
diff --git a/pkg/syserr/syserr.go b/pkg/syserr/syserr.go
index 5d9fa24de..dba6cb7de 100644
--- a/pkg/syserr/syserr.go
+++ b/pkg/syserr/syserr.go
@@ -27,30 +27,43 @@ import (
// Error represents an internal error.
type Error struct {
- string
+ // message is the human readable form of this Error.
+ message string
+
+ // noTranslation indicates that this Error cannot be translated to a
+ // linux.Errno.
+ noTranslation bool
+
+ // errno is the linux.Errno this Error should be translated to. nil means
+ // that this Error should be translated to a nil linux.Errno.
+ errno *linux.Errno
}
// New creates a new Error and adds a translation for it.
//
// New must only be called at init.
func New(message string, linuxTranslation *linux.Errno) *Error {
- err := &Error{message}
- linuxABITranslations[err] = linuxTranslation
+ err := &Error{message: message, errno: linuxTranslation}
- // TODO: Remove this.
if linuxTranslation == nil {
- linuxBackwardsTranslations[err] = nil
- } else {
- e := error(syscall.Errno(linuxTranslation.Number()))
- // syserror.ErrWouldBlock gets translated to syserror.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 e == syserror.EWOULDBLOCK {
- e = syserror.ErrWouldBlock
- }
- linuxBackwardsTranslations[err] = e
+ return err
+ }
+
+ // TODO: Remove this.
+ errno := linuxTranslation.Number()
+ if errno <= 0 || errno >= len(linuxBackwardsTranslations) {
+ panic(fmt.Sprint("invalid errno: ", errno))
+ }
+
+ e := error(syscall.Errno(errno))
+ // syserror.ErrWouldBlock gets translated to syserror.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 e == syserror.EWOULDBLOCK {
+ e = syserror.ErrWouldBlock
}
+ linuxBackwardsTranslations[errno] = linuxBackwardsTranslation{err: e, ok: true}
return err
}
@@ -58,7 +71,13 @@ func New(message string, linuxTranslation *linux.Errno) *Error {
// NewWithoutTranslation creates a new Error. If translation is attempted on
// the error, translation will fail.
func NewWithoutTranslation(message string) *Error {
- return &Error{message}
+ return &Error{message: message, noTranslation: true}
+}
+
+func newWithHost(message string, linuxTranslation *linux.Errno, hostErrno syscall.Errno) *Error {
+ e := New(message, linuxTranslation)
+ addLinuxHostTranslation(hostErrno, e)
+ return e
}
// String implements fmt.Stringer.String.
@@ -66,11 +85,16 @@ func (e *Error) String() string {
if e == nil {
return "<nil>"
}
- return e.string
+ return e.message
+}
+
+type linuxBackwardsTranslation struct {
+ err error
+ ok bool
}
// TODO: Remove this.
-var linuxBackwardsTranslations = map[*Error]error{}
+var linuxBackwardsTranslations [maxErrno]linuxBackwardsTranslation
// ToError translates an Error to a corresponding error value.
//
@@ -79,11 +103,26 @@ func (e *Error) ToError() error {
if e == nil {
return nil
}
- err, ok := linuxBackwardsTranslations[e]
- if !ok {
- panic(fmt.Sprintf("unknown error: %q", e.string))
+ if e.noTranslation {
+ panic(fmt.Sprintf("error %q does not support translation", e.message))
}
- return err
+ if e.errno == nil {
+ return nil
+ }
+ errno := e.errno.Number()
+ if errno <= 0 || errno >= len(linuxBackwardsTranslations) || !linuxBackwardsTranslations[errno].ok {
+ panic(fmt.Sprintf("unknown error %q (%d)", e.message, errno))
+ }
+ return linuxBackwardsTranslations[errno].err
+}
+
+// ToLinux converts the Error to a Linux ABI error that can be returned to the
+// application.
+func (e *Error) ToLinux() *linux.Errno {
+ if e.noTranslation {
+ panic(fmt.Sprintf("No Linux ABI translation available for %q", e.message))
+ }
+ return e.errno
}
// TODO: Remove or replace most of these errors.
@@ -91,134 +130,137 @@ func (e *Error) ToError() error {
// Some of the errors should be replaced with package specific errors and
// others should be removed entirely.
var (
- ErrNotPermitted = New("operation not permitted", linux.EPERM)
- ErrNoFileOrDir = New("no such file or directory", linux.ENOENT)
- ErrNoProcess = New("no such process", linux.ESRCH)
- ErrInterrupted = New("interrupted system call", linux.EINTR)
- ErrIO = New("I/O error", linux.EIO)
- ErrDeviceOrAddress = New("no such device or address", linux.ENXIO)
- ErrTooManyArgs = New("argument list too long", linux.E2BIG)
- ErrEcec = New("exec format error", linux.ENOEXEC)
- ErrBadFD = New("bad file number", linux.EBADF)
- ErrNoChild = New("no child processes", linux.ECHILD)
- ErrTryAgain = New("try again", linux.EAGAIN)
- ErrNoMemory = New("out of memory", linux.ENOMEM)
- ErrPermissionDenied = New("permission denied", linux.EACCES)
- ErrBadAddress = New("bad address", linux.EFAULT)
- ErrNotBlockDevice = New("block device required", linux.ENOTBLK)
- ErrBusy = New("device or resource busy", linux.EBUSY)
- ErrExists = New("file exists", linux.EEXIST)
- ErrCrossDeviceLink = New("cross-device link", linux.EXDEV)
- ErrNoDevice = New("no such device", linux.ENODEV)
- ErrNotDir = New("not a directory", linux.ENOTDIR)
- ErrIsDir = New("is a directory", linux.EISDIR)
- ErrInvalidArgument = New("invalid argument", linux.EINVAL)
- ErrFileTableOverflow = New("file table overflow", linux.ENFILE)
- ErrTooManyOpenFiles = New("too many open files", linux.EMFILE)
- ErrNotTTY = New("not a typewriter", linux.ENOTTY)
- ErrTestFileBusy = New("text file busy", linux.ETXTBSY)
- ErrFileTooBig = New("file too large", linux.EFBIG)
- ErrNoSpace = New("no space left on device", linux.ENOSPC)
- ErrIllegalSeek = New("illegal seek", linux.ESPIPE)
- ErrReadOnlyFS = New("read-only file system", linux.EROFS)
- ErrTooManyLinks = New("too many links", linux.EMLINK)
- ErrBrokenPipe = New("broken pipe", linux.EPIPE)
- ErrDomain = New("math argument out of domain of func", linux.EDOM)
- ErrRange = New("math result not representable", linux.ERANGE)
- ErrDeadlock = New("resource deadlock would occur", linux.EDEADLOCK)
- ErrNameTooLong = New("file name too long", linux.ENAMETOOLONG)
- ErrNoLocksAvailable = New("no record locks available", linux.ENOLCK)
- ErrInvalidSyscall = New("invalid system call number", linux.ENOSYS)
- ErrDirNotEmpty = New("directory not empty", linux.ENOTEMPTY)
- ErrLinkLoop = New("too many symbolic links encountered", linux.ELOOP)
- ErrWouldBlock = New("operation would block", linux.EWOULDBLOCK)
- ErrNoMessage = New("no message of desired type", linux.ENOMSG)
- ErrIdentifierRemoved = New("identifier removed", linux.EIDRM)
- ErrChannelOutOfRange = New("channel number out of range", linux.ECHRNG)
- ErrLevelTwoNotSynced = New("level 2 not synchronized", linux.EL2NSYNC)
- ErrLevelThreeHalted = New("level 3 halted", linux.EL3HLT)
- ErrLevelThreeReset = New("level 3 reset", linux.EL3RST)
- ErrLinkNumberOutOfRange = New("link number out of range", linux.ELNRNG)
- ErrProtocolDriverNotAttached = New("protocol driver not attached", linux.EUNATCH)
- ErrNoCSIAvailable = New("no CSI structure available", linux.ENOCSI)
- ErrLevelTwoHalted = New("level 2 halted", linux.EL2HLT)
- ErrInvalidExchange = New("invalid exchange", linux.EBADE)
- ErrInvalidRequestDescriptor = New("invalid request descriptor", linux.EBADR)
- ErrExchangeFull = New("exchange full", linux.EXFULL)
- ErrNoAnode = New("no anode", linux.ENOANO)
- ErrInvalidRequestCode = New("invalid request code", linux.EBADRQC)
- ErrInvalidSlot = New("invalid slot", linux.EBADSLT)
- ErrBadFontFile = New("bad font file format", linux.EBFONT)
- ErrNotStream = New("device not a stream", linux.ENOSTR)
- ErrNoDataAvailable = New("no data available", linux.ENODATA)
- ErrTimerExpired = New("timer expired", linux.ETIME)
- ErrStreamsResourceDepleted = New("out of streams resources", linux.ENOSR)
- ErrMachineNotOnNetwork = New("machine is not on the network", linux.ENONET)
- ErrPackageNotInstalled = New("package not installed", linux.ENOPKG)
- ErrIsRemote = New("object is remote", linux.EREMOTE)
- ErrNoLink = New("link has been severed", linux.ENOLINK)
- ErrAdvertise = New("advertise error", linux.EADV)
- ErrSRMount = New("srmount error", linux.ESRMNT)
- ErrSendCommunication = New("communication error on send", linux.ECOMM)
- ErrProtocol = New("protocol error", linux.EPROTO)
- ErrMultihopAttempted = New("multihop attempted", linux.EMULTIHOP)
- ErrRFS = New("RFS specific error", linux.EDOTDOT)
- ErrInvalidDataMessage = New("not a data message", linux.EBADMSG)
- ErrOverflow = New("value too large for defined data type", linux.EOVERFLOW)
- ErrNetworkNameNotUnique = New("name not unique on network", linux.ENOTUNIQ)
- ErrFDInBadState = New("file descriptor in bad state", linux.EBADFD)
- ErrRemoteAddressChanged = New("remote address changed", linux.EREMCHG)
- ErrSharedLibraryInaccessible = New("can not access a needed shared library", linux.ELIBACC)
- ErrCorruptedSharedLibrary = New("accessing a corrupted shared library", linux.ELIBBAD)
- ErrLibSectionCorrupted = New(".lib section in a.out corrupted", linux.ELIBSCN)
- ErrTooManySharedLibraries = New("attempting to link in too many shared libraries", linux.ELIBMAX)
- ErrSharedLibraryExeced = New("cannot exec a shared library directly", linux.ELIBEXEC)
- ErrIllegalByteSequence = New("illegal byte sequence", linux.EILSEQ)
- ErrShouldRestart = New("interrupted system call should be restarted", linux.ERESTART)
- ErrStreamPipe = New("streams pipe error", linux.ESTRPIPE)
- ErrTooManyUsers = New("too many users", linux.EUSERS)
- ErrNotASocket = New("socket operation on non-socket", linux.ENOTSOCK)
- ErrDestinationAddressRequired = New("destination address required", linux.EDESTADDRREQ)
- ErrMessageTooLong = New("message too long", linux.EMSGSIZE)
- ErrWrongProtocolForSocket = New("protocol wrong type for socket", linux.EPROTOTYPE)
- ErrProtocolNotAvailable = New("protocol not available", linux.ENOPROTOOPT)
- ErrProtocolNotSupported = New("protocol not supported", linux.EPROTONOSUPPORT)
- ErrSocketNotSupported = New("socket type not supported", linux.ESOCKTNOSUPPORT)
- ErrEndpointOperation = New("operation not supported on transport endpoint", linux.EOPNOTSUPP)
- ErrProtocolFamilyNotSupported = New("protocol family not supported", linux.EPFNOSUPPORT)
- ErrAddressFamilyNotSupported = New("address family not supported by protocol", linux.EAFNOSUPPORT)
- ErrAddressInUse = New("address already in use", linux.EADDRINUSE)
- ErrAddressNotAvailable = New("cannot assign requested address", linux.EADDRNOTAVAIL)
- ErrNetworkDown = New("network is down", linux.ENETDOWN)
- ErrNetworkUnreachable = New("network is unreachable", linux.ENETUNREACH)
- ErrNetworkReset = New("network dropped connection because of reset", linux.ENETRESET)
- ErrConnectionAborted = New("software caused connection abort", linux.ECONNABORTED)
- ErrConnectionReset = New("connection reset by peer", linux.ECONNRESET)
- ErrNoBufferSpace = New("no buffer space available", linux.ENOBUFS)
- ErrAlreadyConnected = New("transport endpoint is already connected", linux.EISCONN)
- ErrNotConnected = New("transport endpoint is not connected", linux.ENOTCONN)
- ErrShutdown = New("cannot send after transport endpoint shutdown", linux.ESHUTDOWN)
- ErrTooManyRefs = New("too many references: cannot splice", linux.ETOOMANYREFS)
- ErrTimedOut = New("connection timed out", linux.ETIMEDOUT)
- ErrConnectionRefused = New("connection refused", linux.ECONNREFUSED)
- ErrHostDown = New("host is down", linux.EHOSTDOWN)
- ErrNoRoute = New("no route to host", linux.EHOSTUNREACH)
- ErrAlreadyInProgress = New("operation already in progress", linux.EALREADY)
- ErrInProgress = New("operation now in progress", linux.EINPROGRESS)
- ErrStaleFileHandle = New("stale file handle", linux.ESTALE)
- ErrStructureNeedsCleaning = New("structure needs cleaning", linux.EUCLEAN)
- ErrIsNamedFile = New("is a named type file", linux.ENOTNAM)
- ErrRemoteIO = New("remote I/O error", linux.EREMOTEIO)
- ErrQuotaExceeded = New("quota exceeded", linux.EDQUOT)
- ErrNoMedium = New("no medium found", linux.ENOMEDIUM)
- ErrWrongMediumType = New("wrong medium type", linux.EMEDIUMTYPE)
- ErrCanceled = New("operation Canceled", linux.ECANCELED)
- ErrNoKey = New("required key not available", linux.ENOKEY)
- ErrKeyExpired = New("key has expired", linux.EKEYEXPIRED)
- ErrKeyRevoked = New("key has been revoked", linux.EKEYREVOKED)
- ErrKeyRejected = New("key was rejected by service", linux.EKEYREJECTED)
- ErrOwnerDied = New("owner died", linux.EOWNERDEAD)
- ErrNotRecoverable = New("state not recoverable", linux.ENOTRECOVERABLE)
+ ErrNotPermitted = newWithHost("operation not permitted", linux.EPERM, syscall.EPERM)
+ ErrNoFileOrDir = newWithHost("no such file or directory", linux.ENOENT, syscall.ENOENT)
+ ErrNoProcess = newWithHost("no such process", linux.ESRCH, syscall.ESRCH)
+ ErrInterrupted = newWithHost("interrupted system call", linux.EINTR, syscall.EINTR)
+ ErrIO = newWithHost("I/O error", linux.EIO, syscall.EIO)
+ ErrDeviceOrAddress = newWithHost("no such device or address", linux.ENXIO, syscall.ENXIO)
+ ErrTooManyArgs = newWithHost("argument list too long", linux.E2BIG, syscall.E2BIG)
+ ErrEcec = newWithHost("exec format error", linux.ENOEXEC, syscall.ENOEXEC)
+ ErrBadFD = newWithHost("bad file number", linux.EBADF, syscall.EBADF)
+ ErrNoChild = newWithHost("no child processes", linux.ECHILD, syscall.ECHILD)
+ ErrTryAgain = newWithHost("try again", linux.EAGAIN, syscall.EAGAIN)
+ ErrNoMemory = newWithHost("out of memory", linux.ENOMEM, syscall.ENOMEM)
+ ErrPermissionDenied = newWithHost("permission denied", linux.EACCES, syscall.EACCES)
+ ErrBadAddress = newWithHost("bad address", linux.EFAULT, syscall.EFAULT)
+ ErrNotBlockDevice = newWithHost("block device required", linux.ENOTBLK, syscall.ENOTBLK)
+ ErrBusy = newWithHost("device or resource busy", linux.EBUSY, syscall.EBUSY)
+ ErrExists = newWithHost("file exists", linux.EEXIST, syscall.EEXIST)
+ ErrCrossDeviceLink = newWithHost("cross-device link", linux.EXDEV, syscall.EXDEV)
+ ErrNoDevice = newWithHost("no such device", linux.ENODEV, syscall.ENODEV)
+ ErrNotDir = newWithHost("not a directory", linux.ENOTDIR, syscall.ENOTDIR)
+ ErrIsDir = newWithHost("is a directory", linux.EISDIR, syscall.EISDIR)
+ ErrInvalidArgument = newWithHost("invalid argument", linux.EINVAL, syscall.EINVAL)
+ ErrFileTableOverflow = newWithHost("file table overflow", linux.ENFILE, syscall.ENFILE)
+ ErrTooManyOpenFiles = newWithHost("too many open files", linux.EMFILE, syscall.EMFILE)
+ ErrNotTTY = newWithHost("not a typewriter", linux.ENOTTY, syscall.ENOTTY)
+ ErrTestFileBusy = newWithHost("text file busy", linux.ETXTBSY, syscall.ETXTBSY)
+ ErrFileTooBig = newWithHost("file too large", linux.EFBIG, syscall.EFBIG)
+ ErrNoSpace = newWithHost("no space left on device", linux.ENOSPC, syscall.ENOSPC)
+ ErrIllegalSeek = newWithHost("illegal seek", linux.ESPIPE, syscall.ESPIPE)
+ ErrReadOnlyFS = newWithHost("read-only file system", linux.EROFS, syscall.EROFS)
+ ErrTooManyLinks = newWithHost("too many links", linux.EMLINK, syscall.EMLINK)
+ ErrBrokenPipe = newWithHost("broken pipe", linux.EPIPE, syscall.EPIPE)
+ ErrDomain = newWithHost("math argument out of domain of func", linux.EDOM, syscall.EDOM)
+ ErrRange = newWithHost("math result not representable", linux.ERANGE, syscall.ERANGE)
+ ErrDeadlock = newWithHost("resource deadlock would occur", linux.EDEADLOCK, syscall.EDEADLOCK)
+ ErrNameTooLong = newWithHost("file name too long", linux.ENAMETOOLONG, syscall.ENAMETOOLONG)
+ ErrNoLocksAvailable = newWithHost("no record locks available", linux.ENOLCK, syscall.ENOLCK)
+ ErrInvalidSyscall = newWithHost("invalid system call number", linux.ENOSYS, syscall.ENOSYS)
+ ErrDirNotEmpty = newWithHost("directory not empty", linux.ENOTEMPTY, syscall.ENOTEMPTY)
+ ErrLinkLoop = newWithHost("too many symbolic links encountered", linux.ELOOP, syscall.ELOOP)
+ ErrNoMessage = newWithHost("no message of desired type", linux.ENOMSG, syscall.ENOMSG)
+ ErrIdentifierRemoved = newWithHost("identifier removed", linux.EIDRM, syscall.EIDRM)
+ ErrChannelOutOfRange = newWithHost("channel number out of range", linux.ECHRNG, syscall.ECHRNG)
+ ErrLevelTwoNotSynced = newWithHost("level 2 not synchronized", linux.EL2NSYNC, syscall.EL2NSYNC)
+ ErrLevelThreeHalted = newWithHost("level 3 halted", linux.EL3HLT, syscall.EL3HLT)
+ ErrLevelThreeReset = newWithHost("level 3 reset", linux.EL3RST, syscall.EL3RST)
+ ErrLinkNumberOutOfRange = newWithHost("link number out of range", linux.ELNRNG, syscall.ELNRNG)
+ ErrProtocolDriverNotAttached = newWithHost("protocol driver not attached", linux.EUNATCH, syscall.EUNATCH)
+ ErrNoCSIAvailable = newWithHost("no CSI structure available", linux.ENOCSI, syscall.ENOCSI)
+ ErrLevelTwoHalted = newWithHost("level 2 halted", linux.EL2HLT, syscall.EL2HLT)
+ ErrInvalidExchange = newWithHost("invalid exchange", linux.EBADE, syscall.EBADE)
+ ErrInvalidRequestDescriptor = newWithHost("invalid request descriptor", linux.EBADR, syscall.EBADR)
+ ErrExchangeFull = newWithHost("exchange full", linux.EXFULL, syscall.EXFULL)
+ ErrNoAnode = newWithHost("no anode", linux.ENOANO, syscall.ENOANO)
+ ErrInvalidRequestCode = newWithHost("invalid request code", linux.EBADRQC, syscall.EBADRQC)
+ ErrInvalidSlot = newWithHost("invalid slot", linux.EBADSLT, syscall.EBADSLT)
+ ErrBadFontFile = newWithHost("bad font file format", linux.EBFONT, syscall.EBFONT)
+ ErrNotStream = newWithHost("device not a stream", linux.ENOSTR, syscall.ENOSTR)
+ ErrNoDataAvailable = newWithHost("no data available", linux.ENODATA, syscall.ENODATA)
+ ErrTimerExpired = newWithHost("timer expired", linux.ETIME, syscall.ETIME)
+ ErrStreamsResourceDepleted = newWithHost("out of streams resources", linux.ENOSR, syscall.ENOSR)
+ ErrMachineNotOnNetwork = newWithHost("machine is not on the network", linux.ENONET, syscall.ENONET)
+ ErrPackageNotInstalled = newWithHost("package not installed", linux.ENOPKG, syscall.ENOPKG)
+ ErrIsRemote = newWithHost("object is remote", linux.EREMOTE, syscall.EREMOTE)
+ ErrNoLink = newWithHost("link has been severed", linux.ENOLINK, syscall.ENOLINK)
+ ErrAdvertise = newWithHost("advertise error", linux.EADV, syscall.EADV)
+ ErrSRMount = newWithHost("srmount error", linux.ESRMNT, syscall.ESRMNT)
+ ErrSendCommunication = newWithHost("communication error on send", linux.ECOMM, syscall.ECOMM)
+ ErrProtocol = newWithHost("protocol error", linux.EPROTO, syscall.EPROTO)
+ ErrMultihopAttempted = newWithHost("multihop attempted", linux.EMULTIHOP, syscall.EMULTIHOP)
+ ErrRFS = newWithHost("RFS specific error", linux.EDOTDOT, syscall.EDOTDOT)
+ ErrInvalidDataMessage = newWithHost("not a data message", linux.EBADMSG, syscall.EBADMSG)
+ ErrOverflow = newWithHost("value too large for defined data type", linux.EOVERFLOW, syscall.EOVERFLOW)
+ ErrNetworkNameNotUnique = newWithHost("name not unique on network", linux.ENOTUNIQ, syscall.ENOTUNIQ)
+ ErrFDInBadState = newWithHost("file descriptor in bad state", linux.EBADFD, syscall.EBADFD)
+ ErrRemoteAddressChanged = newWithHost("remote address changed", linux.EREMCHG, syscall.EREMCHG)
+ ErrSharedLibraryInaccessible = newWithHost("can not access a needed shared library", linux.ELIBACC, syscall.ELIBACC)
+ ErrCorruptedSharedLibrary = newWithHost("accessing a corrupted shared library", linux.ELIBBAD, syscall.ELIBBAD)
+ ErrLibSectionCorrupted = newWithHost(".lib section in a.out corrupted", linux.ELIBSCN, syscall.ELIBSCN)
+ ErrTooManySharedLibraries = newWithHost("attempting to link in too many shared libraries", linux.ELIBMAX, syscall.ELIBMAX)
+ ErrSharedLibraryExeced = newWithHost("cannot exec a shared library directly", linux.ELIBEXEC, syscall.ELIBEXEC)
+ ErrIllegalByteSequence = newWithHost("illegal byte sequence", linux.EILSEQ, syscall.EILSEQ)
+ ErrShouldRestart = newWithHost("interrupted system call should be restarted", linux.ERESTART, syscall.ERESTART)
+ ErrStreamPipe = newWithHost("streams pipe error", linux.ESTRPIPE, syscall.ESTRPIPE)
+ ErrTooManyUsers = newWithHost("too many users", linux.EUSERS, syscall.EUSERS)
+ ErrNotASocket = newWithHost("socket operation on non-socket", linux.ENOTSOCK, syscall.ENOTSOCK)
+ ErrDestinationAddressRequired = newWithHost("destination address required", linux.EDESTADDRREQ, syscall.EDESTADDRREQ)
+ ErrMessageTooLong = newWithHost("message too long", linux.EMSGSIZE, syscall.EMSGSIZE)
+ ErrWrongProtocolForSocket = newWithHost("protocol wrong type for socket", linux.EPROTOTYPE, syscall.EPROTOTYPE)
+ ErrProtocolNotAvailable = newWithHost("protocol not available", linux.ENOPROTOOPT, syscall.ENOPROTOOPT)
+ ErrProtocolNotSupported = newWithHost("protocol not supported", linux.EPROTONOSUPPORT, syscall.EPROTONOSUPPORT)
+ ErrSocketNotSupported = newWithHost("socket type not supported", linux.ESOCKTNOSUPPORT, syscall.ESOCKTNOSUPPORT)
+ ErrEndpointOperation = newWithHost("operation not supported on transport endpoint", linux.EOPNOTSUPP, syscall.EOPNOTSUPP)
+ ErrProtocolFamilyNotSupported = newWithHost("protocol family not supported", linux.EPFNOSUPPORT, syscall.EPFNOSUPPORT)
+ ErrAddressFamilyNotSupported = newWithHost("address family not supported by protocol", linux.EAFNOSUPPORT, syscall.EAFNOSUPPORT)
+ ErrAddressInUse = newWithHost("address already in use", linux.EADDRINUSE, syscall.EADDRINUSE)
+ ErrAddressNotAvailable = newWithHost("cannot assign requested address", linux.EADDRNOTAVAIL, syscall.EADDRNOTAVAIL)
+ ErrNetworkDown = newWithHost("network is down", linux.ENETDOWN, syscall.ENETDOWN)
+ ErrNetworkUnreachable = newWithHost("network is unreachable", linux.ENETUNREACH, syscall.ENETUNREACH)
+ ErrNetworkReset = newWithHost("network dropped connection because of reset", linux.ENETRESET, syscall.ENETRESET)
+ ErrConnectionAborted = newWithHost("software caused connection abort", linux.ECONNABORTED, syscall.ECONNABORTED)
+ ErrConnectionReset = newWithHost("connection reset by peer", linux.ECONNRESET, syscall.ECONNRESET)
+ ErrNoBufferSpace = newWithHost("no buffer space available", linux.ENOBUFS, syscall.ENOBUFS)
+ ErrAlreadyConnected = newWithHost("transport endpoint is already connected", linux.EISCONN, syscall.EISCONN)
+ ErrNotConnected = newWithHost("transport endpoint is not connected", linux.ENOTCONN, syscall.ENOTCONN)
+ ErrShutdown = newWithHost("cannot send after transport endpoint shutdown", linux.ESHUTDOWN, syscall.ESHUTDOWN)
+ ErrTooManyRefs = newWithHost("too many references: cannot splice", linux.ETOOMANYREFS, syscall.ETOOMANYREFS)
+ ErrTimedOut = newWithHost("connection timed out", linux.ETIMEDOUT, syscall.ETIMEDOUT)
+ ErrConnectionRefused = newWithHost("connection refused", linux.ECONNREFUSED, syscall.ECONNREFUSED)
+ ErrHostDown = newWithHost("host is down", linux.EHOSTDOWN, syscall.EHOSTDOWN)
+ ErrNoRoute = newWithHost("no route to host", linux.EHOSTUNREACH, syscall.EHOSTUNREACH)
+ ErrAlreadyInProgress = newWithHost("operation already in progress", linux.EALREADY, syscall.EALREADY)
+ ErrInProgress = newWithHost("operation now in progress", linux.EINPROGRESS, syscall.EINPROGRESS)
+ ErrStaleFileHandle = newWithHost("stale file handle", linux.ESTALE, syscall.ESTALE)
+ ErrStructureNeedsCleaning = newWithHost("structure needs cleaning", linux.EUCLEAN, syscall.EUCLEAN)
+ ErrIsNamedFile = newWithHost("is a named type file", linux.ENOTNAM, syscall.ENOTNAM)
+ ErrRemoteIO = newWithHost("remote I/O error", linux.EREMOTEIO, syscall.EREMOTEIO)
+ ErrQuotaExceeded = newWithHost("quota exceeded", linux.EDQUOT, syscall.EDQUOT)
+ ErrNoMedium = newWithHost("no medium found", linux.ENOMEDIUM, syscall.ENOMEDIUM)
+ ErrWrongMediumType = newWithHost("wrong medium type", linux.EMEDIUMTYPE, syscall.EMEDIUMTYPE)
+ ErrCanceled = newWithHost("operation canceled", linux.ECANCELED, syscall.ECANCELED)
+ ErrNoKey = newWithHost("required key not available", linux.ENOKEY, syscall.ENOKEY)
+ ErrKeyExpired = newWithHost("key has expired", linux.EKEYEXPIRED, syscall.EKEYEXPIRED)
+ ErrKeyRevoked = newWithHost("key has been revoked", linux.EKEYREVOKED, syscall.EKEYREVOKED)
+ ErrKeyRejected = newWithHost("key was rejected by service", linux.EKEYREJECTED, syscall.EKEYREJECTED)
+ ErrOwnerDied = newWithHost("owner died", linux.EOWNERDEAD, syscall.EOWNERDEAD)
+ ErrNotRecoverable = newWithHost("state not recoverable", linux.ENOTRECOVERABLE, syscall.ENOTRECOVERABLE)
+
+ // ErrWouldBlock translates to EWOULDBLOCK which is the same as EAGAIN
+ // on Linux.
+ ErrWouldBlock = New("operation would block", linux.EWOULDBLOCK)
)
// FromError converts a generic error to an *Error.