linuxerr

package
v0.0.0-...-c27c9a0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2024 License: Apache-2.0, MIT Imports: 4 Imported by: 196

Documentation

Overview

Package linuxerr contains syscall error codes exported as an error interface pointers. This allows for fast comparison and return operations comparable to unix.Errno constants.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrWouldBlock is an internal error used to indicate that an operation
	// cannot be satisfied immediately, and should be retried at a later
	// time, possibly when the caller has received a notification that the
	// operation may be able to complete. It is used by implementations of
	// the kio.File interface.
	ErrWouldBlock = errors.New(errno.EWOULDBLOCK, "request would block")

	// ErrInterrupted is returned if a request is interrupted before it can
	// complete.
	ErrInterrupted = errors.New(errno.EINTR, "request was interrupted")

	// ErrExceedsFileSizeLimit is returned if a request would exceed the
	// file's size limit.
	ErrExceedsFileSizeLimit = errors.New(errno.E2BIG, "exceeds file size limit")
)
View Source
var (
	// ERESTARTSYS is returned by an interrupted syscall to indicate that it
	// should be converted to EINTR if interrupted by a signal delivered to a
	// user handler without SA_RESTART set, and restarted otherwise.
	ERESTARTSYS = errors.New(errno.ERESTARTSYS, "to be restarted if SA_RESTART is set")

	// ERESTARTNOINTR is returned by an interrupted syscall to indicate that it
	// should always be restarted.
	ERESTARTNOINTR = errors.New(errno.ERESTARTNOINTR, "to be restarted")

	// ERESTARTNOHAND is returned by an interrupted syscall to indicate that it
	// should be converted to EINTR if interrupted by a signal delivered to a
	// user handler, and restarted otherwise.
	ERESTARTNOHAND = errors.New(errno.ERESTARTNOHAND, "to be restarted if no handler")

	// ERESTART_RESTARTBLOCK is returned by an interrupted syscall to indicate
	// that it should be restarted using a custom function. The interrupted
	// syscall must register a custom restart function by calling
	// Task.SetRestartSyscallFn.
	ERESTART_RESTARTBLOCK = errors.New(errno.ERESTART_RESTARTBLOCK, "interrupted by signal")
)

These errors are significant because ptrace syscall exit tracing can observe them.

For all of the following errors, if the syscall is not interrupted by a signal delivered to a user handler, the syscall is restarted.

