summaryrefslogtreecommitdiffhomepage
path: root/src/internal/ntux_strerr_impl.c
blob: 6cb4853ee10c198dd17a22781583eb505ae11cd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/***********************************************************/
/*  ntux: native translation und extension                 */
/*  Copyright (C) 2016--2018  Z. Gilboa                    */
/*  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;
}