Blob Blame History Raw
/***********************************************************/
/*  ntux: native translation und extension                 */
/*  Copyright (C) 2016--2021  SysDeer Technologies, LLC    */
/*  Released under GPLv2 and GPLv3; see COPYING.NTUX.      */
/***********************************************************/

#include <psxabi/sys_errno.h>

#include <ntux/ntux.h>
#include "ntux_driver_impl.h"
#include "ntux_nolibc_impl.h"

const char * ntux_posix_error_strs[] = {
	[0]                      = "EOK",
	[EPERM]                  = "EPERM",
	[ENOENT]                 = "ENOENT",
	[ESRCH]                  = "ESRCH",
	[EINTR]                  = "EINTR",
	[EIO]                    = "EIO",
	[ENXIO]                  = "ENXIO",
	[E2BIG]                  = "E2BIG",
	[ENOEXEC]                = "ENOEXEC",
	[EBADF]                  = "EBADF",
	[ECHILD]                 = "ECHILD",
	[EAGAIN]                 = "EAGAIN",
	[ENOMEM]                 = "ENOMEM",
	[EACCES]                 = "EACCES",
	[EFAULT]                 = "EFAULT",
	[ENOTBLK]                = "ENOTBLK",
	[EBUSY]                  = "EBUSY",
	[EEXIST]                 = "EEXIST",
	[EXDEV]                  = "EXDEV",
	[ENODEV]                 = "ENODEV",
	[ENOTDIR]                = "ENOTDIR",
	[EISDIR]                 = "EISDIR",
	[EINVAL]                 = "EINVAL",
	[ENFILE]                 = "ENFILE",
	[EMFILE]                 = "EMFILE",
	[ENOTTY]                 = "ENOTTY",
	[ETXTBSY]                = "ETXTBSY",
	[EFBIG]                  = "EFBIG",
	[ENOSPC]                 = "ENOSPC",
	[ESPIPE]                 = "ESPIPE",
	[EROFS]                  = "EROFS",
	[EMLINK]                 = "EMLINK",
	[EPIPE]                  = "EPIPE",
	[EDOM]                   = "EDOM",
	[ERANGE]                 = "ERANGE",
	[EDEADLK]                = "EDEADLK",
	[ENAMETOOLONG]           = "ENAMETOOLONG",
	[ENOLCK]                 = "ENOLCK",
	[ENOSYS]                 = "ENOSYS",
	[ENOTEMPTY]              = "ENOTEMPTY",
	[ELOOP]                  = "ELOOP",
	[ENOMSG]                 = "ENOMSG",
	[EIDRM]                  = "EIDRM",
	[ECHRNG]                 = "ECHRNG",
	[EL2NSYNC]               = "EL2NSYNC",
	[EL3HLT]                 = "EL3HLT",
	[EL3RST]                 = "EL3RST",
	[ELNRNG]                 = "ELNRNG",
	[EUNATCH]                = "EUNATCH",
	[ENOCSI]                 = "ENOCSI",
	[EL2HLT]                 = "EL2HLT",
	[EBADE]                  = "EBADE",
	[EBADR]                  = "EBADR",
	[EXFULL]                 = "EXFULL",
	[ENOANO]                 = "ENOANO",
	[EBADRQC]                = "EBADRQC",
	[EBADSLT]                = "EBADSLT",
	[EBFONT]                 = "EBFONT",
	[ENOSTR]                 = "ENOSTR",
	[ENODATA]                = "ENODATA",
	[ETIME]                  = "ETIME",
	[ENOSR]                  = "ENOSR",
	[ENONET]                 = "ENONET",
	[ENOPKG]                 = "ENOPKG",
	[EREMOTE]                = "EREMOTE",
	[ENOLINK]                = "ENOLINK",
	[EADV]                   = "EADV",
	[ESRMNT]                 = "ESRMNT",
	[ECOMM]                  = "ECOMM",
	[EPROTO]                 = "EPROTO",
	[EMULTIHOP]              = "EMULTIHOP",
	[EDOTDOT]                = "EDOTDOT",
	[EBADMSG]                = "EBADMSG",
	[EOVERFLOW]              = "EOVERFLOW",
	[ENOTUNIQ]               = "ENOTUNIQ",
	[EBADFD]                 = "EBADFD",
	[EREMCHG]                = "EREMCHG",
	[ELIBACC]                = "ELIBACC",
	[ELIBBAD]                = "ELIBBAD",
	[ELIBSCN]                = "ELIBSCN",
	[ELIBMAX]                = "ELIBMAX",
	[ELIBEXEC]               = "ELIBEXEC",
	[EILSEQ]                 = "EILSEQ",
	[ERESTART]               = "ERESTART",
	[ESTRPIPE]               = "ESTRPIPE",
	[EUSERS]                 = "EUSERS",
	[ENOTSOCK]               = "ENOTSOCK",
	[EDESTADDRREQ]           = "EDESTADDRREQ",
	[EMSGSIZE]               = "EMSGSIZE",
	[EPROTOTYPE]             = "EPROTOTYPE",
	[ENOPROTOOPT]            = "ENOPROTOOPT",
	[EPROTONOSUPPORT]        = "EPROTONOSUPPORT",
	[ESOCKTNOSUPPORT]        = "ESOCKTNOSUPPORT",
	[EOPNOTSUPP]             = "EOPNOTSUPP",
	[EPFNOSUPPORT]           = "EPFNOSUPPORT",
	[EAFNOSUPPORT]           = "EAFNOSUPPORT",
	[EADDRINUSE]             = "EADDRINUSE",
	[EADDRNOTAVAIL]          = "EADDRNOTAVAIL",
	[ENETDOWN]               = "ENETDOWN",
	[ENETUNREACH]            = "ENETUNREACH",
	[ENETRESET]              = "ENETRESET",
	[ECONNABORTED]           = "ECONNABORTED",
	[ECONNRESET]             = "ECONNRESET",
	[ENOBUFS]                = "ENOBUFS",
	[EISCONN]                = "EISCONN",
	[ENOTCONN]               = "ENOTCONN",
	[ESHUTDOWN]              = "ESHUTDOWN",
	[ETOOMANYREFS]           = "ETOOMANYREFS",
	[ETIMEDOUT]              = "ETIMEDOUT",
	[ECONNREFUSED]           = "ECONNREFUSED",
	[EHOSTDOWN]              = "EHOSTDOWN",
	[EHOSTUNREACH]           = "EHOSTUNREACH",
	[EALREADY]               = "EALREADY",
	[EINPROGRESS]            = "EINPROGRESS",
	[ESTALE]                 = "ESTALE",
	[EUCLEAN]                = "EUCLEAN",
	[ENOTNAM]                = "ENOTNAM",
	[ENAVAIL]                = "ENAVAIL",
	[EISNAM]                 = "EISNAM",
	[EREMOTEIO]              = "EREMOTEIO",
	[EDQUOT]                 = "EDQUOT",
	[ENOMEDIUM]              = "ENOMEDIUM",
	[EMEDIUMTYPE]            = "EMEDIUMTYPE",
	[ECANCELED]              = "ECANCELED",
	[ENOKEY]                 = "ENOKEY",
	[EKEYEXPIRED]            = "EKEYEXPIRED",
	[EKEYREVOKED]            = "EKEYREVOKED",
	[EKEYREJECTED]           = "EKEYREJECTED",
	[EOWNERDEAD]             = "EOWNERDEAD",
	[ENOTRECOVERABLE]        = "ENOTRECOVERABLE",
	[ERFKILL]                = "ERFKILL",
	[EHWPOISON]              = "EHWPOISON",
	[EERRORS]                = 0};

const char * ntux_strerror(
	const struct ntux_driver_ctx *	dctx,
	int				errno)
{
	struct ntux_driver_ctx_impl *	ictx;

	if ((errno >= 0) && (errno < EERRORS))
		return ntux_posix_error_strs[errno];

	ictx = ntux_get_driver_ictx(dctx);

	ntux_sprintf(
		ictx->errsbuf,
		"Unknown error %d",
		errno);

	return ictx->errsbuf;
}