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