Blame src/internal/ntux_strerr_impl.c

da20d8
/***********************************************************/
da20d8
/*  ntux: native translation und extension                 */
14ffae
/*  Copyright (C) 2016--2021  SysDeer Technologies, LLC    */
da20d8
/*  Released under GPLv2 and GPLv3; see COPYING.NTUX.      */
da20d8
/***********************************************************/
da20d8
da20d8
#include <psxabi/sys_errno.h>
da20d8
da20d8
#include <ntux/ntux.h>
da20d8
#include "ntux_driver_impl.h"
da20d8
#include "ntux_nolibc_impl.h"
da20d8
da20d8
const char * ntux_posix_error_strs[] = {
da20d8
	[0]                      = "EOK",
da20d8
	[EPERM]                  = "EPERM",
da20d8
	[ENOENT]                 = "ENOENT",
da20d8
	[ESRCH]                  = "ESRCH",
da20d8
	[EINTR]                  = "EINTR",
da20d8
	[EIO]                    = "EIO",
da20d8
	[ENXIO]                  = "ENXIO",
da20d8
	[E2BIG]                  = "E2BIG",
da20d8
	[ENOEXEC]                = "ENOEXEC",
da20d8
	[EBADF]                  = "EBADF",
da20d8
	[ECHILD]                 = "ECHILD",
da20d8
	[EAGAIN]                 = "EAGAIN",
da20d8
	[ENOMEM]                 = "ENOMEM",
da20d8
	[EACCES]                 = "EACCES",
da20d8
	[EFAULT]                 = "EFAULT",
da20d8
	[ENOTBLK]                = "ENOTBLK",
da20d8
	[EBUSY]                  = "EBUSY",
da20d8
	[EEXIST]                 = "EEXIST",
da20d8
	[EXDEV]                  = "EXDEV",
da20d8
	[ENODEV]                 = "ENODEV",
da20d8
	[ENOTDIR]                = "ENOTDIR",
da20d8
	[EISDIR]                 = "EISDIR",
da20d8
	[EINVAL]                 = "EINVAL",
da20d8
	[ENFILE]                 = "ENFILE",
da20d8
	[EMFILE]                 = "EMFILE",
da20d8
	[ENOTTY]                 = "ENOTTY",
da20d8
	[ETXTBSY]                = "ETXTBSY",
da20d8
	[EFBIG]                  = "EFBIG",
da20d8
	[ENOSPC]                 = "ENOSPC",
da20d8
	[ESPIPE]                 = "ESPIPE",
da20d8
	[EROFS]                  = "EROFS",
da20d8
	[EMLINK]                 = "EMLINK",
da20d8
	[EPIPE]                  = "EPIPE",
da20d8
	[EDOM]                   = "EDOM",
da20d8
	[ERANGE]                 = "ERANGE",
da20d8
	[EDEADLK]                = "EDEADLK",
da20d8
	[ENAMETOOLONG]           = "ENAMETOOLONG",
da20d8
	[ENOLCK]                 = "ENOLCK",
da20d8
	[ENOSYS]                 = "ENOSYS",
da20d8
	[ENOTEMPTY]              = "ENOTEMPTY",
da20d8
	[ELOOP]                  = "ELOOP",
da20d8
	[ENOMSG]                 = "ENOMSG",
da20d8
	[EIDRM]                  = "EIDRM",
da20d8
	[ECHRNG]                 = "ECHRNG",
da20d8
	[EL2NSYNC]               = "EL2NSYNC",
da20d8
	[EL3HLT]                 = "EL3HLT",
da20d8
	[EL3RST]                 = "EL3RST",
da20d8
	[ELNRNG]                 = "ELNRNG",
da20d8
	[EUNATCH]                = "EUNATCH",
da20d8
	[ENOCSI]                 = "ENOCSI",
da20d8
	[EL2HLT]                 = "EL2HLT",
da20d8
	[EBADE]                  = "EBADE",
da20d8
	[EBADR]                  = "EBADR",
da20d8
	[EXFULL]                 = "EXFULL",
da20d8
	[ENOANO]                 = "ENOANO",
da20d8
	[EBADRQC]                = "EBADRQC",
da20d8
	[EBADSLT]                = "EBADSLT",
da20d8
	[EBFONT]                 = "EBFONT",
da20d8
	[ENOSTR]                 = "ENOSTR",
da20d8
	[ENODATA]                = "ENODATA",
da20d8
	[ETIME]                  = "ETIME",
da20d8
	[ENOSR]                  = "ENOSR",
da20d8
	[ENONET]                 = "ENONET",
da20d8
	[ENOPKG]                 = "ENOPKG",
da20d8
	[EREMOTE]                = "EREMOTE",
da20d8
	[ENOLINK]                = "ENOLINK",
da20d8
	[EADV]                   = "EADV",
da20d8
	[ESRMNT]                 = "ESRMNT",
da20d8
	[ECOMM]                  = "ECOMM",
da20d8
	[EPROTO]                 = "EPROTO",
da20d8
	[EMULTIHOP]              = "EMULTIHOP",
da20d8
	[EDOTDOT]                = "EDOTDOT",
da20d8
	[EBADMSG]                = "EBADMSG",
da20d8
	[EOVERFLOW]              = "EOVERFLOW",
da20d8
	[ENOTUNIQ]               = "ENOTUNIQ",
da20d8
	[EBADFD]                 = "EBADFD",
da20d8
	[EREMCHG]                = "EREMCHG",
da20d8
	[ELIBACC]                = "ELIBACC",
da20d8
	[ELIBBAD]                = "ELIBBAD",
da20d8
	[ELIBSCN]                = "ELIBSCN",
da20d8
	[ELIBMAX]                = "ELIBMAX",
da20d8
	[ELIBEXEC]               = "ELIBEXEC",
da20d8
	[EILSEQ]                 = "EILSEQ",
da20d8
	[ERESTART]               = "ERESTART",
da20d8
	[ESTRPIPE]               = "ESTRPIPE",
da20d8
	[EUSERS]                 = "EUSERS",
da20d8
	[ENOTSOCK]               = "ENOTSOCK",
da20d8
	[EDESTADDRREQ]           = "EDESTADDRREQ",
da20d8
	[EMSGSIZE]               = "EMSGSIZE",
da20d8
	[EPROTOTYPE]             = "EPROTOTYPE",
da20d8
	[ENOPROTOOPT]            = "ENOPROTOOPT",
da20d8
	[EPROTONOSUPPORT]        = "EPROTONOSUPPORT",
da20d8
	[ESOCKTNOSUPPORT]        = "ESOCKTNOSUPPORT",
da20d8
	[EOPNOTSUPP]             = "EOPNOTSUPP",
da20d8
	[EPFNOSUPPORT]           = "EPFNOSUPPORT",
da20d8
	[EAFNOSUPPORT]           = "EAFNOSUPPORT",
da20d8
	[EADDRINUSE]             = "EADDRINUSE",
da20d8
	[EADDRNOTAVAIL]          = "EADDRNOTAVAIL",
da20d8
	[ENETDOWN]               = "ENETDOWN",
da20d8
	[ENETUNREACH]            = "ENETUNREACH",
da20d8
	[ENETRESET]              = "ENETRESET",
da20d8
	[ECONNABORTED]           = "ECONNABORTED",
da20d8
	[ECONNRESET]             = "ECONNRESET",
da20d8
	[ENOBUFS]                = "ENOBUFS",
da20d8
	[EISCONN]                = "EISCONN",
da20d8
	[ENOTCONN]               = "ENOTCONN",
da20d8
	[ESHUTDOWN]              = "ESHUTDOWN",
da20d8
	[ETOOMANYREFS]           = "ETOOMANYREFS",
da20d8
	[ETIMEDOUT]              = "ETIMEDOUT",
da20d8
	[ECONNREFUSED]           = "ECONNREFUSED",
da20d8
	[EHOSTDOWN]              = "EHOSTDOWN",
da20d8
	[EHOSTUNREACH]           = "EHOSTUNREACH",
da20d8
	[EALREADY]               = "EALREADY",
da20d8
	[EINPROGRESS]            = "EINPROGRESS",
da20d8
	[ESTALE]                 = "ESTALE",
da20d8
	[EUCLEAN]                = "EUCLEAN",
da20d8
	[ENOTNAM]                = "ENOTNAM",
da20d8
	[ENAVAIL]                = "ENAVAIL",
da20d8
	[EISNAM]                 = "EISNAM",
da20d8
	[EREMOTEIO]              = "EREMOTEIO",
da20d8
	[EDQUOT]                 = "EDQUOT",
da20d8
	[ENOMEDIUM]              = "ENOMEDIUM",
da20d8
	[EMEDIUMTYPE]            = "EMEDIUMTYPE",
da20d8
	[ECANCELED]              = "ECANCELED",
da20d8
	[ENOKEY]                 = "ENOKEY",
da20d8
	[EKEYEXPIRED]            = "EKEYEXPIRED",
da20d8
	[EKEYREVOKED]            = "EKEYREVOKED",
da20d8
	[EKEYREJECTED]           = "EKEYREJECTED",
da20d8
	[EOWNERDEAD]             = "EOWNERDEAD",
da20d8
	[ENOTRECOVERABLE]        = "ENOTRECOVERABLE",
da20d8
	[ERFKILL]                = "ERFKILL",
da20d8
	[EHWPOISON]              = "EHWPOISON",
da20d8
	[EERRORS]                = 0};
da20d8
da20d8
const char * ntux_strerror(
da20d8
	const struct ntux_driver_ctx *	dctx,
da20d8
	int				errno)
da20d8
{
da20d8
	struct ntux_driver_ctx_impl *	ictx;
da20d8
da20d8
	if ((errno >= 0) && (errno < EERRORS))
da20d8
		return ntux_posix_error_strs[errno];
da20d8
da20d8
	ictx = ntux_get_driver_ictx(dctx);
da20d8
da20d8
	ntux_sprintf(
da20d8
		ictx->errsbuf,
da20d8
		"Unknown error %d",
da20d8
		errno);
da20d8
da20d8
	return ictx->errsbuf;
da20d8
}