syserror

package
v0.0.0-...-ff2c174 Latest Latest
Warning

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

Go to latest
Published: May 9, 2021 License: Apache-2.0, MIT Imports: 1 Imported by: 0

Documentation

Overview

Package syserror contains syscall error codes exported as error interface instead of Errno. This allows for fast comparison and returns when the comparand or return value is of type error because there is no need to convert from Errno to an interface, i.e., runtime.convT2I isn't called.

Index

Constants

View Source
const (
	// 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 = SyscallRestartErrno(512)

	// ERESTARTNOINTR is returned by an interrupted syscall to indicate that it
	// should always be restarted.
	ERESTARTNOINTR = SyscallRestartErrno(513)

	// 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 = SyscallRestartErrno(514)

	// 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 = SyscallRestartErrno(516)
)

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

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

Variables

View Source
var (
	E2BIG        = error(unix.E2BIG)
	EACCES       = error(unix.EACCES)
	EADDRINUSE   = error(unix.EADDRINUSE)
	EAGAIN       = error(unix.EAGAIN)
	EBADF        = error(unix.EBADF)
	EBADFD       = error(unix.EBADFD)
	EBUSY        = error(unix.EBUSY)
	ECHILD       = error(unix.ECHILD)
	ECONNABORTED = error(unix.ECONNABORTED)
	ECONNREFUSED = error(unix.ECONNREFUSED)
	ECONNRESET   = error(unix.ECONNRESET)
	EDEADLK      = error(unix.EDEADLK)
	EEXIST       = error(unix.EEXIST)
	EFAULT       = error(unix.EFAULT)
	EFBIG        = error(unix.EFBIG)
	EIDRM        = error(unix.EIDRM)
	EINTR        = error(unix.EINTR)
	EINVAL       = error(unix.EINVAL)
	EIO          = error(unix.EIO)
	EISDIR       = error(unix.EISDIR)
	ELIBBAD      = error(unix.ELIBBAD)
	ELOOP        = error(unix.ELOOP)
	EMFILE       = error(unix.EMFILE)
	EMLINK       = error(unix.EMLINK)
	EMSGSIZE     = error(unix.EMSGSIZE)
	ENAMETOOLONG = error(unix.ENAMETOOLONG)
	ENOATTR      = ENODATA
	ENOBUFS      = error(unix.ENOBUFS)
	ENODATA      = error(unix.ENODATA)
	ENODEV       = error(unix.ENODEV)
	ENOENT       = error(unix.ENOENT)
	ENOEXEC      = error(unix.ENOEXEC)
	ENOLCK       = error(unix.ENOLCK)
	ENOLINK      = error(unix.ENOLINK)
	ENOMEM       = error(unix.ENOMEM)
	ENOSPC       = error(unix.ENOSPC)
	ENOSYS       = error(unix.ENOSYS)
	ENOTCONN     = error(unix.ENOTCONN)
	ENOTDIR      = error(unix.ENOTDIR)
	ENOTEMPTY    = error(unix.ENOTEMPTY)
	ENOTSOCK     = error(unix.ENOTSOCK)
	ENOTSUP      = error(unix.ENOTSUP)
	ENOTTY       = error(unix.ENOTTY)
	ENXIO        = error(unix.ENXIO)
	EOPNOTSUPP   = error(unix.EOPNOTSUPP)
	EOVERFLOW    = error(unix.EOVERFLOW)
	EPERM        = error(unix.EPERM)
	EPIPE        = error(unix.EPIPE)
	ERANGE       = error(unix.ERANGE)
	EREMOTE      = error(unix.EREMOTE)
	EROFS        = error(unix.EROFS)
	ESPIPE       = error(unix.ESPIPE)
	ESRCH        = error(unix.ESRCH)
	ETIMEDOUT    = error(unix.ETIMEDOUT)
	EUSERS       = error(unix.EUSERS)
	EWOULDBLOCK  = error(unix.EWOULDBLOCK)
	EXDEV        = error(unix.EXDEV)
)

The following variables have the same meaning as their syscall equivalent.

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("request would block")

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

	// ErrExceedsFileSizeLimit is returned if a request would exceed the
	// file's size limit.
	ErrExceedsFileSizeLimit = errors.New("exceeds file size limit")
)

Functions

func AddErrorTranslation

func AddErrorTranslation(from error, to unix.Errno) bool

AddErrorTranslation allows modules to populate the error map by adding their own translations during initialization. Returns if the error translation is accepted or not. A pre-existing translation will not be overwritten by the new translation.

func AddErrorUnwrapper

func AddErrorUnwrapper(unwrap func(e error) (unix.Errno, 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 TranslateError

func TranslateError(from error) (unix.Errno, bool)

TranslateError translates errors to errnos, it will return false if the error was not registered.

Types

type SyscallRestartErrno

type SyscallRestartErrno int

SyscallRestartErrno represents a ERESTART* errno defined in the Linux's kernel include/linux/errno.h. These errnos are never returned to userspace directly, but are used to communicate the expected behavior of an interrupted syscall from the syscall to signal handling.

func SyscallRestartErrnoFromReturn

func SyscallRestartErrnoFromReturn(rv uintptr) (SyscallRestartErrno, bool)

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

func (SyscallRestartErrno) Error

func (e SyscallRestartErrno) Error() string

Error implements error.Error.

Jump to

Keyboard shortcuts

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