1 use libc::c_int;
2 use std::{fmt, io, error};
3 use {Error, Result};
4
5 pub use self::consts::*;
6 pub use self::consts::Errno::*;
7
8 #[cfg(any(target_os = "macos",
9 target_os = "ios",
10 target_os = "freebsd"))]
errno_location() -> *mut c_int11 unsafe fn errno_location() -> *mut c_int {
12 extern { fn __error() -> *mut c_int; }
13 __error()
14 }
15
16 #[cfg(target_os = "bitrig")]
errno_location() -> *mut c_int17 fn errno_location() -> *mut c_int {
18 extern {
19 fn __errno() -> *mut c_int;
20 }
21 unsafe {
22 __errno()
23 }
24 }
25
26 #[cfg(target_os = "dragonfly")]
errno_location() -> *mut c_int27 unsafe fn errno_location() -> *mut c_int {
28 extern { fn __dfly_error() -> *mut c_int; }
29 __dfly_error()
30 }
31
32 #[cfg(any(target_os = "openbsd", target_os = "netbsd"))]
errno_location() -> *mut c_int33 unsafe fn errno_location() -> *mut c_int {
34 extern { fn __errno() -> *mut c_int; }
35 __errno()
36 }
37
38 #[cfg(target_os = "linux")]
errno_location() -> *mut c_int39 unsafe fn errno_location() -> *mut c_int {
40 extern { fn __errno_location() -> *mut c_int; }
41 __errno_location()
42 }
43
44 #[cfg(target_os = "android")]
errno_location() -> *mut c_int45 unsafe fn errno_location() -> *mut c_int {
46 extern { fn __errno() -> *mut c_int; }
47 __errno()
48 }
49
50 /// Sets the platform-specific errno to no-error
clear() -> ()51 unsafe fn clear() -> () {
52 *errno_location() = 0;
53 }
54
55 /// Returns the platform-specific value of errno
errno() -> i3256 pub fn errno() -> i32 {
57 unsafe {
58 (*errno_location()) as i32
59 }
60 }
61
62 impl Errno {
last() -> Self63 pub fn last() -> Self {
64 last()
65 }
66
desc(self) -> &'static str67 pub fn desc(self) -> &'static str {
68 desc(self)
69 }
70
from_i32(err: i32) -> Errno71 pub fn from_i32(err: i32) -> Errno {
72 from_i32(err)
73 }
74
clear() -> ()75 pub unsafe fn clear() -> () {
76 clear()
77 }
78
79 /// Returns `Ok(value)` if it does not contain the sentinel value. This
80 /// should not be used when `-1` is not the errno sentinel value.
result<S: ErrnoSentinel + PartialEq<S>>(value: S) -> Result<S>81 pub fn result<S: ErrnoSentinel + PartialEq<S>>(value: S) -> Result<S> {
82 if value == S::sentinel() {
83 Err(Error::Sys(Self::last()))
84 } else {
85 Ok(value)
86 }
87 }
88 }
89
90 /// The sentinel value indicates that a function failed and more detailed
91 /// information about the error can be found in `errno`
92 pub trait ErrnoSentinel: Sized {
sentinel() -> Self93 fn sentinel() -> Self;
94 }
95
96 impl ErrnoSentinel for isize {
sentinel() -> Self97 fn sentinel() -> Self { -1 }
98 }
99
100 impl ErrnoSentinel for i32 {
sentinel() -> Self101 fn sentinel() -> Self { -1 }
102 }
103
104 impl ErrnoSentinel for i64 {
sentinel() -> Self105 fn sentinel() -> Self { -1 }
106 }
107
108 impl error::Error for Errno {
description(&self) -> &str109 fn description(&self) -> &str {
110 self.desc()
111 }
112 }
113
114 impl fmt::Display for Errno {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result115 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
116 write!(f, "{:?}: {}", self, self.desc())
117 }
118 }
119
120 impl From<Errno> for io::Error {
from(err: Errno) -> Self121 fn from(err: Errno) -> Self {
122 io::Error::from_raw_os_error(err as i32)
123 }
124 }
125
last() -> Errno126 fn last() -> Errno {
127 Errno::from_i32(errno())
128 }
129
desc(errno: Errno) -> &'static str130 fn desc(errno: Errno) -> &'static str {
131 match errno {
132 UnknownErrno => "Unknown errno",
133 EPERM => "Operation not permitted",
134 ENOENT => "No such file or directory",
135 ESRCH => "No such process",
136 EINTR => "Interrupted system call",
137 EIO => "I/O error",
138 ENXIO => "No such device or address",
139 E2BIG => "Argument list too long",
140 ENOEXEC => "Exec format error",
141 EBADF => "Bad file number",
142 ECHILD => "No child processes",
143 EAGAIN => "Try again",
144 ENOMEM => "Out of memory",
145 EACCES => "Permission denied",
146 EFAULT => "Bad address",
147 ENOTBLK => "Block device required",
148 EBUSY => "Device or resource busy",
149 EEXIST => "File exists",
150 EXDEV => "Cross-device link",
151 ENODEV => "No such device",
152 ENOTDIR => "Not a directory",
153 EISDIR => "Is a directory",
154 EINVAL => "Invalid argument",
155 ENFILE => "File table overflow",
156 EMFILE => "Too many open files",
157 ENOTTY => "Not a typewriter",
158 ETXTBSY => "Text file busy",
159 EFBIG => "File too large",
160 ENOSPC => "No space left on device",
161 ESPIPE => "Illegal seek",
162 EROFS => "Read-only file system",
163 EMLINK => "Too many links",
164 EPIPE => "Broken pipe",
165 EDOM => "Math argument out of domain of func",
166 ERANGE => "Math result not representable",
167 EDEADLK => "Resource deadlock would occur",
168 ENAMETOOLONG => "File name too long",
169 ENOLCK => "No record locks available",
170 ENOSYS => "Function not implemented",
171 ENOTEMPTY => "Directory not empty",
172 ELOOP => "Too many symbolic links encountered",
173 ENOMSG => "No message of desired type",
174 EIDRM => "Identifier removed",
175 EINPROGRESS => "Operation now in progress",
176 EALREADY => "Operation already in progress",
177 ENOTSOCK => "Socket operation on non-socket",
178 EDESTADDRREQ => "Destination address required",
179 EMSGSIZE => "Message too long",
180 EPROTOTYPE => "Protocol wrong type for socket",
181 ENOPROTOOPT => "Protocol not available",
182 EPROTONOSUPPORT => "Protocol not supported",
183 ESOCKTNOSUPPORT => "Socket type not supported",
184 EPFNOSUPPORT => "Protocol family not supported",
185 EAFNOSUPPORT => "Address family not supported by protocol",
186 EADDRINUSE => "Address already in use",
187 EADDRNOTAVAIL => "Cannot assign requested address",
188 ENETDOWN => "Network is down",
189 ENETUNREACH => "Network is unreachable",
190 ENETRESET => "Network dropped connection because of reset",
191 ECONNABORTED => "Software caused connection abort",
192 ECONNRESET => "Connection reset by peer",
193 ENOBUFS => "No buffer space available",
194 EISCONN => "Transport endpoint is already connected",
195 ENOTCONN => "Transport endpoint is not connected",
196 ESHUTDOWN => "Cannot send after transport endpoint shutdown",
197 ETOOMANYREFS => "Too many references: cannot splice",
198 ETIMEDOUT => "Connection timed out",
199 ECONNREFUSED => "Connection refused",
200 EHOSTDOWN => "Host is down",
201 EHOSTUNREACH => "No route to host",
202
203 #[cfg(any(target_os = "linux", target_os = "android"))]
204 ECHRNG => "Channel number out of range",
205
206 #[cfg(any(target_os = "linux", target_os = "android"))]
207 EL2NSYNC => "Level 2 not synchronized",
208
209 #[cfg(any(target_os = "linux", target_os = "android"))]
210 EL3HLT => "Level 3 halted",
211
212 #[cfg(any(target_os = "linux", target_os = "android"))]
213 EL3RST => "Level 3 reset",
214
215 #[cfg(any(target_os = "linux", target_os = "android"))]
216 ELNRNG => "Link number out of range",
217
218 #[cfg(any(target_os = "linux", target_os = "android"))]
219 EUNATCH => "Protocol driver not attached",
220
221 #[cfg(any(target_os = "linux", target_os = "android"))]
222 ENOCSI => "No CSI structure available",
223
224 #[cfg(any(target_os = "linux", target_os = "android"))]
225 EL2HLT => "Level 2 halted",
226
227 #[cfg(any(target_os = "linux", target_os = "android"))]
228 EBADE => "Invalid exchange",
229
230 #[cfg(any(target_os = "linux", target_os = "android"))]
231 EBADR => "Invalid request descriptor",
232
233 #[cfg(any(target_os = "linux", target_os = "android"))]
234 EXFULL => "Exchange full",
235
236 #[cfg(any(target_os = "linux", target_os = "android"))]
237 ENOANO => "No anode",
238
239 #[cfg(any(target_os = "linux", target_os = "android"))]
240 EBADRQC => "Invalid request code",
241
242 #[cfg(any(target_os = "linux", target_os = "android"))]
243 EBADSLT => "Invalid slot",
244
245 #[cfg(any(target_os = "linux", target_os = "android"))]
246 EBFONT => "Bad font file format",
247
248 #[cfg(any(target_os = "linux", target_os = "android"))]
249 ENOSTR => "Device not a stream",
250
251 #[cfg(any(target_os = "linux", target_os = "android"))]
252 ENODATA => "No data available",
253
254 #[cfg(any(target_os = "linux", target_os = "android"))]
255 ETIME => "Timer expired",
256
257 #[cfg(any(target_os = "linux", target_os = "android"))]
258 ENOSR => "Out of streams resources",
259
260 #[cfg(any(target_os = "linux", target_os = "android"))]
261 ENONET => "Machine is not on the network",
262
263 #[cfg(any(target_os = "linux", target_os = "android"))]
264 ENOPKG => "Package not installed",
265
266 #[cfg(any(target_os = "linux", target_os = "android"))]
267 EREMOTE => "Object is remote",
268
269 #[cfg(any(target_os = "linux", target_os = "android"))]
270 ENOLINK => "Link has been severed",
271
272 #[cfg(any(target_os = "linux", target_os = "android"))]
273 EADV => "Advertise error",
274
275 #[cfg(any(target_os = "linux", target_os = "android"))]
276 ESRMNT => "Srmount error",
277
278 #[cfg(any(target_os = "linux", target_os = "android"))]
279 ECOMM => "Communication error on send",
280
281 #[cfg(any(target_os = "linux", target_os = "android"))]
282 EPROTO => "Protocol error",
283
284 #[cfg(any(target_os = "linux", target_os = "android"))]
285 EMULTIHOP => "Multihop attempted",
286
287 #[cfg(any(target_os = "linux", target_os = "android"))]
288 EDOTDOT => "RFS specific error",
289
290 #[cfg(any(target_os = "linux", target_os = "android"))]
291 EBADMSG => "Not a data message",
292
293 #[cfg(any(target_os = "linux", target_os = "android"))]
294 EOVERFLOW => "Value too large for defined data type",
295
296 #[cfg(any(target_os = "linux", target_os = "android"))]
297 ENOTUNIQ => "Name not unique on network",
298
299 #[cfg(any(target_os = "linux", target_os = "android"))]
300 EBADFD => "File descriptor in bad state",
301
302 #[cfg(any(target_os = "linux", target_os = "android"))]
303 EREMCHG => "Remote address changed",
304
305 #[cfg(any(target_os = "linux", target_os = "android"))]
306 ELIBACC => "Can not acces a needed shared library",
307
308 #[cfg(any(target_os = "linux", target_os = "android"))]
309 ELIBBAD => "Accessing a corrupted shared library",
310
311 #[cfg(any(target_os = "linux", target_os = "android"))]
312 ELIBSCN => ".lib section in a.out corrupted",
313
314 #[cfg(any(target_os = "linux", target_os = "android"))]
315 ELIBMAX => "Attempting to link in too many shared libraries",
316
317 #[cfg(any(target_os = "linux", target_os = "android"))]
318 ELIBEXEC => "Cannot exec a shared library directly",
319
320 #[cfg(any(target_os = "linux", target_os = "android", target_os = "openbsd"))]
321 EILSEQ => "Illegal byte sequence",
322
323 #[cfg(any(target_os = "linux", target_os = "android"))]
324 ERESTART => "Interrupted system call should be restarted",
325
326 #[cfg(any(target_os = "linux", target_os = "android"))]
327 ESTRPIPE => "Streams pipe error",
328
329 #[cfg(any(target_os = "linux", target_os = "android"))]
330 EUSERS => "Too many users",
331
332 #[cfg(any(target_os = "linux", target_os = "android", target_os = "netbsd"))]
333 EOPNOTSUPP => "Operation not supported on transport endpoint",
334
335 #[cfg(any(target_os = "linux", target_os = "android"))]
336 ESTALE => "Stale file handle",
337
338 #[cfg(any(target_os = "linux", target_os = "android"))]
339 EUCLEAN => "Structure needs cleaning",
340
341 #[cfg(any(target_os = "linux", target_os = "android"))]
342 ENOTNAM => "Not a XENIX named type file",
343
344 #[cfg(any(target_os = "linux", target_os = "android"))]
345 ENAVAIL => "No XENIX semaphores available",
346
347 #[cfg(any(target_os = "linux", target_os = "android"))]
348 EISNAM => "Is a named type file",
349
350 #[cfg(any(target_os = "linux", target_os = "android"))]
351 EREMOTEIO => "Remote I/O error",
352
353 #[cfg(any(target_os = "linux", target_os = "android"))]
354 EDQUOT => "Quota exceeded",
355
356 #[cfg(any(target_os = "linux", target_os = "android", target_os = "openbsd", target_os = "dragonfly"))]
357 ENOMEDIUM => "No medium found",
358
359 #[cfg(any(target_os = "linux", target_os = "android", target_os = "openbsd"))]
360 EMEDIUMTYPE => "Wrong medium type",
361
362 #[cfg(any(target_os = "linux", target_os = "android"))]
363 ECANCELED => "Operation canceled",
364
365 #[cfg(any(target_os = "linux", target_os = "android"))]
366 ENOKEY => "Required key not available",
367
368 #[cfg(any(target_os = "linux", target_os = "android"))]
369 EKEYEXPIRED => "Key has expired",
370
371 #[cfg(any(target_os = "linux", target_os = "android"))]
372 EKEYREVOKED => "Key has been revoked",
373
374 #[cfg(any(target_os = "linux", target_os = "android"))]
375 EKEYREJECTED => "Key was rejected by service",
376
377 #[cfg(any(target_os = "linux", target_os = "android"))]
378 EOWNERDEAD => "Owner died",
379
380 #[cfg(any(target_os = "linux", target_os = "android"))]
381 ENOTRECOVERABLE => "State not recoverable",
382
383 #[cfg(all(target_os = "linux", not(target_arch="mips")))]
384 ERFKILL => "Operation not possible due to RF-kill",
385
386 #[cfg(all(target_os = "linux", not(target_arch="mips")))]
387 EHWPOISON => "Memory page has hardware error",
388
389 #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
390 EDOOFUS => "Programming error",
391
392 #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
393 EMULTIHOP => "Multihop attempted",
394
395 #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
396 ENOLINK => "Link has been severed",
397
398 #[cfg(target_os = "freebsd")]
399 ENOTCAPABLE => "Capabilities insufficient",
400
401 #[cfg(target_os = "freebsd")]
402 ECAPMODE => "Not permitted in capability mode",
403
404 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
405 ENEEDAUTH => "Need authenticator",
406
407 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
408 EOVERFLOW => "Value too large to be stored in data type",
409
410 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "netbsd"))]
411 EILSEQ => "Illegal byte sequence",
412
413 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
414 ENOATTR => "Attribute not found",
415
416 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "netbsd"))]
417 EBADMSG => "Bad message",
418
419 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "netbsd"))]
420 EPROTO => "Protocol error",
421
422 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios"))]
423 ENOTRECOVERABLE => "State not recoverable",
424
425 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios"))]
426 EOWNERDEAD => "Previous owner died",
427
428 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
429 ENOTSUP => "Operation not supported",
430
431 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
432 EPROCLIM => "Too many processes",
433
434 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
435 EUSERS => "Too many users",
436
437 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
438 EDQUOT => "Disc quota exceeded",
439
440 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
441 ESTALE => "Stale NFS file handle",
442
443 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
444 EREMOTE => "Too many levels of remote in path",
445
446 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
447 EBADRPC => "RPC struct is bad",
448
449 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
450 ERPCMISMATCH => "RPC version wrong",
451
452 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
453 EPROGUNAVAIL => "RPC prog. not avail",
454
455 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
456 EPROGMISMATCH => "Program version wrong",
457
458 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
459 EPROCUNAVAIL => "Bad procedure for program",
460
461 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
462 EFTYPE => "Inappropriate file type or format",
463
464 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
465 EAUTH => "Authentication error",
466
467 #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
468 ECANCELED => "Operation canceled",
469
470 #[cfg(any(target_os = "macos", target_os = "ios"))]
471 EPWROFF => "Device power is off",
472
473 #[cfg(any(target_os = "macos", target_os = "ios"))]
474 EDEVERR => "Device error, e.g. paper out",
475
476 #[cfg(any(target_os = "macos", target_os = "ios"))]
477 EBADEXEC => "Bad executable",
478
479 #[cfg(any(target_os = "macos", target_os = "ios"))]
480 EBADARCH => "Bad CPU type in executable",
481
482 #[cfg(any(target_os = "macos", target_os = "ios"))]
483 ESHLIBVERS => "Shared library version mismatch",
484
485 #[cfg(any(target_os = "macos", target_os = "ios"))]
486 EBADMACHO => "Malformed Macho file",
487
488 #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))]
489 EMULTIHOP => "Reserved",
490
491 #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))]
492 ENODATA => "No message available on STREAM",
493
494 #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))]
495 ENOLINK => "Reserved",
496
497 #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))]
498 ENOSR => "No STREAM resources",
499
500 #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))]
501 ENOSTR => "Not a STREAM",
502
503 #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))]
504 ETIME => "STREAM ioctl timeout",
505
506 #[cfg(any(target_os = "macos", target_os = "ios"))]
507 EOPNOTSUPP => "Operation not supported on socket",
508
509 #[cfg(any(target_os = "macos", target_os = "ios"))]
510 ENOPOLICY => "No such policy registered",
511
512 #[cfg(any(target_os = "macos", target_os = "ios"))]
513 EQFULL => "Interface output queue is full",
514
515 #[cfg(target_os = "openbsd")]
516 EOPNOTSUPP => "Operation not supported",
517
518 #[cfg(target_os = "openbsd")]
519 EIPSEC => "IPsec processing failure",
520
521 #[cfg(target_os = "dragonfly")]
522 EUNUSED94 | EUNUSED95 | EUNUSED96 | EUNUSED97 | EUNUSED98 => "Unused",
523
524 #[cfg(target_os = "dragonfly")]
525 EASYNC => "Async",
526 }
527 }
528
529 #[cfg(any(target_os = "linux", target_os = "android"))]
530 mod consts {
531 use libc;
532
533 #[derive(Debug, Clone, PartialEq, Copy)]
534 pub enum Errno {
535 UnknownErrno = 0,
536 EPERM = libc::EPERM as isize,
537 ENOENT = libc::ENOENT as isize,
538 ESRCH = libc::ESRCH as isize,
539 EINTR = libc::EINTR as isize,
540 EIO = libc::EIO as isize,
541 ENXIO = libc::ENXIO as isize,
542 E2BIG = libc::E2BIG as isize,
543 ENOEXEC = libc::ENOEXEC as isize,
544 EBADF = libc::EBADF as isize,
545 ECHILD = libc::ECHILD as isize,
546 EAGAIN = libc::EAGAIN as isize,
547 ENOMEM = libc::ENOMEM as isize,
548 EACCES = libc::EACCES as isize,
549 EFAULT = libc::EFAULT as isize,
550 ENOTBLK = libc::ENOTBLK as isize,
551 EBUSY = libc::EBUSY as isize,
552 EEXIST = libc::EEXIST as isize,
553 EXDEV = libc::EXDEV as isize,
554 ENODEV = libc::ENODEV as isize,
555 ENOTDIR = libc::ENOTDIR as isize,
556 EISDIR = libc::EISDIR as isize,
557 EINVAL = libc::EINVAL as isize,
558 ENFILE = libc::ENFILE as isize,
559 EMFILE = libc::EMFILE as isize,
560 ENOTTY = libc::ENOTTY as isize,
561 ETXTBSY = libc::ETXTBSY as isize,
562 EFBIG = libc::EFBIG as isize,
563 ENOSPC = libc::ENOSPC as isize,
564 ESPIPE = libc::ESPIPE as isize,
565 EROFS = libc::EROFS as isize,
566 EMLINK = libc::EMLINK as isize,
567 EPIPE = libc::EPIPE as isize,
568 EDOM = libc::EDOM as isize,
569 ERANGE = libc::ERANGE as isize,
570 EDEADLK = libc::EDEADLK as isize,
571 ENAMETOOLONG = libc::ENAMETOOLONG as isize,
572 ENOLCK = libc::ENOLCK as isize,
573 ENOSYS = libc::ENOSYS as isize,
574 ENOTEMPTY = libc::ENOTEMPTY as isize,
575 ELOOP = libc::ELOOP as isize,
576 ENOMSG = libc::ENOMSG as isize,
577 EIDRM = libc::EIDRM as isize,
578 ECHRNG = libc::ECHRNG as isize,
579 EL2NSYNC = libc::EL2NSYNC as isize,
580 EL3HLT = libc::EL3HLT as isize,
581 EL3RST = libc::EL3RST as isize,
582 ELNRNG = libc::ELNRNG as isize,
583 EUNATCH = libc::EUNATCH as isize,
584 ENOCSI = libc::ENOCSI as isize,
585 EL2HLT = libc::EL2HLT as isize,
586 EBADE = libc::EBADE as isize,
587 EBADR = libc::EBADR as isize,
588 EXFULL = libc::EXFULL as isize,
589 ENOANO = libc::ENOANO as isize,
590 EBADRQC = libc::EBADRQC as isize,
591 EBADSLT = libc::EBADSLT as isize,
592 EBFONT = libc::EBFONT as isize,
593 ENOSTR = libc::ENOSTR as isize,
594 ENODATA = libc::ENODATA as isize,
595 ETIME = libc::ETIME as isize,
596 ENOSR = libc::ENOSR as isize,
597 ENONET = libc::ENONET as isize,
598 ENOPKG = libc::ENOPKG as isize,
599 EREMOTE = libc::EREMOTE as isize,
600 ENOLINK = libc::ENOLINK as isize,
601 EADV = libc::EADV as isize,
602 ESRMNT = libc::ESRMNT as isize,
603 ECOMM = libc::ECOMM as isize,
604 EPROTO = libc::EPROTO as isize,
605 EMULTIHOP = libc::EMULTIHOP as isize,
606 EDOTDOT = libc::EDOTDOT as isize,
607 EBADMSG = libc::EBADMSG as isize,
608 EOVERFLOW = libc::EOVERFLOW as isize,
609 ENOTUNIQ = libc::ENOTUNIQ as isize,
610 EBADFD = libc::EBADFD as isize,
611 EREMCHG = libc::EREMCHG as isize,
612 ELIBACC = libc::ELIBACC as isize,
613 ELIBBAD = libc::ELIBBAD as isize,
614 ELIBSCN = libc::ELIBSCN as isize,
615 ELIBMAX = libc::ELIBMAX as isize,
616 ELIBEXEC = libc::ELIBEXEC as isize,
617 EILSEQ = libc::EILSEQ as isize,
618 ERESTART = libc::ERESTART as isize,
619 ESTRPIPE = libc::ESTRPIPE as isize,
620 EUSERS = libc::EUSERS as isize,
621 ENOTSOCK = libc::ENOTSOCK as isize,
622 EDESTADDRREQ = libc::EDESTADDRREQ as isize,
623 EMSGSIZE = libc::EMSGSIZE as isize,
624 EPROTOTYPE = libc::EPROTOTYPE as isize,
625 ENOPROTOOPT = libc::ENOPROTOOPT as isize,
626 EPROTONOSUPPORT = libc::EPROTONOSUPPORT as isize,
627 ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT as isize,
628 EOPNOTSUPP = libc::EOPNOTSUPP as isize,
629 EPFNOSUPPORT = libc::EPFNOSUPPORT as isize,
630 EAFNOSUPPORT = libc::EAFNOSUPPORT as isize,
631 EADDRINUSE = libc::EADDRINUSE as isize,
632 EADDRNOTAVAIL = libc::EADDRNOTAVAIL as isize,
633 ENETDOWN = libc::ENETDOWN as isize,
634 ENETUNREACH = libc::ENETUNREACH as isize,
635 ENETRESET = libc::ENETRESET as isize,
636 ECONNABORTED = libc::ECONNABORTED as isize,
637 ECONNRESET = libc::ECONNRESET as isize,
638 ENOBUFS = libc::ENOBUFS as isize,
639 EISCONN = libc::EISCONN as isize,
640 ENOTCONN = libc::ENOTCONN as isize,
641 ESHUTDOWN = libc::ESHUTDOWN as isize,
642 ETOOMANYREFS = libc::ETOOMANYREFS as isize,
643 ETIMEDOUT = libc::ETIMEDOUT as isize,
644 ECONNREFUSED = libc::ECONNREFUSED as isize,
645 EHOSTDOWN = libc::EHOSTDOWN as isize,
646 EHOSTUNREACH = libc::EHOSTUNREACH as isize,
647 EALREADY = libc::EALREADY as isize,
648 EINPROGRESS = libc::EINPROGRESS as isize,
649 ESTALE = libc::ESTALE as isize,
650 EUCLEAN = libc::EUCLEAN as isize,
651 ENOTNAM = libc::ENOTNAM as isize,
652 ENAVAIL = libc::ENAVAIL as isize,
653 EISNAM = libc::EISNAM as isize,
654 EREMOTEIO = libc::EREMOTEIO as isize,
655 EDQUOT = libc::EDQUOT as isize,
656 ENOMEDIUM = libc::ENOMEDIUM as isize,
657 EMEDIUMTYPE = libc::EMEDIUMTYPE as isize,
658 ECANCELED = libc::ECANCELED as isize,
659 ENOKEY = libc::ENOKEY as isize,
660 EKEYEXPIRED = libc::EKEYEXPIRED as isize,
661 EKEYREVOKED = libc::EKEYREVOKED as isize,
662 EKEYREJECTED = libc::EKEYREJECTED as isize,
663 EOWNERDEAD = libc::EOWNERDEAD as isize,
664 ENOTRECOVERABLE = libc::ENOTRECOVERABLE as isize,
665
666 #[cfg(not(any(target_os = "android", target_arch="mips")))]
667 ERFKILL = libc::ERFKILL as isize,
668 #[cfg(not(any(target_os = "android", target_arch="mips")))]
669 EHWPOISON = libc::EHWPOISON as isize,
670 }
671
672 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
673 pub const EDEADLOCK: Errno = Errno::EDEADLK;
674
from_i32(e: i32) -> Errno675 pub fn from_i32(e: i32) -> Errno {
676 use self::Errno::*;
677
678 match e {
679 0 => UnknownErrno,
680 libc::EPERM => EPERM,
681 libc::ENOENT => ENOENT,
682 libc::ESRCH => ESRCH,
683 libc::EINTR => EINTR,
684 libc::EIO => EIO,
685 libc::ENXIO => ENXIO,
686 libc::E2BIG => E2BIG,
687 libc::ENOEXEC => ENOEXEC,
688 libc::EBADF => EBADF,
689 libc::ECHILD => ECHILD,
690 libc::EAGAIN => EAGAIN,
691 libc::ENOMEM => ENOMEM,
692 libc::EACCES => EACCES,
693 libc::EFAULT => EFAULT,
694 libc::ENOTBLK => ENOTBLK,
695 libc::EBUSY => EBUSY,
696 libc::EEXIST => EEXIST,
697 libc::EXDEV => EXDEV,
698 libc::ENODEV => ENODEV,
699 libc::ENOTDIR => ENOTDIR,
700 libc::EISDIR => EISDIR,
701 libc::EINVAL => EINVAL,
702 libc::ENFILE => ENFILE,
703 libc::EMFILE => EMFILE,
704 libc::ENOTTY => ENOTTY,
705 libc::ETXTBSY => ETXTBSY,
706 libc::EFBIG => EFBIG,
707 libc::ENOSPC => ENOSPC,
708 libc::ESPIPE => ESPIPE,
709 libc::EROFS => EROFS,
710 libc::EMLINK => EMLINK,
711 libc::EPIPE => EPIPE,
712 libc::EDOM => EDOM,
713 libc::ERANGE => ERANGE,
714 libc::EDEADLK => EDEADLK,
715 libc::ENAMETOOLONG => ENAMETOOLONG,
716 libc::ENOLCK => ENOLCK,
717 libc::ENOSYS => ENOSYS,
718 libc::ENOTEMPTY => ENOTEMPTY,
719 libc::ELOOP => ELOOP,
720 libc::ENOMSG => ENOMSG,
721 libc::EIDRM => EIDRM,
722 libc::ECHRNG => ECHRNG,
723 libc::EL2NSYNC => EL2NSYNC,
724 libc::EL3HLT => EL3HLT,
725 libc::EL3RST => EL3RST,
726 libc::ELNRNG => ELNRNG,
727 libc::EUNATCH => EUNATCH,
728 libc::ENOCSI => ENOCSI,
729 libc::EL2HLT => EL2HLT,
730 libc::EBADE => EBADE,
731 libc::EBADR => EBADR,
732 libc::EXFULL => EXFULL,
733 libc::ENOANO => ENOANO,
734 libc::EBADRQC => EBADRQC,
735 libc::EBADSLT => EBADSLT,
736 libc::EBFONT => EBFONT,
737 libc::ENOSTR => ENOSTR,
738 libc::ENODATA => ENODATA,
739 libc::ETIME => ETIME,
740 libc::ENOSR => ENOSR,
741 libc::ENONET => ENONET,
742 libc::ENOPKG => ENOPKG,
743 libc::EREMOTE => EREMOTE,
744 libc::ENOLINK => ENOLINK,
745 libc::EADV => EADV,
746 libc::ESRMNT => ESRMNT,
747 libc::ECOMM => ECOMM,
748 libc::EPROTO => EPROTO,
749 libc::EMULTIHOP => EMULTIHOP,
750 libc::EDOTDOT => EDOTDOT,
751 libc::EBADMSG => EBADMSG,
752 libc::EOVERFLOW => EOVERFLOW,
753 libc::ENOTUNIQ => ENOTUNIQ,
754 libc::EBADFD => EBADFD,
755 libc::EREMCHG => EREMCHG,
756 libc::ELIBACC => ELIBACC,
757 libc::ELIBBAD => ELIBBAD,
758 libc::ELIBSCN => ELIBSCN,
759 libc::ELIBMAX => ELIBMAX,
760 libc::ELIBEXEC => ELIBEXEC,
761 libc::EILSEQ => EILSEQ,
762 libc::ERESTART => ERESTART,
763 libc::ESTRPIPE => ESTRPIPE,
764 libc::EUSERS => EUSERS,
765 libc::ENOTSOCK => ENOTSOCK,
766 libc::EDESTADDRREQ => EDESTADDRREQ,
767 libc::EMSGSIZE => EMSGSIZE,
768 libc::EPROTOTYPE => EPROTOTYPE,
769 libc::ENOPROTOOPT => ENOPROTOOPT,
770 libc::EPROTONOSUPPORT => EPROTONOSUPPORT,
771 libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT,
772 libc::EOPNOTSUPP => EOPNOTSUPP,
773 libc::EPFNOSUPPORT => EPFNOSUPPORT,
774 libc::EAFNOSUPPORT => EAFNOSUPPORT,
775 libc::EADDRINUSE => EADDRINUSE,
776 libc::EADDRNOTAVAIL => EADDRNOTAVAIL,
777 libc::ENETDOWN => ENETDOWN,
778 libc::ENETUNREACH => ENETUNREACH,
779 libc::ENETRESET => ENETRESET,
780 libc::ECONNABORTED => ECONNABORTED,
781 libc::ECONNRESET => ECONNRESET,
782 libc::ENOBUFS => ENOBUFS,
783 libc::EISCONN => EISCONN,
784 libc::ENOTCONN => ENOTCONN,
785 libc::ESHUTDOWN => ESHUTDOWN,
786 libc::ETOOMANYREFS => ETOOMANYREFS,
787 libc::ETIMEDOUT => ETIMEDOUT,
788 libc::ECONNREFUSED => ECONNREFUSED,
789 libc::EHOSTDOWN => EHOSTDOWN,
790 libc::EHOSTUNREACH => EHOSTUNREACH,
791 libc::EALREADY => EALREADY,
792 libc::EINPROGRESS => EINPROGRESS,
793 libc::ESTALE => ESTALE,
794 libc::EUCLEAN => EUCLEAN,
795 libc::ENOTNAM => ENOTNAM,
796 libc::ENAVAIL => ENAVAIL,
797 libc::EISNAM => EISNAM,
798 libc::EREMOTEIO => EREMOTEIO,
799 libc::EDQUOT => EDQUOT,
800 libc::ENOMEDIUM => ENOMEDIUM,
801 libc::EMEDIUMTYPE => EMEDIUMTYPE,
802 libc::ECANCELED => ECANCELED,
803 libc::ENOKEY => ENOKEY,
804 libc::EKEYEXPIRED => EKEYEXPIRED,
805 libc::EKEYREVOKED => EKEYREVOKED,
806 libc::EKEYREJECTED => EKEYREJECTED,
807 libc::EOWNERDEAD => EOWNERDEAD,
808 libc::ENOTRECOVERABLE => ENOTRECOVERABLE,
809
810 #[cfg(not(any(target_os = "android", target_arch="mips")))]
811 libc::ERFKILL => ERFKILL,
812 #[cfg(not(any(target_os = "android", target_arch="mips")))]
813 libc::EHWPOISON => EHWPOISON,
814 _ => UnknownErrno,
815 }
816 }
817 }
818
819 #[cfg(any(target_os = "macos", target_os = "ios"))]
820 mod consts {
821 #[derive(Copy, Debug, Clone, PartialEq)]
822 pub enum Errno {
823 UnknownErrno = 0,
824 EPERM = 1,
825 ENOENT = 2,
826 ESRCH = 3,
827 EINTR = 4,
828 EIO = 5,
829 ENXIO = 6,
830 E2BIG = 7,
831 ENOEXEC = 8,
832 EBADF = 9,
833 ECHILD = 10,
834 EDEADLK = 11,
835 ENOMEM = 12,
836 EACCES = 13,
837 EFAULT = 14,
838 ENOTBLK = 15,
839 EBUSY = 16,
840 EEXIST = 17,
841 EXDEV = 18,
842 ENODEV = 19,
843 ENOTDIR = 20,
844 EISDIR = 21,
845 EINVAL = 22,
846 ENFILE = 23,
847 EMFILE = 24,
848 ENOTTY = 25,
849 ETXTBSY = 26,
850 EFBIG = 27,
851 ENOSPC = 28,
852 ESPIPE = 29,
853 EROFS = 30,
854 EMLINK = 31,
855 EPIPE = 32,
856 EDOM = 33,
857 ERANGE = 34,
858 EAGAIN = 35,
859 EINPROGRESS = 36,
860 EALREADY = 37,
861 ENOTSOCK = 38,
862 EDESTADDRREQ = 39,
863 EMSGSIZE = 40,
864 EPROTOTYPE = 41,
865 ENOPROTOOPT = 42,
866 EPROTONOSUPPORT = 43,
867 ESOCKTNOSUPPORT = 44,
868 ENOTSUP = 45,
869 EPFNOSUPPORT = 46,
870 EAFNOSUPPORT = 47,
871 EADDRINUSE = 48,
872 EADDRNOTAVAIL = 49,
873 ENETDOWN = 50,
874 ENETUNREACH = 51,
875 ENETRESET = 52,
876 ECONNABORTED = 53,
877 ECONNRESET = 54,
878 ENOBUFS = 55,
879 EISCONN = 56,
880 ENOTCONN = 57,
881 ESHUTDOWN = 58,
882 ETOOMANYREFS = 59,
883 ETIMEDOUT = 60,
884 ECONNREFUSED = 61,
885 ELOOP = 62,
886 ENAMETOOLONG = 63,
887 EHOSTDOWN = 64,
888 EHOSTUNREACH = 65,
889 ENOTEMPTY = 66,
890 EPROCLIM = 67,
891 EUSERS = 68,
892 EDQUOT = 69,
893 ESTALE = 70,
894 EREMOTE = 71,
895 EBADRPC = 72,
896 ERPCMISMATCH = 73,
897 EPROGUNAVAIL = 74,
898 EPROGMISMATCH = 75,
899 EPROCUNAVAIL = 76,
900 ENOLCK = 77,
901 ENOSYS = 78,
902 EFTYPE = 79,
903 EAUTH = 80,
904 ENEEDAUTH = 81,
905 EPWROFF = 82,
906 EDEVERR = 83,
907 EOVERFLOW = 84,
908 EBADEXEC = 85,
909 EBADARCH = 86,
910 ESHLIBVERS = 87,
911 EBADMACHO = 88,
912 ECANCELED = 89,
913 EIDRM = 90,
914 ENOMSG = 91,
915 EILSEQ = 92,
916 ENOATTR = 93,
917 EBADMSG = 94,
918 EMULTIHOP = 95,
919 ENODATA = 96,
920 ENOLINK = 97,
921 ENOSR = 98,
922 ENOSTR = 99,
923 EPROTO = 100,
924 ETIME = 101,
925 EOPNOTSUPP = 102,
926 ENOPOLICY = 103,
927 ENOTRECOVERABLE = 104,
928 EOWNERDEAD = 105,
929 EQFULL = 106,
930 }
931
932 pub const ELAST: Errno = Errno::EQFULL;
933 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
934 pub const EDEADLOCK: Errno = Errno::EDEADLK;
935
936 pub const EL2NSYNC: Errno = Errno::UnknownErrno;
937
from_i32(e: i32) -> Errno938 pub fn from_i32(e: i32) -> Errno {
939 use self::Errno::*;
940
941 match e {
942 0 => UnknownErrno,
943 1 => EPERM,
944 2 => ENOENT,
945 3 => ESRCH,
946 4 => EINTR,
947 5 => EIO,
948 6 => ENXIO,
949 7 => E2BIG,
950 8 => ENOEXEC,
951 9 => EBADF,
952 10 => ECHILD,
953 11 => EDEADLK,
954 12 => ENOMEM,
955 13 => EACCES,
956 14 => EFAULT,
957 15 => ENOTBLK,
958 16 => EBUSY,
959 17 => EEXIST,
960 18 => EXDEV,
961 19 => ENODEV,
962 20 => ENOTDIR,
963 21 => EISDIR,
964 22 => EINVAL,
965 23 => ENFILE,
966 24 => EMFILE,
967 25 => ENOTTY,
968 26 => ETXTBSY,
969 27 => EFBIG,
970 28 => ENOSPC,
971 29 => ESPIPE,
972 30 => EROFS,
973 31 => EMLINK,
974 32 => EPIPE,
975 33 => EDOM,
976 34 => ERANGE,
977 35 => EAGAIN,
978 36 => EINPROGRESS,
979 37 => EALREADY,
980 38 => ENOTSOCK,
981 39 => EDESTADDRREQ,
982 40 => EMSGSIZE,
983 41 => EPROTOTYPE,
984 42 => ENOPROTOOPT,
985 43 => EPROTONOSUPPORT,
986 44 => ESOCKTNOSUPPORT,
987 45 => ENOTSUP,
988 46 => EPFNOSUPPORT,
989 47 => EAFNOSUPPORT,
990 48 => EADDRINUSE,
991 49 => EADDRNOTAVAIL,
992 50 => ENETDOWN,
993 51 => ENETUNREACH,
994 52 => ENETRESET,
995 53 => ECONNABORTED,
996 54 => ECONNRESET,
997 55 => ENOBUFS,
998 56 => EISCONN,
999 57 => ENOTCONN,
1000 58 => ESHUTDOWN,
1001 59 => ETOOMANYREFS,
1002 60 => ETIMEDOUT,
1003 61 => ECONNREFUSED,
1004 62 => ELOOP,
1005 63 => ENAMETOOLONG,
1006 64 => EHOSTDOWN,
1007 65 => EHOSTUNREACH,
1008 66 => ENOTEMPTY,
1009 67 => EPROCLIM,
1010 68 => EUSERS,
1011 69 => EDQUOT,
1012 70 => ESTALE,
1013 71 => EREMOTE,
1014 72 => EBADRPC,
1015 73 => ERPCMISMATCH,
1016 74 => EPROGUNAVAIL,
1017 75 => EPROGMISMATCH,
1018 76 => EPROCUNAVAIL,
1019 77 => ENOLCK,
1020 78 => ENOSYS,
1021 79 => EFTYPE,
1022 80 => EAUTH,
1023 81 => ENEEDAUTH,
1024 82 => EPWROFF,
1025 83 => EDEVERR,
1026 84 => EOVERFLOW,
1027 85 => EBADEXEC,
1028 86 => EBADARCH,
1029 87 => ESHLIBVERS,
1030 88 => EBADMACHO,
1031 89 => ECANCELED,
1032 90 => EIDRM,
1033 91 => ENOMSG,
1034 92 => EILSEQ,
1035 93 => ENOATTR,
1036 94 => EBADMSG,
1037 95 => EMULTIHOP,
1038 96 => ENODATA,
1039 97 => ENOLINK,
1040 98 => ENOSR,
1041 99 => ENOSTR,
1042 100 => EPROTO,
1043 101 => ETIME,
1044 102 => EOPNOTSUPP,
1045 103 => ENOPOLICY,
1046 104 => ENOTRECOVERABLE,
1047 105 => EOWNERDEAD,
1048 106 => EQFULL,
1049 _ => UnknownErrno,
1050 }
1051 }
1052 }
1053
1054 #[cfg(target_os = "freebsd")]
1055 mod consts {
1056 #[derive(Copy, Debug, Clone, PartialEq)]
1057 pub enum Errno {
1058 UnknownErrno = 0,
1059 EPERM = 1,
1060 ENOENT = 2,
1061 ESRCH = 3,
1062 EINTR = 4,
1063 EIO = 5,
1064 ENXIO = 6,
1065 E2BIG = 7,
1066 ENOEXEC = 8,
1067 EBADF = 9,
1068 ECHILD = 10,
1069 EDEADLK = 11,
1070 ENOMEM = 12,
1071 EACCES = 13,
1072 EFAULT = 14,
1073 ENOTBLK = 15,
1074 EBUSY = 16,
1075 EEXIST = 17,
1076 EXDEV = 18,
1077 ENODEV = 19,
1078 ENOTDIR = 20,
1079 EISDIR = 21,
1080 EINVAL = 22,
1081 ENFILE = 23,
1082 EMFILE = 24,
1083 ENOTTY = 25,
1084 ETXTBSY = 26,
1085 EFBIG = 27,
1086 ENOSPC = 28,
1087 ESPIPE = 29,
1088 EROFS = 30,
1089 EMLINK = 31,
1090 EPIPE = 32,
1091 EDOM = 33,
1092 ERANGE = 34,
1093 EAGAIN = 35,
1094 EINPROGRESS = 36,
1095 EALREADY = 37,
1096 ENOTSOCK = 38,
1097 EDESTADDRREQ = 39,
1098 EMSGSIZE = 40,
1099 EPROTOTYPE = 41,
1100 ENOPROTOOPT = 42,
1101 EPROTONOSUPPORT = 43,
1102 ESOCKTNOSUPPORT = 44,
1103 ENOTSUP = 45,
1104 EPFNOSUPPORT = 46,
1105 EAFNOSUPPORT = 47,
1106 EADDRINUSE = 48,
1107 EADDRNOTAVAIL = 49,
1108 ENETDOWN = 50,
1109 ENETUNREACH = 51,
1110 ENETRESET = 52,
1111 ECONNABORTED = 53,
1112 ECONNRESET = 54,
1113 ENOBUFS = 55,
1114 EISCONN = 56,
1115 ENOTCONN = 57,
1116 ESHUTDOWN = 58,
1117 ETOOMANYREFS = 59,
1118 ETIMEDOUT = 60,
1119 ECONNREFUSED = 61,
1120 ELOOP = 62,
1121 ENAMETOOLONG = 63,
1122 EHOSTDOWN = 64,
1123 EHOSTUNREACH = 65,
1124 ENOTEMPTY = 66,
1125 EPROCLIM = 67,
1126 EUSERS = 68,
1127 EDQUOT = 69,
1128 ESTALE = 70,
1129 EREMOTE = 71,
1130 EBADRPC = 72,
1131 ERPCMISMATCH = 73,
1132 EPROGUNAVAIL = 74,
1133 EPROGMISMATCH = 75,
1134 EPROCUNAVAIL = 76,
1135 ENOLCK = 77,
1136 ENOSYS = 78,
1137 EFTYPE = 79,
1138 EAUTH = 80,
1139 ENEEDAUTH = 81,
1140 EIDRM = 82,
1141 ENOMSG = 83,
1142 EOVERFLOW = 84,
1143 ECANCELED = 85,
1144 EILSEQ = 86,
1145 ENOATTR = 87,
1146 EDOOFUS = 88,
1147 EBADMSG = 89,
1148 EMULTIHOP = 90,
1149 ENOLINK = 91,
1150 EPROTO = 92,
1151 ENOTCAPABLE = 93,
1152 ECAPMODE = 94,
1153 ENOTRECOVERABLE = 95,
1154 EOWNERDEAD = 96
1155
1156 }
1157
1158 pub const ELAST: Errno = Errno::EOWNERDEAD;
1159 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
1160 pub const EDEADLOCK: Errno = Errno::EDEADLK;
1161
1162 pub const EL2NSYNC: Errno = Errno::UnknownErrno;
1163
from_i32(e: i32) -> Errno1164 pub fn from_i32(e: i32) -> Errno {
1165 use self::Errno::*;
1166
1167 match e {
1168 0 => UnknownErrno,
1169 1 => EPERM,
1170 2 => ENOENT,
1171 3 => ESRCH,
1172 4 => EINTR,
1173 5 => EIO,
1174 6 => ENXIO,
1175 7 => E2BIG,
1176 8 => ENOEXEC,
1177 9 => EBADF,
1178 10 => ECHILD,
1179 11 => EDEADLK,
1180 12 => ENOMEM,
1181 13 => EACCES,
1182 14 => EFAULT,
1183 15 => ENOTBLK,
1184 16 => EBUSY,
1185 17 => EEXIST,
1186 18 => EXDEV,
1187 19 => ENODEV,
1188 20 => ENOTDIR,
1189 21 => EISDIR,
1190 22 => EINVAL,
1191 23 => ENFILE,
1192 24 => EMFILE,
1193 25 => ENOTTY,
1194 26 => ETXTBSY,
1195 27 => EFBIG,
1196 28 => ENOSPC,
1197 29 => ESPIPE,
1198 30 => EROFS,
1199 31 => EMLINK,
1200 32 => EPIPE,
1201 33 => EDOM,
1202 34 => ERANGE,
1203 35 => EAGAIN,
1204 36 => EINPROGRESS,
1205 37 => EALREADY,
1206 38 => ENOTSOCK,
1207 39 => EDESTADDRREQ,
1208 40 => EMSGSIZE,
1209 41 => EPROTOTYPE,
1210 42 => ENOPROTOOPT,
1211 43 => EPROTONOSUPPORT,
1212 44 => ESOCKTNOSUPPORT,
1213 45 => ENOTSUP,
1214 46 => EPFNOSUPPORT,
1215 47 => EAFNOSUPPORT,
1216 48 => EADDRINUSE,
1217 49 => EADDRNOTAVAIL,
1218 50 => ENETDOWN,
1219 51 => ENETUNREACH,
1220 52 => ENETRESET,
1221 53 => ECONNABORTED,
1222 54 => ECONNRESET,
1223 55 => ENOBUFS,
1224 56 => EISCONN,
1225 57 => ENOTCONN,
1226 58 => ESHUTDOWN,
1227 59 => ETOOMANYREFS,
1228 60 => ETIMEDOUT,
1229 61 => ECONNREFUSED,
1230 62 => ELOOP,
1231 63 => ENAMETOOLONG,
1232 64 => EHOSTDOWN,
1233 65 => EHOSTUNREACH,
1234 66 => ENOTEMPTY,
1235 67 => EPROCLIM,
1236 68 => EUSERS,
1237 69 => EDQUOT,
1238 70 => ESTALE,
1239 71 => EREMOTE,
1240 72 => EBADRPC,
1241 73 => ERPCMISMATCH,
1242 74 => EPROGUNAVAIL,
1243 75 => EPROGMISMATCH,
1244 76 => EPROCUNAVAIL,
1245 77 => ENOLCK,
1246 78 => ENOSYS,
1247 79 => EFTYPE,
1248 80 => EAUTH,
1249 81 => ENEEDAUTH,
1250 82 => EIDRM,
1251 83 => ENOMSG,
1252 84 => EOVERFLOW,
1253 85 => ECANCELED,
1254 86 => EILSEQ,
1255 87 => ENOATTR,
1256 88 => EDOOFUS,
1257 89 => EBADMSG,
1258 90 => EMULTIHOP,
1259 91 => ENOLINK,
1260 92 => EPROTO,
1261 93 => ENOTCAPABLE,
1262 94 => ECAPMODE,
1263 95 => ENOTRECOVERABLE,
1264 96 => EOWNERDEAD,
1265 _ => UnknownErrno,
1266 }
1267 }
1268 }
1269
1270
1271 #[cfg(target_os = "dragonfly")]
1272 mod consts {
1273 #[derive(Copy, Debug, Clone, PartialEq)]
1274 pub enum Errno {
1275 UnknownErrno = 0,
1276 EPERM = 1,
1277 ENOENT = 2,
1278 ESRCH = 3,
1279 EINTR = 4,
1280 EIO = 5,
1281 ENXIO = 6,
1282 E2BIG = 7,
1283 ENOEXEC = 8,
1284 EBADF = 9,
1285 ECHILD = 10,
1286 EDEADLK = 11,
1287 ENOMEM = 12,
1288 EACCES = 13,
1289 EFAULT = 14,
1290 ENOTBLK = 15,
1291 EBUSY = 16,
1292 EEXIST = 17,
1293 EXDEV = 18,
1294 ENODEV = 19,
1295 ENOTDIR = 20,
1296 EISDIR = 21,
1297 EINVAL = 22,
1298 ENFILE = 23,
1299 EMFILE = 24,
1300 ENOTTY = 25,
1301 ETXTBSY = 26,
1302 EFBIG = 27,
1303 ENOSPC = 28,
1304 ESPIPE = 29,
1305 EROFS = 30,
1306 EMLINK = 31,
1307 EPIPE = 32,
1308 EDOM = 33,
1309 ERANGE = 34,
1310 EAGAIN = 35,
1311 EINPROGRESS = 36,
1312 EALREADY = 37,
1313 ENOTSOCK = 38,
1314 EDESTADDRREQ = 39,
1315 EMSGSIZE = 40,
1316 EPROTOTYPE = 41,
1317 ENOPROTOOPT = 42,
1318 EPROTONOSUPPORT = 43,
1319 ESOCKTNOSUPPORT = 44,
1320 ENOTSUP = 45,
1321 EPFNOSUPPORT = 46,
1322 EAFNOSUPPORT = 47,
1323 EADDRINUSE = 48,
1324 EADDRNOTAVAIL = 49,
1325 ENETDOWN = 50,
1326 ENETUNREACH = 51,
1327 ENETRESET = 52,
1328 ECONNABORTED = 53,
1329 ECONNRESET = 54,
1330 ENOBUFS = 55,
1331 EISCONN = 56,
1332 ENOTCONN = 57,
1333 ESHUTDOWN = 58,
1334 ETOOMANYREFS = 59,
1335 ETIMEDOUT = 60,
1336 ECONNREFUSED = 61,
1337 ELOOP = 62,
1338 ENAMETOOLONG = 63,
1339 EHOSTDOWN = 64,
1340 EHOSTUNREACH = 65,
1341 ENOTEMPTY = 66,
1342 EPROCLIM = 67,
1343 EUSERS = 68,
1344 EDQUOT = 69,
1345 ESTALE = 70,
1346 EREMOTE = 71,
1347 EBADRPC = 72,
1348 ERPCMISMATCH = 73,
1349 EPROGUNAVAIL = 74,
1350 EPROGMISMATCH = 75,
1351 EPROCUNAVAIL = 76,
1352 ENOLCK = 77,
1353 ENOSYS = 78,
1354 EFTYPE = 79,
1355 EAUTH = 80,
1356 ENEEDAUTH = 81,
1357 EIDRM = 82,
1358 ENOMSG = 83,
1359 EOVERFLOW = 84,
1360 ECANCELED = 85,
1361 EILSEQ = 86,
1362 ENOATTR = 87,
1363 EDOOFUS = 88,
1364 EBADMSG = 89,
1365 EMULTIHOP = 90,
1366 ENOLINK = 91,
1367 EPROTO = 92,
1368
1369 ENOMEDIUM = 93,
1370 EUNUSED94 = 94,
1371 EUNUSED95 = 95,
1372 EUNUSED96 = 96,
1373 EUNUSED97 = 97,
1374 EUNUSED98 = 98,
1375 EASYNC = 99,
1376 }
1377
1378 pub const ELAST: Errno = Errno::EASYNC;
1379 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
1380 pub const EDEADLOCK: Errno = Errno::EDEADLK;
1381 pub const EOPNOTSUPP: Errno = Errno::ENOTSUP;
1382
1383 pub const EL2NSYNC: Errno = Errno::UnknownErrno;
1384
from_i32(e: i32) -> Errno1385 pub fn from_i32(e: i32) -> Errno {
1386 use self::Errno::*;
1387
1388 match e {
1389 0 => UnknownErrno,
1390 1 => EPERM,
1391 2 => ENOENT,
1392 3 => ESRCH,
1393 4 => EINTR,
1394 5 => EIO,
1395 6 => ENXIO,
1396 7 => E2BIG,
1397 8 => ENOEXEC,
1398 9 => EBADF,
1399 10 => ECHILD,
1400 11 => EDEADLK,
1401 12 => ENOMEM,
1402 13 => EACCES,
1403 14 => EFAULT,
1404 15 => ENOTBLK,
1405 16 => EBUSY,
1406 17 => EEXIST,
1407 18 => EXDEV,
1408 19 => ENODEV,
1409 20 => ENOTDIR,
1410 21 => EISDIR,
1411 22 => EINVAL,
1412 23 => ENFILE,
1413 24 => EMFILE,
1414 25 => ENOTTY,
1415 26 => ETXTBSY,
1416 27 => EFBIG,
1417 28 => ENOSPC,
1418 29 => ESPIPE,
1419 30 => EROFS,
1420 31 => EMLINK,
1421 32 => EPIPE,
1422 33 => EDOM,
1423 34 => ERANGE,
1424 35 => EAGAIN,
1425 36 => EINPROGRESS,
1426 37 => EALREADY,
1427 38 => ENOTSOCK,
1428 39 => EDESTADDRREQ,
1429 40 => EMSGSIZE,
1430 41 => EPROTOTYPE,
1431 42 => ENOPROTOOPT,
1432 43 => EPROTONOSUPPORT,
1433 44 => ESOCKTNOSUPPORT,
1434 45 => ENOTSUP,
1435 46 => EPFNOSUPPORT,
1436 47 => EAFNOSUPPORT,
1437 48 => EADDRINUSE,
1438 49 => EADDRNOTAVAIL,
1439 50 => ENETDOWN,
1440 51 => ENETUNREACH,
1441 52 => ENETRESET,
1442 53 => ECONNABORTED,
1443 54 => ECONNRESET,
1444 55 => ENOBUFS,
1445 56 => EISCONN,
1446 57 => ENOTCONN,
1447 58 => ESHUTDOWN,
1448 59 => ETOOMANYREFS,
1449 60 => ETIMEDOUT,
1450 61 => ECONNREFUSED,
1451 62 => ELOOP,
1452 63 => ENAMETOOLONG,
1453 64 => EHOSTDOWN,
1454 65 => EHOSTUNREACH,
1455 66 => ENOTEMPTY,
1456 67 => EPROCLIM,
1457 68 => EUSERS,
1458 69 => EDQUOT,
1459 70 => ESTALE,
1460 71 => EREMOTE,
1461 72 => EBADRPC,
1462 73 => ERPCMISMATCH,
1463 74 => EPROGUNAVAIL,
1464 75 => EPROGMISMATCH,
1465 76 => EPROCUNAVAIL,
1466 77 => ENOLCK,
1467 78 => ENOSYS,
1468 79 => EFTYPE,
1469 80 => EAUTH,
1470 81 => ENEEDAUTH,
1471 82 => EIDRM,
1472 83 => ENOMSG,
1473 84 => EOVERFLOW,
1474 85 => ECANCELED,
1475 86 => EILSEQ,
1476 87 => ENOATTR,
1477 88 => EDOOFUS,
1478 89 => EBADMSG,
1479 90 => EMULTIHOP,
1480 91 => ENOLINK,
1481 92 => EPROTO,
1482 93 => ENOMEDIUM,
1483 94 => EUNUSED94,
1484 95 => EUNUSED95,
1485 96 => EUNUSED96,
1486 97 => EUNUSED97,
1487 98 => EUNUSED98,
1488 99 => EASYNC,
1489 _ => UnknownErrno,
1490 }
1491 }
1492 }
1493
1494
1495 #[cfg(target_os = "openbsd")]
1496 mod consts {
1497 #[derive(Copy, Debug, Clone, PartialEq)]
1498 pub enum Errno {
1499 UnknownErrno = 0,
1500 EPERM = 1,
1501 ENOENT = 2,
1502 ESRCH = 3,
1503 EINTR = 4,
1504 EIO = 5,
1505 ENXIO = 6,
1506 E2BIG = 7,
1507 ENOEXEC = 8,
1508 EBADF = 9,
1509 ECHILD = 10,
1510 EDEADLK = 11,
1511 ENOMEM = 12,
1512 EACCES = 13,
1513 EFAULT = 14,
1514 ENOTBLK = 15,
1515 EBUSY = 16,
1516 EEXIST = 17,
1517 EXDEV = 18,
1518 ENODEV = 19,
1519 ENOTDIR = 20,
1520 EISDIR = 21,
1521 EINVAL = 22,
1522 ENFILE = 23,
1523 EMFILE = 24,
1524 ENOTTY = 25,
1525 ETXTBSY = 26,
1526 EFBIG = 27,
1527 ENOSPC = 28,
1528 ESPIPE = 29,
1529 EROFS = 30,
1530 EMLINK = 31,
1531 EPIPE = 32,
1532 EDOM = 33,
1533 ERANGE = 34,
1534 EAGAIN = 35,
1535 EINPROGRESS = 36,
1536 EALREADY = 37,
1537 ENOTSOCK = 38,
1538 EDESTADDRREQ = 39,
1539 EMSGSIZE = 40,
1540 EPROTOTYPE = 41,
1541 ENOPROTOOPT = 42,
1542 EPROTONOSUPPORT = 43,
1543 ESOCKTNOSUPPORT = 44,
1544 EOPNOTSUPP = 45,
1545 EPFNOSUPPORT = 46,
1546 EAFNOSUPPORT = 47,
1547 EADDRINUSE = 48,
1548 EADDRNOTAVAIL = 49,
1549 ENETDOWN = 50,
1550 ENETUNREACH = 51,
1551 ENETRESET = 52,
1552 ECONNABORTED = 53,
1553 ECONNRESET = 54,
1554 ENOBUFS = 55,
1555 EISCONN = 56,
1556 ENOTCONN = 57,
1557 ESHUTDOWN = 58,
1558 ETOOMANYREFS = 59,
1559 ETIMEDOUT = 60,
1560 ECONNREFUSED = 61,
1561 ELOOP = 62,
1562 ENAMETOOLONG = 63,
1563 EHOSTDOWN = 64,
1564 EHOSTUNREACH = 65,
1565 ENOTEMPTY = 66,
1566 EPROCLIM = 67,
1567 EUSERS = 68,
1568 EDQUOT = 69,
1569 ESTALE = 70,
1570 EREMOTE = 71,
1571 EBADRPC = 72,
1572 ERPCMISMATCH = 73,
1573 EPROGUNAVAIL = 74,
1574 EPROGMISMATCH = 75,
1575 EPROCUNAVAIL = 76,
1576 ENOLCK = 77,
1577 ENOSYS = 78,
1578 EFTYPE = 79,
1579 EAUTH = 80,
1580 ENEEDAUTH = 81,
1581 EIPSEC = 82,
1582 ENOATTR = 83,
1583 EILSEQ = 84,
1584 ENOMEDIUM = 85,
1585 EMEDIUMTYPE = 86,
1586 EOVERFLOW = 87,
1587 ECANCELED = 88,
1588 EIDRM = 89,
1589 ENOMSG = 90,
1590 ENOTSUP = 91,
1591 }
1592
1593 pub const ELAST: Errno = Errno::ENOTSUP;
1594 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
1595
1596 pub const EL2NSYNC: Errno = Errno::UnknownErrno;
1597
from_i32(e: i32) -> Errno1598 pub fn from_i32(e: i32) -> Errno {
1599 use self::Errno::*;
1600
1601 match e {
1602 0 => UnknownErrno,
1603 1 => EPERM,
1604 2 => ENOENT,
1605 3 => ESRCH,
1606 4 => EINTR,
1607 5 => EIO,
1608 6 => ENXIO,
1609 7 => E2BIG,
1610 8 => ENOEXEC,
1611 9 => EBADF,
1612 10 => ECHILD,
1613 11 => EDEADLK,
1614 12 => ENOMEM,
1615 13 => EACCES,
1616 14 => EFAULT,
1617 15 => ENOTBLK,
1618 16 => EBUSY,
1619 17 => EEXIST,
1620 18 => EXDEV,
1621 19 => ENODEV,
1622 20 => ENOTDIR,
1623 21 => EISDIR,
1624 22 => EINVAL,
1625 23 => ENFILE,
1626 24 => EMFILE,
1627 25 => ENOTTY,
1628 26 => ETXTBSY,
1629 27 => EFBIG,
1630 28 => ENOSPC,
1631 29 => ESPIPE,
1632 30 => EROFS,
1633 31 => EMLINK,
1634 32 => EPIPE,
1635 33 => EDOM,
1636 34 => ERANGE,
1637 35 => EAGAIN,
1638 36 => EINPROGRESS,
1639 37 => EALREADY,
1640 38 => ENOTSOCK,
1641 39 => EDESTADDRREQ,
1642 40 => EMSGSIZE,
1643 41 => EPROTOTYPE,
1644 42 => ENOPROTOOPT,
1645 43 => EPROTONOSUPPORT,
1646 44 => ESOCKTNOSUPPORT,
1647 45 => EOPNOTSUPP,
1648 46 => EPFNOSUPPORT,
1649 47 => EAFNOSUPPORT,
1650 48 => EADDRINUSE,
1651 49 => EADDRNOTAVAIL,
1652 50 => ENETDOWN,
1653 51 => ENETUNREACH,
1654 52 => ENETRESET,
1655 53 => ECONNABORTED,
1656 54 => ECONNRESET,
1657 55 => ENOBUFS,
1658 56 => EISCONN,
1659 57 => ENOTCONN,
1660 58 => ESHUTDOWN,
1661 59 => ETOOMANYREFS,
1662 60 => ETIMEDOUT,
1663 61 => ECONNREFUSED,
1664 62 => ELOOP,
1665 63 => ENAMETOOLONG,
1666 64 => EHOSTDOWN,
1667 65 => EHOSTUNREACH,
1668 66 => ENOTEMPTY,
1669 67 => EPROCLIM,
1670 68 => EUSERS,
1671 69 => EDQUOT,
1672 70 => ESTALE,
1673 71 => EREMOTE,
1674 72 => EBADRPC,
1675 73 => ERPCMISMATCH,
1676 74 => EPROGUNAVAIL,
1677 75 => EPROGMISMATCH,
1678 76 => EPROCUNAVAIL,
1679 77 => ENOLCK,
1680 78 => ENOSYS,
1681 79 => EFTYPE,
1682 80 => EAUTH,
1683 81 => ENEEDAUTH,
1684 82 => EIPSEC,
1685 83 => ENOATTR,
1686 84 => EILSEQ,
1687 85 => ENOMEDIUM,
1688 86 => EMEDIUMTYPE,
1689 87 => EOVERFLOW,
1690 88 => ECANCELED,
1691 89 => EIDRM,
1692 90 => ENOMSG,
1693 91 => ENOTSUP,
1694 _ => UnknownErrno,
1695 }
1696 }
1697 }
1698
1699 #[cfg(target_os = "netbsd")]
1700 mod consts {
1701 #[derive(Copy, Debug, Clone, PartialEq)]
1702 pub enum Errno {
1703 UnknownErrno = 0,
1704 EPERM = 1,
1705 ENOENT = 2,
1706 ESRCH = 3,
1707 EINTR = 4,
1708 EIO = 5,
1709 ENXIO = 6,
1710 E2BIG = 7,
1711 ENOEXEC = 8,
1712 EBADF = 9,
1713 ECHILD = 10,
1714 EDEADLK = 11,
1715 ENOMEM = 12,
1716 EACCES = 13,
1717 EFAULT = 14,
1718 ENOTBLK = 15,
1719 EBUSY = 16,
1720 EEXIST = 17,
1721 EXDEV = 18,
1722 ENODEV = 19,
1723 ENOTDIR = 20,
1724 EISDIR = 21,
1725 EINVAL = 22,
1726 ENFILE = 23,
1727 EMFILE = 24,
1728 ENOTTY = 25,
1729 ETXTBSY = 26,
1730 EFBIG = 27,
1731 ENOSPC = 28,
1732 ESPIPE = 29,
1733 EROFS = 30,
1734 EMLINK = 31,
1735 EPIPE = 32,
1736 EDOM = 33,
1737 ERANGE = 34,
1738 EAGAIN = 35,
1739 EINPROGRESS = 36,
1740 EALREADY = 37,
1741 ENOTSOCK = 38,
1742 EDESTADDRREQ = 39,
1743 EMSGSIZE = 40,
1744 EPROTOTYPE = 41,
1745 ENOPROTOOPT = 42,
1746 EPROTONOSUPPORT = 43,
1747 ESOCKTNOSUPPORT = 44,
1748 EOPNOTSUPP = 45,
1749 EPFNOSUPPORT = 46,
1750 EAFNOSUPPORT = 47,
1751 EADDRINUSE = 48,
1752 EADDRNOTAVAIL = 49,
1753 ENETDOWN = 50,
1754 ENETUNREACH = 51,
1755 ENETRESET = 52,
1756 ECONNABORTED = 53,
1757 ECONNRESET = 54,
1758 ENOBUFS = 55,
1759 EISCONN = 56,
1760 ENOTCONN = 57,
1761 ESHUTDOWN = 58,
1762 ETOOMANYREFS = 59,
1763 ETIMEDOUT = 60,
1764 ECONNREFUSED = 61,
1765 ELOOP = 62,
1766 ENAMETOOLONG = 63,
1767 EHOSTDOWN = 64,
1768 EHOSTUNREACH = 65,
1769 ENOTEMPTY = 66,
1770 EPROCLIM = 67,
1771 EUSERS = 68,
1772 EDQUOT = 69,
1773 ESTALE = 70,
1774 EREMOTE = 71,
1775 EBADRPC = 72,
1776 ERPCMISMATCH = 73,
1777 EPROGUNAVAIL = 74,
1778 EPROGMISMATCH = 75,
1779 EPROCUNAVAIL = 76,
1780 ENOLCK = 77,
1781 ENOSYS = 78,
1782 EFTYPE = 79,
1783 EAUTH = 80,
1784 ENEEDAUTH = 81,
1785 EIDRM = 82,
1786 ENOMSG = 83,
1787 EOVERFLOW = 84,
1788 EILSEQ = 85,
1789 ENOTSUP = 86,
1790 ECANCELED = 87,
1791 EBADMSG = 88,
1792 ENODATA = 89,
1793 ENOSR = 90,
1794 ENOSTR = 91,
1795 ETIME = 92,
1796 ENOATTR = 93,
1797 EMULTIHOP = 94,
1798 ENOLINK = 95,
1799 EPROTO = 96,
1800 }
1801
1802 pub const ELAST: Errno = Errno::ENOTSUP;
1803 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
1804
1805 pub const EL2NSYNC: Errno = Errno::UnknownErrno;
1806
from_i32(e: i32) -> Errno1807 pub fn from_i32(e: i32) -> Errno {
1808 use self::Errno::*;
1809
1810 match e {
1811 0 => UnknownErrno,
1812 1 => EPERM,
1813 2 => ENOENT,
1814 3 => ESRCH,
1815 4 => EINTR,
1816 5 => EIO,
1817 6 => ENXIO,
1818 7 => E2BIG,
1819 8 => ENOEXEC,
1820 9 => EBADF,
1821 10 => ECHILD,
1822 11 => EDEADLK,
1823 12 => ENOMEM,
1824 13 => EACCES,
1825 14 => EFAULT,
1826 15 => ENOTBLK,
1827 16 => EBUSY,
1828 17 => EEXIST,
1829 18 => EXDEV,
1830 19 => ENODEV,
1831 20 => ENOTDIR,
1832 21 => EISDIR,
1833 22 => EINVAL,
1834 23 => ENFILE,
1835 24 => EMFILE,
1836 25 => ENOTTY,
1837 26 => ETXTBSY,
1838 27 => EFBIG,
1839 28 => ENOSPC,
1840 29 => ESPIPE,
1841 30 => EROFS,
1842 31 => EMLINK,
1843 32 => EPIPE,
1844 33 => EDOM,
1845 34 => ERANGE,
1846 35 => EAGAIN,
1847 36 => EINPROGRESS,
1848 37 => EALREADY,
1849 38 => ENOTSOCK,
1850 39 => EDESTADDRREQ,
1851 40 => EMSGSIZE,
1852 41 => EPROTOTYPE,
1853 42 => ENOPROTOOPT,
1854 43 => EPROTONOSUPPORT,
1855 44 => ESOCKTNOSUPPORT,
1856 45 => EOPNOTSUPP,
1857 46 => EPFNOSUPPORT,
1858 47 => EAFNOSUPPORT,
1859 48 => EADDRINUSE,
1860 49 => EADDRNOTAVAIL,
1861 50 => ENETDOWN,
1862 51 => ENETUNREACH,
1863 52 => ENETRESET,
1864 53 => ECONNABORTED,
1865 54 => ECONNRESET,
1866 55 => ENOBUFS,
1867 56 => EISCONN,
1868 57 => ENOTCONN,
1869 58 => ESHUTDOWN,
1870 59 => ETOOMANYREFS,
1871 60 => ETIMEDOUT,
1872 61 => ECONNREFUSED,
1873 62 => ELOOP,
1874 63 => ENAMETOOLONG,
1875 64 => EHOSTDOWN,
1876 65 => EHOSTUNREACH,
1877 66 => ENOTEMPTY,
1878 67 => EPROCLIM,
1879 68 => EUSERS,
1880 69 => EDQUOT,
1881 70 => ESTALE,
1882 71 => EREMOTE,
1883 72 => EBADRPC,
1884 73 => ERPCMISMATCH,
1885 74 => EPROGUNAVAIL,
1886 75 => EPROGMISMATCH,
1887 76 => EPROCUNAVAIL,
1888 77 => ENOLCK,
1889 78 => ENOSYS,
1890 79 => EFTYPE,
1891 80 => EAUTH,
1892 81 => ENEEDAUTH,
1893 82 => EIDRM,
1894 83 => ENOMSG,
1895 84 => EOVERFLOW,
1896 85 => EILSEQ,
1897 86 => ENOTSUP,
1898 87 => ECANCELED,
1899 88 => EBADMSG,
1900 89 => ENODATA,
1901 90 => ENOSR,
1902 91 => ENOSTR,
1903 92 => ETIME,
1904 93 => ENOATTR,
1905 94 => EMULTIHOP,
1906 95 => ENOLINK,
1907 96 => EPROTO,
1908 _ => UnknownErrno,
1909 }
1910 }
1911 }
1912
1913
1914 #[cfg(test)]
1915 mod test {
1916 use super::*;
1917 use nixtest::assert_const_eq;
1918 use libc::c_int;
1919
1920 macro_rules! check_errno {
1921 ($($errno:ident),+) => {{
1922 $(assert_const_eq(stringify!($errno), $errno as c_int);)+
1923 }};
1924 }
1925
1926 #[test]
test_errno_values()1927 pub fn test_errno_values() {
1928 check_errno!(
1929 EPERM,
1930 ENOENT,
1931 ESRCH,
1932 EINTR,
1933 EIO,
1934 ENXIO,
1935 E2BIG,
1936 ENOEXEC,
1937 EBADF,
1938 ECHILD,
1939 EAGAIN,
1940 ENOMEM,
1941 EACCES,
1942 EFAULT,
1943 ENOTBLK,
1944 EBUSY,
1945 EEXIST,
1946 EXDEV,
1947 ENODEV,
1948 ENOTDIR,
1949 EISDIR,
1950 EINVAL,
1951 ENFILE,
1952 EMFILE,
1953 ENOTTY,
1954 ETXTBSY,
1955 EFBIG,
1956 ENOSPC,
1957 ESPIPE,
1958 EROFS,
1959 EMLINK,
1960 EPIPE,
1961 EDOM,
1962 ERANGE,
1963 EDEADLK,
1964 ENAMETOOLONG,
1965 ENOLCK,
1966 ENOSYS,
1967 ENOTEMPTY,
1968 ELOOP,
1969 ENOMSG,
1970 EIDRM);
1971
1972 check_errno!(
1973 EINPROGRESS,
1974 EALREADY,
1975 ENOTSOCK,
1976 EDESTADDRREQ,
1977 EMSGSIZE,
1978 EPROTOTYPE,
1979 ENOPROTOOPT,
1980 EPROTONOSUPPORT,
1981 ESOCKTNOSUPPORT,
1982 EPFNOSUPPORT,
1983 EAFNOSUPPORT,
1984 EADDRINUSE,
1985 EADDRNOTAVAIL,
1986 ENETDOWN,
1987 ENETUNREACH,
1988 ENETRESET,
1989 ECONNABORTED,
1990 ECONNRESET,
1991 ENOBUFS,
1992 EISCONN,
1993 ENOTCONN,
1994 ESHUTDOWN,
1995 ETOOMANYREFS,
1996 ETIMEDOUT,
1997 ECONNREFUSED,
1998 EHOSTDOWN,
1999 EHOSTUNREACH);
2000 }
2001
2002 #[test]
2003 #[cfg(any(target_os = "linux", target_os = "android"))]
test_linux_errnos()2004 pub fn test_linux_errnos() {
2005 check_errno!(
2006 ECHRNG,
2007 EL2NSYNC,
2008 EL3HLT,
2009 EL3RST,
2010 ELNRNG,
2011 EUNATCH,
2012 ENOCSI,
2013 EL2HLT,
2014 EBADE,
2015 EBADR,
2016 EXFULL,
2017 ENOANO,
2018 EBADRQC,
2019 EBADSLT,
2020 EBFONT,
2021 ENOSTR,
2022 ENODATA,
2023 ETIME,
2024 ENOSR,
2025 ENONET,
2026 ENOPKG,
2027 EREMOTE,
2028 ENOLINK,
2029 EADV,
2030 ESRMNT,
2031 ECOMM,
2032 EPROTO,
2033 EMULTIHOP,
2034 EDOTDOT,
2035 EBADMSG,
2036 EOVERFLOW,
2037 ENOTUNIQ,
2038 EBADFD,
2039 EREMCHG,
2040 ELIBACC,
2041 ELIBBAD,
2042 ELIBSCN,
2043 ELIBMAX,
2044 ELIBEXEC,
2045 EILSEQ,
2046 ERESTART,
2047 ESTRPIPE,
2048 EUSERS,
2049 EOPNOTSUPP,
2050 ESTALE,
2051 EUCLEAN,
2052 ENOTNAM,
2053 ENAVAIL,
2054 EISNAM,
2055 EREMOTEIO,
2056 EDQUOT,
2057 ENOMEDIUM,
2058 EMEDIUMTYPE,
2059 ECANCELED,
2060 ENOKEY,
2061 EKEYEXPIRED,
2062 EKEYREVOKED,
2063 EKEYREJECTED,
2064 EOWNERDEAD,
2065 ENOTRECOVERABLE);
2066 }
2067
2068 #[test]
2069 #[cfg(all(target_os = "linux", not(target_arch = "mips")))]
test_linux_not_android_errnos()2070 pub fn test_linux_not_android_errnos() {
2071 check_errno!(
2072 ERFKILL /*,
2073 EHWPOISON */);
2074 }
2075
2076 #[test]
2077 #[cfg(target_os = "freebsd")]
test_freebsd_errnos()2078 pub fn test_freebsd_errnos() {
2079 check_errno!(
2080 EDOOFUS,
2081 EMULTIHOP,
2082 ENOLINK,
2083 ENOTCAPABLE,
2084 ECAPMODE,
2085 ENEEDAUTH,
2086 EOVERFLOW,
2087 EILSEQ,
2088 ENOATTR,
2089 EBADMSG,
2090 EPROTO,
2091 ENOTRECOVERABLE,
2092 EOWNERDEAD,
2093 ENOTSUP,
2094 EPROCLIM,
2095 EUSERS,
2096 EDQUOT,
2097 ESTALE,
2098 EREMOTE,
2099 EBADRPC,
2100 ERPCMISMATCH,
2101 EPROGUNAVAIL,
2102 EPROGMISMATCH,
2103 EPROCUNAVAIL,
2104 EAUTH);
2105 }
2106
2107 #[test]
2108 #[cfg(target_os = "dragonfly")]
test_dragonfly_errnos()2109 pub fn test_dragonfly_errnos() {
2110 check_errno!(
2111 EDOOFUS,
2112 EMULTIHOP,
2113 ENOLINK,
2114 ENEEDAUTH,
2115 EOVERFLOW,
2116 EILSEQ,
2117 ENOATTR,
2118 EBADMSG,
2119 EPROTO,
2120 ENOTSUP,
2121 EPROCLIM,
2122 EUSERS,
2123 EDQUOT,
2124 ESTALE,
2125 EREMOTE,
2126 EBADRPC,
2127 ERPCMISMATCH,
2128 EPROGUNAVAIL,
2129 EPROGMISMATCH,
2130 EPROCUNAVAIL,
2131 EAUTH);
2132 }
2133
2134 #[test]
2135 #[cfg(target_os = "openbsd")]
test_openbsd_errnos()2136 pub fn test_openbsd_errnos() {
2137 check_errno!(
2138 EADDRINUSE,
2139 EADDRNOTAVAIL,
2140 EAFNOSUPPORT,
2141 EALREADY,
2142 EAUTH,
2143 EBADRPC,
2144 ECANCELED,
2145 ECONNABORTED,
2146 ECONNREFUSED,
2147 ECONNRESET,
2148 EDESTADDRREQ,
2149 EDQUOT,
2150 EFTYPE,
2151 EHOSTDOWN,
2152 EHOSTUNREACH,
2153 EILSEQ,
2154 EINPROGRESS,
2155 EIPSEC,
2156 EISCONN,
2157 EMEDIUMTYPE,
2158 EMSGSIZE,
2159 ENEEDAUTH,
2160 ENETDOWN,
2161 ENETRESET,
2162 ENETUNREACH,
2163 ENOATTR,
2164 ENOBUFS,
2165 ENOMEDIUM,
2166 ENOPROTOOPT,
2167 ENOTCONN,
2168 ENOTSOCK,
2169 ENOTSUP,
2170 EOPNOTSUPP,
2171 EOVERFLOW,
2172 EPFNOSUPPORT,
2173 EPROCLIM,
2174 EPROCUNAVAIL,
2175 EPROGMISMATCH,
2176 EPROGUNAVAIL,
2177 EPROTONOSUPPORT,
2178 EPROTOTYPE,
2179 EREMOTE,
2180 ESHUTDOWN,
2181 ESOCKTNOSUPPORT,
2182 ESTALE,
2183 ETIMEDOUT,
2184 ETOOMANYREFS,
2185 EUSERS);
2186 }
2187
2188 #[test]
2189 #[cfg(any(target_os = "macos", target_os = "ios"))]
test_darwin_errnos()2190 pub fn test_darwin_errnos() {
2191 check_errno!(
2192 ENOTSUP,
2193 EPROCLIM,
2194 EUSERS,
2195 EDQUOT,
2196 ESTALE,
2197 EREMOTE,
2198 EBADRPC,
2199 ERPCMISMATCH,
2200 EPROGUNAVAIL,
2201 EPROGMISMATCH,
2202 EPROCUNAVAIL,
2203 EFTYPE,
2204 EAUTH,
2205 ENEEDAUTH,
2206 EPWROFF,
2207 EDEVERR,
2208 EOVERFLOW,
2209 EBADEXEC,
2210 EBADARCH,
2211 ESHLIBVERS,
2212 EBADMACHO,
2213 ECANCELED,
2214 EILSEQ,
2215 ENOATTR,
2216 EBADMSG,
2217 EMULTIHOP,
2218 ENODATA,
2219 ENOLINK,
2220 ENOSR,
2221 ENOSTR,
2222 EPROTO,
2223 ETIME,
2224 EOPNOTSUPP,
2225 ENOPOLICY,
2226 ENOTRECOVERABLE,
2227 EOWNERDEAD,
2228 EQFULL
2229 );
2230 }
2231 }
2232