View Source
var (
	EPERM   = errors.New(errno.EPERM, "operation not permitted")
	ENOENT  = errors.New(errno.ENOENT, "no such file or directory")
	ESRCH   = errors.New(errno.ESRCH, "no such process")
	EINTR   = errors.New(errno.EINTR, "interrupted system call")
	EIO     = errors.New(errno.EIO, "I/O error")
	ENXIO   = errors.New(errno.ENXIO, "no such device or address")
	E2BIG   = errors.New(errno.E2BIG, "argument list too long")
	ENOEXEC = errors.New(errno.ENOEXEC, "exec format error")
	EBADF   = errors.New(errno.EBADF, "bad file number")
	ECHILD  = errors.New(errno.ECHILD, "no child processes")
	EAGAIN  = errors.New(errno.EAGAIN, "try again")
	ENOMEM  = errors.New(errno.ENOMEM, "out of memory")
	EACCES  = errors.New(errno.EACCES, "permission denied")
	EFAULT  = errors.New(errno.EFAULT, "bad address")
	ENOTBLK = errors.New(errno.ENOTBLK, "block device required")
	EBUSY   = errors.New(errno.EBUSY, "device or resource busy")
	EEXIST  = errors.New(errno.EEXIST, "file exists")
	EXDEV   = errors.New(errno.EXDEV, "cross-device link")
	ENODEV  = errors.New(errno.ENODEV, "no such device")
	ENOTDIR = errors.New(errno.ENOTDIR, "not a directory")
	EISDIR  = errors.New(errno.EISDIR, "is a directory")
	EINVAL  = errors.New(errno.EINVAL, "invalid argument")
	ENFILE  = errors.New(errno.ENFILE, "file table overflow")
	EMFILE  = errors.New(errno.EMFILE, "too many open files")
	ENOTTY  = errors.New(errno.ENOTTY, "not a typewriter")
	ETXTBSY = errors.New(errno.ETXTBSY, "text file busy")
	EFBIG   = errors.New(errno.EFBIG, "file too large")
	ENOSPC  = errors.New(errno.ENOSPC, "no space left on device")
	ESPIPE  = errors.New(errno.ESPIPE, "illegal seek")
	EROFS   = errors.New(errno.EROFS, "read-only file system")
	EMLINK  = errors.New(errno.EMLINK, "too many links")
	EPIPE   = errors.New(errno.EPIPE, "broken pipe")
	EDOM    = errors.New(errno.EDOM, "math argument out of domain of func")
	ERANGE  = errors.New(errno.ERANGE, "math result not representable")

	// Errno values from include/uapi/asm-generic/errno.h.
	EDEADLK         = errors.New(errno.EDEADLK, "resource deadlock would occur")
	ENAMETOOLONG    = errors.New(errno.ENAMETOOLONG, "file name too long")
	ENOLCK          = errors.New(errno.ENOLCK, "no record locks available")
	ENOSYS          = errors.New(errno.ENOSYS, "invalid system call number")
	ENOTEMPTY       = errors.New(errno.ENOTEMPTY, "directory not empty")
	ELOOP           = errors.New(errno.ELOOP, "too many symbolic links encountered")
	ENOMSG          = errors.New(errno.ENOMSG, "no message of desired type")
	EIDRM           = errors.New(errno.EIDRM, "identifier removed")
	ECHRNG          = errors.New(errno.ECHRNG, "channel number out of range")
	EL2NSYNC        = errors.New(errno.EL2NSYNC, "level 2 not synchronized")
	EL3HLT          = errors.New(errno.EL3HLT, "level 3 halted")
	EL3RST          = errors.New(errno.EL3RST, "level 3 reset")
	ELNRNG          = errors.New(errno.ELNRNG, "link number out of range")
	EUNATCH         = errors.New(errno.EUNATCH, "protocol driver not attached")
	ENOCSI          = errors.New(errno.ENOCSI, "no CSI structure available")
	EL2HLT          = errors.New(errno.EL2HLT, "level 2 halted")
	EBADE           = errors.New(errno.EBADE, "invalid exchange")
	EBADR           = errors.New(errno.EBADR, "invalid request descriptor")
	EXFULL          = errors.New(errno.EXFULL, "exchange full")
	ENOANO          = errors.New(errno.ENOANO, "no anode")
	EBADRQC         = errors.New(errno.EBADRQC, "invalid request code")
	EBADSLT         = errors.New(errno.EBADSLT, "invalid slot")
	EBFONT          = errors.New(errno.EBFONT, "bad font file format")
	ENOSTR          = errors.New(errno.ENOSTR, "device not a stream")
	ENODATA         = errors.New(errno.ENODATA, "no data available")
	ETIME           = errors.New(errno.ETIME, "timer expired")
	ENOSR           = errors.New(errno.ENOSR, "out of streams resources")
	ENOPKG          = errors.New(errno.ENOPKG, "package not installed")
	EREMOTE         = errors.New(errno.EREMOTE, "object is remote")
	ENOLINK         = errors.New(errno.ENOLINK, "link has been severed")
	EADV            = errors.New(errno.EADV, "advertise error")
	ESRMNT          = errors.New(errno.ESRMNT, "srmount error")
	ECOMM           = errors.New(errno.ECOMM, "communication error on send")
	EPROTO          = errors.New(errno.EPROTO, "protocol error")
	EMULTIHOP       = errors.New(errno.EMULTIHOP, "multihop attempted")
	EDOTDOT         = errors.New(errno.EDOTDOT, "RFS specific error")
	EBADMSG         = errors.New(errno.EBADMSG, "not a data message")
	EOVERFLOW       = errors.New(errno.EOVERFLOW, "value too large for defined data type")
	ENOTUNIQ        = errors.New(errno.ENOTUNIQ, "name not unique on network")
	EBADFD          = errors.New(errno.EBADFD, "file descriptor in bad state")
	EREMCHG         = errors.New(errno.EREMCHG, "remote address changed")
	ELIBACC         = errors.New(errno.ELIBACC, "can not access a needed shared library")
	ELIBBAD         = errors.New(errno.ELIBBAD, "accessing a corrupted shared library")
	ELIBSCN         = errors.New(errno.ELIBSCN, ".lib section in a.out corrupted")
	ELIBMAX         = errors.New(errno.ELIBMAX, "attempting to link in too many shared libraries")
	ELIBEXEC        = errors.New(errno.ELIBEXEC, "cannot exec a shared library directly")
	EILSEQ          = errors.New(errno.EILSEQ, "illegal byte sequence")
	ERESTART        = errors.New(errno.ERESTART, "interrupted system call should be restarted")
	ESTRPIPE        = errors.New(errno.ESTRPIPE, "streams pipe error")
	EUSERS          = errors.New(errno.EUSERS, "too many users")
	ENOTSOCK        = errors.New(errno.ENOTSOCK, "socket operation on non-socket")
	EDESTADDRREQ    = errors.New(errno.EDESTADDRREQ, "destination address required")
	EMSGSIZE        = errors.New(errno.EMSGSIZE, "message too long")
	EPROTOTYPE      = errors.New(errno.EPROTOTYPE, "protocol wrong type for socket")
	ENOPROTOOPT     = errors.New(errno.ENOPROTOOPT, "protocol not available")
	EPROTONOSUPPORT = errors.New(errno.EPROTONOSUPPORT, "protocol not supported")
	ESOCKTNOSUPPORT = errors.New(errno.ESOCKTNOSUPPORT, "socket type not supported")
	EOPNOTSUPP      = errors.New(errno.EOPNOTSUPP, "operation not supported on transport endpoint")
	EPFNOSUPPORT    = errors.New(errno.EPFNOSUPPORT, "protocol family not supported")
	EAFNOSUPPORT    = errors.New(errno.EAFNOSUPPORT, "address family not supported by protocol")
	EADDRINUSE      = errors.New(errno.EADDRINUSE, "address already in use")
	EADDRNOTAVAIL   = errors.New(errno.EADDRNOTAVAIL, "cannot assign requested address")
	ENETDOWN        = errors.New(errno.ENETDOWN, "network is down")
	ENETUNREACH     = errors.New(errno.ENETUNREACH, "network is unreachable")
	ENETRESET       = errors.New(errno.ENETRESET, "network dropped connection because of reset")
	ECONNABORTED    = errors.New(errno.ECONNABORTED, "software caused connection abort")
	ECONNRESET      = errors.New(errno.ECONNRESET, "connection reset by peer")
	ENOBUFS         = errors.New(errno.ENOBUFS, "no buffer space available")
	EISCONN         = errors.New(errno.EISCONN, "transport endpoint is already connected")
	ENOTCONN        = errors.New(errno.ENOTCONN, "transport endpoint is not connected")
	ESHUTDOWN       = errors.New(errno.ESHUTDOWN, "cannot send after transport endpoint shutdown")
	ETOOMANYREFS    = errors.New(errno.ETOOMANYREFS, "too many references: cannot splice")
	ETIMEDOUT       = errors.New(errno.ETIMEDOUT, "connection timed out")
	ECONNREFUSED    = errors.New(errno.ECONNREFUSED, "connection refused")
	EHOSTDOWN       = errors.New(errno.EHOSTDOWN, "host is down")
	EHOSTUNREACH    = errors.New(errno.EHOSTUNREACH, "no route to host")
	EALREADY        = errors.New(errno.EALREADY, "operation already in progress")
	EINPROGRESS     = errors.New(errno.EINPROGRESS, "operation now in progress")
	ESTALE          = errors.New(errno.ESTALE, "stale file handle")
	EUCLEAN         = errors.New(errno.EUCLEAN, "structure needs cleaning")
	ENOTNAM         = errors.New(errno.ENOTNAM, "not a XENIX named type file")
	ENAVAIL         = errors.New(errno.ENAVAIL, "no XENIX semaphores available")
	EISNAM          = errors.New(errno.EISNAM, "is a named type file")
	EREMOTEIO       = errors.New(errno.EREMOTEIO, "remote I/O error")
	EDQUOT          = errors.New(errno.EDQUOT, "quota exceeded")
	ENOMEDIUM       = errors.New(errno.ENOMEDIUM, "no medium found")
	EMEDIUMTYPE     = errors.New(errno.EMEDIUMTYPE, "wrong medium type")
	ECANCELED       = errors.New(errno.ECANCELED, "operation Canceled")
	ENOKEY          = errors.New(errno.ENOKEY, "required key not available")
	EKEYEXPIRED     = errors.New(errno.EKEYEXPIRED, "key has expired")
	EKEYREVOKED     = errors.New(errno.EKEYREVOKED, "key has been revoked")
	EKEYREJECTED    = errors.New(errno.EKEYREJECTED, "key was rejected by service")
	EOWNERDEAD      = errors.New(errno.EOWNERDEAD, "owner died")
	ENOTRECOVERABLE = errors.New(errno.ENOTRECOVERABLE, "state not recoverable")
	ERFKILL         = errors.New(errno.ERFKILL, "operation not possible due to RF-kill")
	EHWPOISON       = errors.New(errno.EHWPOISON, "memory page has hardware error")

	// Errors equivalent to other errors.
	EWOULDBLOCK = EAGAIN
	EDEADLOCK   = EDEADLK
	ENONET      = ENOENT
	ENOATTR     = ENODATA
	ENOTSUP     = EOPNOTSUPP
)

