xref: /relibc/src/header/errno/mod.rs (revision be35961d82cd98f2a2e61c4f1869271b9f4af571)
1 //! errno implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/errno.h.html
2 
3 use crate::platform::{self, types::*};
4 
5 //TODO: Consider removing, provided for compatibility with newlib
6 #[no_mangle]
7 pub unsafe extern "C" fn __errno() -> *mut c_int {
8     __errno_location()
9 }
10 
11 #[no_mangle]
12 pub unsafe extern "C" fn __errno_location() -> *mut c_int {
13     &mut platform::errno
14 }
15 
16 #[no_mangle]
17 pub unsafe extern "C" fn __program_invocation_name() -> *mut *mut c_char {
18     &mut platform::program_invocation_name
19 }
20 
21 #[no_mangle]
22 pub unsafe extern "C" fn __program_invocation_short_name() -> *mut *mut c_char {
23     &mut platform::program_invocation_short_name
24 }
25 
26 pub const EPERM: c_int = 1; /* Operation not permitted */
27 pub const ENOENT: c_int = 2; /* No such file or directory */
28 pub const ESRCH: c_int = 3; /* No such process */
29 pub const EINTR: c_int = 4; /* Interrupted system call */
30 pub const EIO: c_int = 5; /* I/O error */
31 pub const ENXIO: c_int = 6; /* No such device or address */
32 pub const E2BIG: c_int = 7; /* Argument list too long */
33 pub const ENOEXEC: c_int = 8; /* Exec format error */
34 pub const EBADF: c_int = 9; /* Bad file number */
35 pub const ECHILD: c_int = 10; /* No child processes */
36 pub const EAGAIN: c_int = 11; /* Try again */
37 pub const ENOMEM: c_int = 12; /* Out of memory */
38 pub const EACCES: c_int = 13; /* Permission denied */
39 pub const EFAULT: c_int = 14; /* Bad address */
40 pub const ENOTBLK: c_int = 15; /* Block device required */
41 pub const EBUSY: c_int = 16; /* Device or resource busy */
42 pub const EEXIST: c_int = 17; /* File exists */
43 pub const EXDEV: c_int = 18; /* Cross-device link */
44 pub const ENODEV: c_int = 19; /* No such device */
45 pub const ENOTDIR: c_int = 20; /* Not a directory */
46 pub const EISDIR: c_int = 21; /* Is a directory */
47 pub const EINVAL: c_int = 22; /* Invalid argument */
48 pub const ENFILE: c_int = 23; /* File table overflow */
49 pub const EMFILE: c_int = 24; /* Too many open files */
50 pub const ENOTTY: c_int = 25; /* Not a typewriter */
51 pub const ETXTBSY: c_int = 26; /* Text file busy */
52 pub const EFBIG: c_int = 27; /* File too large */
53 pub const ENOSPC: c_int = 28; /* No space left on device */
54 pub const ESPIPE: c_int = 29; /* Illegal seek */
55 pub const EROFS: c_int = 30; /* Read-only file system */
56 pub const EMLINK: c_int = 31; /* Too many links */
57 pub const EPIPE: c_int = 32; /* Broken pipe */
58 pub const EDOM: c_int = 33; /* Math argument out of domain of func */
59 pub const ERANGE: c_int = 34; /* Math result not representable */
60 pub const EDEADLK: c_int = 35; /* Resource deadlock would occur */
61 pub const ENAMETOOLONG: c_int = 36; /* File name too long */
62 pub const ENOLCK: c_int = 37; /* No record locks available */
63 pub const ENOSYS: c_int = 38; /* Function not implemented */
64 pub const ENOTEMPTY: c_int = 39; /* Directory not empty */
65 pub const ELOOP: c_int = 40; /* Too many symbolic links encountered */
66 pub const EWOULDBLOCK: c_int = 41; /* Operation would block */
67 pub const ENOMSG: c_int = 42; /* No message of desired type */
68 pub const EIDRM: c_int = 43; /* Identifier removed */
69 pub const ECHRNG: c_int = 44; /* Channel number out of range */
70 pub const EL2NSYNC: c_int = 45; /* Level 2 not synchronized */
71 pub const EL3HLT: c_int = 46; /* Level 3 halted */
72 pub const EL3RST: c_int = 47; /* Level 3 reset */
73 pub const ELNRNG: c_int = 48; /* Link number out of range */
74 pub const EUNATCH: c_int = 49; /* Protocol driver not attached */
75 pub const ENOCSI: c_int = 50; /* No CSI structure available */
76 pub const EL2HLT: c_int = 51; /* Level 2 halted */
77 pub const EBADE: c_int = 52; /* Invalid exchange */
78 pub const EBADR: c_int = 53; /* Invalid request descriptor */
79 pub const EXFULL: c_int = 54; /* Exchange full */
80 pub const ENOANO: c_int = 55; /* No anode */
81 pub const EBADRQC: c_int = 56; /* Invalid request code */
82 pub const EBADSLT: c_int = 57; /* Invalid slot */
83 pub const EDEADLOCK: c_int = 58; /* Resource deadlock would occur */
84 pub const EBFONT: c_int = 59; /* Bad font file format */
85 pub const ENOSTR: c_int = 60; /* Device not a stream */
86 pub const ENODATA: c_int = 61; /* No data available */
87 pub const ETIME: c_int = 62; /* Timer expired */
88 pub const ENOSR: c_int = 63; /* Out of streams resources */
89 pub const ENONET: c_int = 64; /* Machine is not on the network */
90 pub const ENOPKG: c_int = 65; /* Package not installed */
91 pub const EREMOTE: c_int = 66; /* Object is remote */
92 pub const ENOLINK: c_int = 67; /* Link has been severed */
93 pub const EADV: c_int = 68; /* Advertise error */
94 pub const ESRMNT: c_int = 69; /* Srmount error */
95 pub const ECOMM: c_int = 70; /* Communication error on send */
96 pub const EPROTO: c_int = 71; /* Protocol error */
97 pub const EMULTIHOP: c_int = 72; /* Multihop attempted */
98 pub const EDOTDOT: c_int = 73; /* RFS specific error */
99 pub const EBADMSG: c_int = 74; /* Not a data message */
100 pub const EOVERFLOW: c_int = 75; /* Value too large for defined data type */
101 pub const ENOTUNIQ: c_int = 76; /* Name not unique on network */
102 pub const EBADFD: c_int = 77; /* File descriptor in bad state */
103 pub const EREMCHG: c_int = 78; /* Remote address changed */
104 pub const ELIBACC: c_int = 79; /* Can not access a needed shared library */
105 pub const ELIBBAD: c_int = 80; /* Accessing a corrupted shared library */
106 pub const ELIBSCN: c_int = 81; /* .lib section in a.out corrupted */
107 pub const ELIBMAX: c_int = 82; /* Attempting to link in too many shared libraries */
108 pub const ELIBEXEC: c_int = 83; /* Cannot exec a shared library directly */
109 pub const EILSEQ: c_int = 84; /* Illegal byte sequence */
110 pub const ERESTART: c_int = 85; /* Interrupted system call should be restarted */
111 pub const ESTRPIPE: c_int = 86; /* Streams pipe error */
112 pub const EUSERS: c_int = 87; /* Too many users */
113 pub const ENOTSOCK: c_int = 88; /* Socket operation on non-socket */
114 pub const EDESTADDRREQ: c_int = 89; /* Destination address required */
115 pub const EMSGSIZE: c_int = 90; /* Message too long */
116 pub const EPROTOTYPE: c_int = 91; /* Protocol wrong type for socket */
117 pub const ENOPROTOOPT: c_int = 92; /* Protocol not available */
118 pub const EPROTONOSUPPORT: c_int = 93; /* Protocol not supported */
119 pub const ESOCKTNOSUPPORT: c_int = 94; /* Socket type not supported */
120 pub const EOPNOTSUPP: c_int = 95; /* Operation not supported on transport endpoint */
121 pub const EPFNOSUPPORT: c_int = 96; /* Protocol family not supported */
122 pub const EAFNOSUPPORT: c_int = 97; /* Address family not supported by protocol */
123 pub const EADDRINUSE: c_int = 98; /* Address already in use */
124 pub const EADDRNOTAVAIL: c_int = 99; /* Cannot assign requested address */
125 pub const ENETDOWN: c_int = 100; /* Network is down */
126 pub const ENETUNREACH: c_int = 101; /* Network is unreachable */
127 pub const ENETRESET: c_int = 102; /* Network dropped connection because of reset */
128 pub const ECONNABORTED: c_int = 103; /* Software caused connection abort */
129 pub const ECONNRESET: c_int = 104; /* Connection reset by peer */
130 pub const ENOBUFS: c_int = 105; /* No buffer space available */
131 pub const EISCONN: c_int = 106; /* Transport endpoint is already connected */
132 pub const ENOTCONN: c_int = 107; /* Transport endpoint is not connected */
133 pub const ESHUTDOWN: c_int = 108; /* Cannot send after transport endpoint shutdown */
134 pub const ETOOMANYREFS: c_int = 109; /* Too many references: cannot splice */
135 pub const ETIMEDOUT: c_int = 110; /* Connection timed out */
136 pub const ECONNREFUSED: c_int = 111; /* Connection refused */
137 pub const EHOSTDOWN: c_int = 112; /* Host is down */
138 pub const EHOSTUNREACH: c_int = 113; /* No route to host */
139 pub const EALREADY: c_int = 114; /* Operation already in progress */
140 pub const EINPROGRESS: c_int = 115; /* Operation now in progress */
141 pub const ESTALE: c_int = 116; /* Stale NFS file handle */
142 pub const EUCLEAN: c_int = 117; /* Structure needs cleaning */
143 pub const ENOTNAM: c_int = 118; /* Not a XENIX named type file */
144 pub const ENAVAIL: c_int = 119; /* No XENIX semaphores available */
145 pub const EISNAM: c_int = 120; /* Is a named type file */
146 pub const EREMOTEIO: c_int = 121; /* Remote I/O error */
147 pub const EDQUOT: c_int = 122; /* Quota exceeded */
148 pub const ENOMEDIUM: c_int = 123; /* No medium found */
149 pub const EMEDIUMTYPE: c_int = 124; /* Wrong medium type */
150 pub const ECANCELED: c_int = 125; /* Operation Canceled */
151 pub const ENOKEY: c_int = 126; /* Required key not available */
152 pub const EKEYEXPIRED: c_int = 127; /* Key has expired */
153 pub const EKEYREVOKED: c_int = 128; /* Key has been revoked */
154 pub const EKEYREJECTED: c_int = 129; /* Key was rejected by service */
155 pub const EOWNERDEAD: c_int = 130; /* Owner died */
156 pub const ENOTRECOVERABLE: c_int = 131; /* State not recoverable */
157 
158 pub static STR_ERROR: [&'static str; 132] = [
159     "Success",
160     "Operation not permitted",
161     "No such file or directory",
162     "No such process",
163     "Interrupted system call",
164     "I/O error",
165     "No such device or address",
166     "Argument list too long",
167     "Exec format error",
168     "Bad file number",
169     "No child processes",
170     "Try again",
171     "Out of memory",
172     "Permission denied",
173     "Bad address",
174     "Block device required",
175     "Device or resource busy",
176     "File exists",
177     "Cross-device link",
178     "No such device",
179     "Not a directory",
180     "Is a directory",
181     "Invalid argument",
182     "File table overflow",
183     "Too many open files",
184     "Not a typewriter",
185     "Text file busy",
186     "File too large",
187     "No space left on device",
188     "Illegal seek",
189     "Read-only file system",
190     "Too many links",
191     "Broken pipe",
192     "Math argument out of domain of func",
193     "Math result not representable",
194     "Resource deadlock would occur",
195     "File name too long",
196     "No record locks available",
197     "Function not implemented",
198     "Directory not empty",
199     "Too many symbolic links encountered",
200     "Operation would block",
201     "No message of desired type",
202     "Identifier removed",
203     "Channel number out of range",
204     "Level 2 not synchronized",
205     "Level 3 halted",
206     "Level 3 reset",
207     "Link number out of range",
208     "Protocol driver not attached",
209     "No CSI structure available",
210     "Level 2 halted",
211     "Invalid exchange",
212     "Invalid request descriptor",
213     "Exchange full",
214     "No anode",
215     "Invalid request code",
216     "Invalid slot",
217     "Resource deadlock would occur",
218     "Bad font file format",
219     "Device not a stream",
220     "No data available",
221     "Timer expired",
222     "Out of streams resources",
223     "Machine is not on the network",
224     "Package not installed",
225     "Object is remote",
226     "Link has been severed",
227     "Advertise error",
228     "Srmount error",
229     "Communication error on send",
230     "Protocol error",
231     "Multihop attempted",
232     "RFS specific error",
233     "Not a data message",
234     "Value too large for defined data type",
235     "Name not unique on network",
236     "File descriptor in bad state",
237     "Remote address changed",
238     "Can not access a needed shared library",
239     "Accessing a corrupted shared library",
240     ".lib section in a.out corrupted",
241     "Attempting to link in too many shared libraries",
242     "Cannot exec a shared library directly",
243     "Illegal byte sequence",
244     "Interrupted system call should be restarted",
245     "Streams pipe error",
246     "Too many users",
247     "Socket operation on non-socket",
248     "Destination address required",
249     "Message too long",
250     "Protocol wrong type for socket",
251     "Protocol not available",
252     "Protocol not supported",
253     "Socket type not supported",
254     "Operation not supported on transport endpoint",
255     "Protocol family not supported",
256     "Address family not supported by protocol",
257     "Address already in use",
258     "Cannot assign requested address",
259     "Network is down",
260     "Network is unreachable",
261     "Network dropped connection because of reset",
262     "Software caused connection abort",
263     "Connection reset by peer",
264     "No buffer space available",
265     "Transport endpoint is already connected",
266     "Transport endpoint is not connected",
267     "Cannot send after transport endpoint shutdown",
268     "Too many references: cannot splice",
269     "Connection timed out",
270     "Connection refused",
271     "Host is down",
272     "No route to host",
273     "Operation already in progress",
274     "Operation now in progress",
275     "Stale NFS file handle",
276     "Structure needs cleaning",
277     "Not a XENIX named type file",
278     "No XENIX semaphores available",
279     "Is a named type file",
280     "Remote I/O error",
281     "Quota exceeded",
282     "No medium found",
283     "Wrong medium type",
284     "Operation Canceled",
285     "Required key not available",
286     "Key has expired",
287     "Key has been revoked",
288     "Key was rejected by service",
289     "Owner died",
290     "State not recoverable",
291 ];
292