The following errors are semantically identical to Errno of type unix.Errno or sycall.Errno. However, since the type are distinct ( these are *errors.Error), they are not directly comparable. However, the Errno method returns an Errno number such that the error can be compared to unix/syscall.Errno (e.g. unix.Errno(EPERM.Errno()) == unix.EPERM is true). Converting unix/syscall.Errno to the errors should be done via the lookup methods provided.

Functions

func AddErrorUnwrapper

func AddErrorUnwrapper(unwrap func(e error) (*errors.Error, bool))

AddErrorUnwrapper registers an unwrap method that can extract a concrete error from a typed, but not initialized, error.

func ConvertIntr

func ConvertIntr(err, intr error) error

ConvertIntr converts the provided error code (err) to another one (intr) if the first error corresponds to an interrupted operation.

func Equals

func Equals(e *errors.Error, err error) bool

Equals compares a linuxerr to a given error.

func ErrorFromUnix

func ErrorFromUnix(err unix.Errno) error

ErrorFromUnix returns a linuxerr from a unix.Errno.

func IsRestartError

func IsRestartError(err error) bool

IsRestartError checks if a given error is a restart error.

func SyscallRestartErrorFromReturn

func SyscallRestartErrorFromReturn(rv uintptr) (*errors.Error, bool)

SyscallRestartErrorFromReturn returns the SyscallRestartErrno represented by rv, the value in a syscall return register.

func ToError

func ToError(err *errors.Error) error

ToError converts a linuxerr to an error type.

func ToUnix

func ToUnix(e *errors.Error) unix.Errno

ToUnix converts a linuxerr to a unix.Errno.

func TranslateError

func TranslateError(from error) (*errors.Error, bool)

TranslateError translates errors to errnos for registered internal errors. It will return false if the error was not registered.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL