1use crate::{Error, Result};
2use cfg_if::cfg_if;
3use libc::{c_int, c_void};
4use std::convert::TryFrom;
5use std::{error, fmt, io};
6
7pub use self::consts::*;
8
9cfg_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(any(target_os = "android",
17 target_os = "netbsd",
18 target_os = "openbsd"))] {
19 unsafe fn errno_location() -> *mut c_int {
20 libc::__errno()
21 }
22 } else if #[cfg(any(target_os = "linux",
23 target_os = "redox",
24 target_os = "dragonfly",
25 target_os = "fuchsia"))] {
26 unsafe fn errno_location() -> *mut c_int {
27 libc::__errno_location()
28 }
29 } else if #[cfg(any(target_os = "illumos", target_os = "solaris"))] {
30 unsafe fn errno_location() -> *mut c_int {
31 libc::___errno()
32 }
33 } else if #[cfg(any(target_os = "haiku",))] {
34 unsafe fn errno_location() -> *mut c_int {
35 libc::_errnop()
36 }
37 }
38}
39
40fn clear() {
42 unsafe {
44 *errno_location() = 0;
45 }
46}
47
48pub fn errno() -> i32 {
50 unsafe { *errno_location() }
51}
52
53impl Errno {
54 #[deprecated(since = "0.22.0", note = "It's a no-op now; just delete it.")]
65 pub const fn as_errno(self) -> Option<Self> {
66 Some(self)
67 }
68
69 #[deprecated(since = "0.22.0", note = "It's a no-op now; just delete it.")]
71 #[allow(clippy::wrong_self_convention)] pub fn from_errno(errno: Errno) -> Error {
73 errno
74 }
75
76 #[deprecated(since = "0.22.0", note = "Use Errno::EINVAL instead")]
78 pub const fn invalid_argument() -> Error {
79 Errno::EINVAL
80 }
81
82 pub fn last() -> Self {
83 last()
84 }
85
86 pub fn desc(self) -> &'static str {
87 desc(self)
88 }
89
90 pub const fn from_i32(err: i32) -> Errno {
91 from_i32(err)
92 }
93
94 pub fn clear() {
95 clear()
96 }
97
98 #[inline]
101 pub fn result<S: ErrnoSentinel + PartialEq<S>>(value: S) -> Result<S> {
102 if value == S::sentinel() {
103 Err(Self::last())
104 } else {
105 Ok(value)
106 }
107 }
108
109 #[deprecated(since = "0.22.0", note = "Use Errno::... instead")]
115 #[allow(non_snake_case)]
116 #[inline]
117 pub const fn Sys(errno: Errno) -> Error {
118 errno
119 }
120}
121
122pub trait ErrnoSentinel: Sized {
125 fn sentinel() -> Self;
126}
127
128impl ErrnoSentinel for isize {
129 fn sentinel() -> Self {
130 -1
131 }
132}
133
134impl ErrnoSentinel for i32 {
135 fn sentinel() -> Self {
136 -1
137 }
138}
139
140impl ErrnoSentinel for i64 {
141 fn sentinel() -> Self {
142 -1
143 }
144}
145
146impl ErrnoSentinel for *mut c_void {
147 fn sentinel() -> Self {
148 -1isize as *mut c_void
149 }
150}
151
152impl ErrnoSentinel for libc::sighandler_t {
153 fn sentinel() -> Self {
154 libc::SIG_ERR
155 }
156}
157
158impl error::Error for Errno {}
159
160impl fmt::Display for Errno {
161 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
162 write!(f, "{:?}: {}", self, self.desc())
163 }
164}
165
166impl From<Errno> for io::Error {
167 fn from(err: Errno) -> Self {
168 io::Error::from_raw_os_error(err as i32)
169 }
170}
171
172impl TryFrom<io::Error> for Errno {
173 type Error = io::Error;
174
175 fn try_from(ioerror: io::Error) -> std::result::Result<Self, io::Error> {
176 ioerror.raw_os_error().map(Errno::from_i32).ok_or(ioerror)
177 }
178}
179
180fn last() -> Errno {
181 Errno::from_i32(errno())
182}
183
184fn desc(errno: Errno) -> &'static str {
185 use self::Errno::*;
186 match errno {
187 UnknownErrno => "Unknown errno",
188 EPERM => "Operation not permitted",
189 ENOENT => "No such file or directory",
190 ESRCH => "No such process",
191 EINTR => "Interrupted system call",
192 EIO => "I/O error",
193 ENXIO => "No such device or address",
194 E2BIG => "Argument list too long",
195 ENOEXEC => "Exec format error",
196 EBADF => "Bad file number",
197 ECHILD => "No child processes",
198 EAGAIN => "Try again",
199 ENOMEM => "Out of memory",
200 EACCES => "Permission denied",
201 EFAULT => "Bad address",
202 #[cfg(not(target_os = "haiku"))]
203 ENOTBLK => "Block device required",
204 EBUSY => "Device or resource busy",
205 EEXIST => "File exists",
206 EXDEV => "Cross-device link",
207 ENODEV => "No such device",
208 ENOTDIR => "Not a directory",
209 EISDIR => "Is a directory",
210 EINVAL => "Invalid argument",
211 ENFILE => "File table overflow",
212 EMFILE => "Too many open files",
213 ENOTTY => "Not a typewriter",
214 ETXTBSY => "Text file busy",
215 EFBIG => "File too large",
216 ENOSPC => "No space left on device",
217 ESPIPE => "Illegal seek",
218 EROFS => "Read-only file system",
219 EMLINK => "Too many links",
220 EPIPE => "Broken pipe",
221 EDOM => "Math argument out of domain of func",
222 ERANGE => "Math result not representable",
223 EDEADLK => "Resource deadlock would occur",
224 ENAMETOOLONG => "File name too long",
225 ENOLCK => "No record locks available",
226 ENOSYS => "Function not implemented",
227 ENOTEMPTY => "Directory not empty",
228 ELOOP => "Too many symbolic links encountered",
229 ENOMSG => "No message of desired type",
230 EIDRM => "Identifier removed",
231 EINPROGRESS => "Operation now in progress",
232 EALREADY => "Operation already in progress",
233 ENOTSOCK => "Socket operation on non-socket",
234 EDESTADDRREQ => "Destination address required",
235 EMSGSIZE => "Message too long",
236 EPROTOTYPE => "Protocol wrong type for socket",
237 ENOPROTOOPT => "Protocol not available",
238 EPROTONOSUPPORT => "Protocol not supported",
239 #[cfg(not(target_os = "haiku"))]
240 ESOCKTNOSUPPORT => "Socket type not supported",
241 #[cfg(not(target_os = "haiku"))]
242 EPFNOSUPPORT => "Protocol family not supported",
243 #[cfg(not(target_os = "haiku"))]
244 EAFNOSUPPORT => "Address family not supported by protocol",
245 EADDRINUSE => "Address already in use",
246 EADDRNOTAVAIL => "Cannot assign requested address",
247 ENETDOWN => "Network is down",
248 ENETUNREACH => "Network is unreachable",
249 ENETRESET => "Network dropped connection because of reset",
250 ECONNABORTED => "Software caused connection abort",
251 ECONNRESET => "Connection reset by peer",
252 ENOBUFS => "No buffer space available",
253 EISCONN => "Transport endpoint is already connected",
254 ENOTCONN => "Transport endpoint is not connected",
255 ESHUTDOWN => "Cannot send after transport endpoint shutdown",
256 #[cfg(not(target_os = "haiku"))]
257 ETOOMANYREFS => "Too many references: cannot splice",
258 ETIMEDOUT => "Connection timed out",
259 ECONNREFUSED => "Connection refused",
260 EHOSTDOWN => "Host is down",
261 EHOSTUNREACH => "No route to host",
262
263 #[cfg(any(
264 target_os = "linux",
265 target_os = "android",
266 target_os = "illumos",
267 target_os = "solaris",
268 target_os = "fuchsia"
269 ))]
270 ECHRNG => "Channel number out of range",
271
272 #[cfg(any(
273 target_os = "linux",
274 target_os = "android",
275 target_os = "illumos",
276 target_os = "solaris",
277 target_os = "fuchsia"
278 ))]
279 EL2NSYNC => "Level 2 not synchronized",
280
281 #[cfg(any(
282 target_os = "linux",
283 target_os = "android",
284 target_os = "illumos",
285 target_os = "solaris",
286 target_os = "fuchsia"
287 ))]
288 EL3HLT => "Level 3 halted",
289
290 #[cfg(any(
291 target_os = "linux",
292 target_os = "android",
293 target_os = "illumos",
294 target_os = "solaris",
295 target_os = "fuchsia"
296 ))]
297 EL3RST => "Level 3 reset",
298
299 #[cfg(any(
300 target_os = "linux",
301 target_os = "android",
302 target_os = "illumos",
303 target_os = "solaris",
304 target_os = "fuchsia"
305 ))]
306 ELNRNG => "Link number out of range",
307
308 #[cfg(any(
309 target_os = "linux",
310 target_os = "android",
311 target_os = "illumos",
312 target_os = "solaris",
313 target_os = "fuchsia"
314 ))]
315 EUNATCH => "Protocol driver not attached",
316
317 #[cfg(any(
318 target_os = "linux",
319 target_os = "android",
320 target_os = "illumos",
321 target_os = "solaris",
322 target_os = "fuchsia"
323 ))]
324 ENOCSI => "No CSI structure available",
325
326 #[cfg(any(
327 target_os = "linux",
328 target_os = "android",
329 target_os = "illumos",
330 target_os = "solaris",
331 target_os = "fuchsia"
332 ))]
333 EL2HLT => "Level 2 halted",
334
335 #[cfg(any(
336 target_os = "linux",
337 target_os = "android",
338 target_os = "illumos",
339 target_os = "solaris",
340 target_os = "fuchsia"
341 ))]
342 EBADE => "Invalid exchange",
343
344 #[cfg(any(
345 target_os = "linux",
346 target_os = "android",
347 target_os = "illumos",
348 target_os = "solaris",
349 target_os = "fuchsia"
350 ))]
351 EBADR => "Invalid request descriptor",
352
353 #[cfg(any(
354 target_os = "linux",
355 target_os = "android",
356 target_os = "illumos",
357 target_os = "solaris",
358 target_os = "fuchsia"
359 ))]
360 EXFULL => "Exchange full",
361
362 #[cfg(any(
363 target_os = "linux",
364 target_os = "android",
365 target_os = "illumos",
366 target_os = "solaris",
367 target_os = "fuchsia"
368 ))]
369 ENOANO => "No anode",
370
371 #[cfg(any(
372 target_os = "linux",
373 target_os = "android",
374 target_os = "illumos",
375 target_os = "solaris",
376 target_os = "fuchsia"
377 ))]
378 EBADRQC => "Invalid request code",
379
380 #[cfg(any(
381 target_os = "linux",
382 target_os = "android",
383 target_os = "illumos",
384 target_os = "solaris",
385 target_os = "fuchsia"
386 ))]
387 EBADSLT => "Invalid slot",
388
389 #[cfg(any(
390 target_os = "linux",
391 target_os = "android",
392 target_os = "illumos",
393 target_os = "solaris",
394 target_os = "fuchsia"
395 ))]
396 EBFONT => "Bad font file format",
397
398 #[cfg(any(
399 target_os = "linux",
400 target_os = "android",
401 target_os = "illumos",
402 target_os = "solaris",
403 target_os = "fuchsia"
404 ))]
405 ENOSTR => "Device not a stream",
406
407 #[cfg(any(
408 target_os = "linux",
409 target_os = "android",
410 target_os = "illumos",
411 target_os = "solaris",
412 target_os = "fuchsia"
413 ))]
414 ENODATA => "No data available",
415
416 #[cfg(any(
417 target_os = "linux",
418 target_os = "android",
419 target_os = "illumos",
420 target_os = "solaris",
421 target_os = "fuchsia"
422 ))]
423 ETIME => "Timer expired",
424
425 #[cfg(any(
426 target_os = "linux",
427 target_os = "android",
428 target_os = "illumos",
429 target_os = "solaris",
430 target_os = "fuchsia"
431 ))]
432 ENOSR => "Out of streams resources",
433
434 #[cfg(any(
435 target_os = "linux",
436 target_os = "android",
437 target_os = "illumos",
438 target_os = "solaris",
439 target_os = "fuchsia"
440 ))]
441 ENONET => "Machine is not on the network",
442
443 #[cfg(any(
444 target_os = "linux",
445 target_os = "android",
446 target_os = "illumos",
447 target_os = "solaris",
448 target_os = "fuchsia"
449 ))]
450 ENOPKG => "Package not installed",
451
452 #[cfg(any(
453 target_os = "linux",
454 target_os = "android",
455 target_os = "illumos",
456 target_os = "solaris",
457 target_os = "fuchsia"
458 ))]
459 EREMOTE => "Object is remote",
460
461 #[cfg(any(
462 target_os = "linux",
463 target_os = "android",
464 target_os = "illumos",
465 target_os = "solaris",
466 target_os = "fuchsia"
467 ))]
468 ENOLINK => "Link has been severed",
469
470 #[cfg(any(
471 target_os = "linux",
472 target_os = "android",
473 target_os = "illumos",
474 target_os = "solaris",
475 target_os = "fuchsia"
476 ))]
477 EADV => "Advertise error",
478
479 #[cfg(any(
480 target_os = "linux",
481 target_os = "android",
482 target_os = "illumos",
483 target_os = "solaris",
484 target_os = "fuchsia"
485 ))]
486 ESRMNT => "Srmount error",
487
488 #[cfg(any(
489 target_os = "linux",
490 target_os = "android",
491 target_os = "illumos",
492 target_os = "solaris",
493 target_os = "fuchsia"
494 ))]
495 ECOMM => "Communication error on send",
496
497 #[cfg(any(
498 target_os = "linux",
499 target_os = "android",
500 target_os = "illumos",
501 target_os = "solaris",
502 target_os = "fuchsia"
503 ))]
504 EPROTO => "Protocol error",
505
506 #[cfg(any(
507 target_os = "linux",
508 target_os = "android",
509 target_os = "illumos",
510 target_os = "solaris",
511 target_os = "fuchsia"
512 ))]
513 EMULTIHOP => "Multihop attempted",
514
515 #[cfg(any(
516 target_os = "linux",
517 target_os = "android",
518 target_os = "fuchsia"
519 ))]
520 EDOTDOT => "RFS specific error",
521
522 #[cfg(any(
523 target_os = "linux",
524 target_os = "android",
525 target_os = "fuchsia"
526 ))]
527 EBADMSG => "Not a data message",
528
529 #[cfg(any(target_os = "illumos", target_os = "solaris"))]
530 EBADMSG => "Trying to read unreadable message",
531
532 #[cfg(any(
533 target_os = "linux",
534 target_os = "android",
535 target_os = "fuchsia",
536 target_os = "haiku"
537 ))]
538 EOVERFLOW => "Value too large for defined data type",
539
540 #[cfg(any(
541 target_os = "linux",
542 target_os = "android",
543 target_os = "illumos",
544 target_os = "solaris",
545 target_os = "fuchsia"
546 ))]
547 ENOTUNIQ => "Name not unique on network",
548
549 #[cfg(any(
550 target_os = "linux",
551 target_os = "android",
552 target_os = "illumos",
553 target_os = "solaris",
554 target_os = "fuchsia"
555 ))]
556 EBADFD => "File descriptor in bad state",
557
558 #[cfg(any(
559 target_os = "linux",
560 target_os = "android",
561 target_os = "illumos",
562 target_os = "solaris",
563 target_os = "fuchsia"
564 ))]
565 EREMCHG => "Remote address changed",
566
567 #[cfg(any(
568 target_os = "linux",
569 target_os = "android",
570 target_os = "illumos",
571 target_os = "solaris",
572 target_os = "fuchsia"
573 ))]
574 ELIBACC => "Can not access a needed shared library",
575
576 #[cfg(any(
577 target_os = "linux",
578 target_os = "android",
579 target_os = "illumos",
580 target_os = "solaris",
581 target_os = "fuchsia"
582 ))]
583 ELIBBAD => "Accessing a corrupted shared library",
584
585 #[cfg(any(
586 target_os = "linux",
587 target_os = "android",
588 target_os = "illumos",
589 target_os = "solaris",
590 target_os = "fuchsia"
591 ))]
592 ELIBSCN => ".lib section in a.out corrupted",
593
594 #[cfg(any(
595 target_os = "linux",
596 target_os = "android",
597 target_os = "illumos",
598 target_os = "solaris",
599 target_os = "fuchsia"
600 ))]
601 ELIBMAX => "Attempting to link in too many shared libraries",
602
603 #[cfg(any(
604 target_os = "linux",
605 target_os = "android",
606 target_os = "illumos",
607 target_os = "solaris",
608 target_os = "fuchsia"
609 ))]
610 ELIBEXEC => "Cannot exec a shared library directly",
611
612 #[cfg(any(
613 target_os = "linux",
614 target_os = "android",
615 target_os = "illumos",
616 target_os = "solaris",
617 target_os = "fuchsia",
618 target_os = "openbsd"
619 ))]
620 EILSEQ => "Illegal byte sequence",
621
622 #[cfg(any(
623 target_os = "linux",
624 target_os = "android",
625 target_os = "illumos",
626 target_os = "solaris",
627 target_os = "fuchsia"
628 ))]
629 ERESTART => "Interrupted system call should be restarted",
630
631 #[cfg(any(
632 target_os = "linux",
633 target_os = "android",
634 target_os = "illumos",
635 target_os = "solaris",
636 target_os = "fuchsia"
637 ))]
638 ESTRPIPE => "Streams pipe error",
639
640 #[cfg(any(
641 target_os = "linux",
642 target_os = "android",
643 target_os = "illumos",
644 target_os = "solaris",
645 target_os = "fuchsia"
646 ))]
647 EUSERS => "Too many users",
648
649 #[cfg(any(
650 target_os = "linux",
651 target_os = "android",
652 target_os = "fuchsia",
653 target_os = "netbsd",
654 target_os = "redox"
655 ))]
656 EOPNOTSUPP => "Operation not supported on transport endpoint",
657
658 #[cfg(any(
659 target_os = "linux",
660 target_os = "android",
661 target_os = "fuchsia"
662 ))]
663 ESTALE => "Stale file handle",
664
665 #[cfg(any(
666 target_os = "linux",
667 target_os = "android",
668 target_os = "fuchsia"
669 ))]
670 EUCLEAN => "Structure needs cleaning",
671
672 #[cfg(any(
673 target_os = "linux",
674 target_os = "android",
675 target_os = "fuchsia"
676 ))]
677 ENOTNAM => "Not a XENIX named type file",
678
679 #[cfg(any(
680 target_os = "linux",
681 target_os = "android",
682 target_os = "fuchsia"
683 ))]
684 ENAVAIL => "No XENIX semaphores available",
685
686 #[cfg(any(
687 target_os = "linux",
688 target_os = "android",
689 target_os = "fuchsia"
690 ))]
691 EISNAM => "Is a named type file",
692
693 #[cfg(any(
694 target_os = "linux",
695 target_os = "android",
696 target_os = "fuchsia"
697 ))]
698 EREMOTEIO => "Remote I/O error",
699
700 #[cfg(any(
701 target_os = "linux",
702 target_os = "android",
703 target_os = "fuchsia"
704 ))]
705 EDQUOT => "Quota exceeded",
706
707 #[cfg(any(
708 target_os = "linux",
709 target_os = "android",
710 target_os = "fuchsia",
711 target_os = "openbsd",
712 target_os = "dragonfly"
713 ))]
714 ENOMEDIUM => "No medium found",
715
716 #[cfg(any(
717 target_os = "linux",
718 target_os = "android",
719 target_os = "fuchsia",
720 target_os = "openbsd"
721 ))]
722 EMEDIUMTYPE => "Wrong medium type",
723
724 #[cfg(any(
725 target_os = "linux",
726 target_os = "android",
727 target_os = "illumos",
728 target_os = "solaris",
729 target_os = "fuchsia",
730 target_os = "haiku"
731 ))]
732 ECANCELED => "Operation canceled",
733
734 #[cfg(any(
735 target_os = "linux",
736 target_os = "android",
737 target_os = "fuchsia"
738 ))]
739 ENOKEY => "Required key not available",
740
741 #[cfg(any(
742 target_os = "linux",
743 target_os = "android",
744 target_os = "fuchsia"
745 ))]
746 EKEYEXPIRED => "Key has expired",
747
748 #[cfg(any(
749 target_os = "linux",
750 target_os = "android",
751 target_os = "fuchsia"
752 ))]
753 EKEYREVOKED => "Key has been revoked",
754
755 #[cfg(any(
756 target_os = "linux",
757 target_os = "android",
758 target_os = "fuchsia"
759 ))]
760 EKEYREJECTED => "Key was rejected by service",
761
762 #[cfg(any(
763 target_os = "linux",
764 target_os = "android",
765 target_os = "fuchsia"
766 ))]
767 EOWNERDEAD => "Owner died",
768
769 #[cfg(any(target_os = "illumos", target_os = "solaris"))]
770 EOWNERDEAD => "Process died with lock",
771
772 #[cfg(any(
773 target_os = "linux",
774 target_os = "android",
775 target_os = "fuchsia"
776 ))]
777 ENOTRECOVERABLE => "State not recoverable",
778
779 #[cfg(any(target_os = "illumos", target_os = "solaris"))]
780 ENOTRECOVERABLE => "Lock is not recoverable",
781
782 #[cfg(any(
783 all(target_os = "linux", not(target_arch = "mips")),
784 target_os = "fuchsia"
785 ))]
786 ERFKILL => "Operation not possible due to RF-kill",
787
788 #[cfg(any(
789 all(target_os = "linux", not(target_arch = "mips")),
790 target_os = "fuchsia"
791 ))]
792 EHWPOISON => "Memory page has hardware error",
793
794 #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
795 EDOOFUS => "Programming error",
796
797 #[cfg(any(
798 target_os = "freebsd",
799 target_os = "dragonfly",
800 target_os = "redox"
801 ))]
802 EMULTIHOP => "Multihop attempted",
803
804 #[cfg(any(
805 target_os = "freebsd",
806 target_os = "dragonfly",
807 target_os = "redox"
808 ))]
809 ENOLINK => "Link has been severed",
810
811 #[cfg(target_os = "freebsd")]
812 ENOTCAPABLE => "Capabilities insufficient",
813
814 #[cfg(target_os = "freebsd")]
815 ECAPMODE => "Not permitted in capability mode",
816
817 #[cfg(any(
818 target_os = "macos",
819 target_os = "freebsd",
820 target_os = "dragonfly",
821 target_os = "ios",
822 target_os = "openbsd",
823 target_os = "netbsd"
824 ))]
825 ENEEDAUTH => "Need authenticator",
826
827 #[cfg(any(
828 target_os = "macos",
829 target_os = "freebsd",
830 target_os = "dragonfly",
831 target_os = "ios",
832 target_os = "openbsd",
833 target_os = "netbsd",
834 target_os = "redox",
835 target_os = "illumos",
836 target_os = "solaris"
837 ))]
838 EOVERFLOW => "Value too large to be stored in data type",
839
840 #[cfg(any(
841 target_os = "macos",
842 target_os = "freebsd",
843 target_os = "dragonfly",
844 target_os = "ios",
845 target_os = "netbsd",
846 target_os = "redox",
847 target_os = "haiku"
848 ))]
849 EILSEQ => "Illegal byte sequence",
850
851 #[cfg(any(
852 target_os = "macos",
853 target_os = "freebsd",
854 target_os = "dragonfly",
855 target_os = "ios",
856 target_os = "openbsd",
857 target_os = "netbsd",
858 target_os = "haiku"
859 ))]
860 ENOATTR => "Attribute not found",
861
862 #[cfg(any(
863 target_os = "macos",
864 target_os = "freebsd",
865 target_os = "dragonfly",
866 target_os = "ios",
867 target_os = "openbsd",
868 target_os = "netbsd",
869 target_os = "redox",
870 target_os = "haiku"
871 ))]
872 EBADMSG => "Bad message",
873
874 #[cfg(any(
875 target_os = "macos",
876 target_os = "freebsd",
877 target_os = "dragonfly",
878 target_os = "ios",
879 target_os = "openbsd",
880 target_os = "netbsd",
881 target_os = "redox",
882 target_os = "haiku"
883 ))]
884 EPROTO => "Protocol error",
885
886 #[cfg(any(
887 target_os = "macos",
888 target_os = "freebsd",
889 target_os = "dragonfly",
890 target_os = "ios",
891 target_os = "openbsd"
892 ))]
893 ENOTRECOVERABLE => "State not recoverable",
894
895 #[cfg(any(
896 target_os = "macos",
897 target_os = "freebsd",
898 target_os = "dragonfly",
899 target_os = "ios",
900 target_os = "openbsd"
901 ))]
902 EOWNERDEAD => "Previous owner died",
903
904 #[cfg(any(
905 target_os = "macos",
906 target_os = "freebsd",
907 target_os = "dragonfly",
908 target_os = "ios",
909 target_os = "openbsd",
910 target_os = "netbsd",
911 target_os = "illumos",
912 target_os = "solaris",
913 target_os = "haiku"
914 ))]
915 ENOTSUP => "Operation not supported",
916
917 #[cfg(any(
918 target_os = "macos",
919 target_os = "freebsd",
920 target_os = "dragonfly",
921 target_os = "ios",
922 target_os = "openbsd",
923 target_os = "netbsd"
924 ))]
925 EPROCLIM => "Too many processes",
926
927 #[cfg(any(
928 target_os = "macos",
929 target_os = "freebsd",
930 target_os = "dragonfly",
931 target_os = "ios",
932 target_os = "openbsd",
933 target_os = "netbsd",
934 target_os = "redox"
935 ))]
936 EUSERS => "Too many users",
937
938 #[cfg(any(
939 target_os = "macos",
940 target_os = "freebsd",
941 target_os = "dragonfly",
942 target_os = "ios",
943 target_os = "openbsd",
944 target_os = "netbsd",
945 target_os = "redox",
946 target_os = "illumos",
947 target_os = "solaris",
948 target_os = "haiku"
949 ))]
950 EDQUOT => "Disc quota exceeded",
951
952 #[cfg(any(
953 target_os = "macos",
954 target_os = "freebsd",
955 target_os = "dragonfly",
956 target_os = "ios",
957 target_os = "openbsd",
958 target_os = "netbsd",
959 target_os = "redox",
960 target_os = "illumos",
961 target_os = "solaris",
962 target_os = "haiku"
963 ))]
964 ESTALE => "Stale NFS file handle",
965
966 #[cfg(any(
967 target_os = "macos",
968 target_os = "freebsd",
969 target_os = "dragonfly",
970 target_os = "ios",
971 target_os = "openbsd",
972 target_os = "netbsd",
973 target_os = "redox"
974 ))]
975 EREMOTE => "Too many levels of remote in path",
976
977 #[cfg(any(
978 target_os = "macos",
979 target_os = "freebsd",
980 target_os = "dragonfly",
981 target_os = "ios",
982 target_os = "openbsd",
983 target_os = "netbsd"
984 ))]
985 EBADRPC => "RPC struct is bad",
986
987 #[cfg(any(
988 target_os = "macos",
989 target_os = "freebsd",
990 target_os = "dragonfly",
991 target_os = "ios",
992 target_os = "openbsd",
993 target_os = "netbsd"
994 ))]
995 ERPCMISMATCH => "RPC version wrong",
996
997 #[cfg(any(
998 target_os = "macos",
999 target_os = "freebsd",
1000 target_os = "dragonfly",
1001 target_os = "ios",
1002 target_os = "openbsd",
1003 target_os = "netbsd"
1004 ))]
1005 EPROGUNAVAIL => "RPC prog. not avail",
1006
1007 #[cfg(any(
1008 target_os = "macos",
1009 target_os = "freebsd",
1010 target_os = "dragonfly",
1011 target_os = "ios",
1012 target_os = "openbsd",
1013 target_os = "netbsd"
1014 ))]
1015 EPROGMISMATCH => "Program version wrong",
1016
1017 #[cfg(any(
1018 target_os = "macos",
1019 target_os = "freebsd",
1020 target_os = "dragonfly",
1021 target_os = "ios",
1022 target_os = "openbsd",
1023 target_os = "netbsd"
1024 ))]
1025 EPROCUNAVAIL => "Bad procedure for program",
1026
1027 #[cfg(any(
1028 target_os = "macos",
1029 target_os = "freebsd",
1030 target_os = "dragonfly",
1031 target_os = "ios",
1032 target_os = "openbsd",
1033 target_os = "netbsd"
1034 ))]
1035 EFTYPE => "Inappropriate file type or format",
1036
1037 #[cfg(any(
1038 target_os = "macos",
1039 target_os = "freebsd",
1040 target_os = "dragonfly",
1041 target_os = "ios",
1042 target_os = "openbsd",
1043 target_os = "netbsd"
1044 ))]
1045 EAUTH => "Authentication error",
1046
1047 #[cfg(any(
1048 target_os = "macos",
1049 target_os = "freebsd",
1050 target_os = "dragonfly",
1051 target_os = "ios",
1052 target_os = "openbsd",
1053 target_os = "netbsd",
1054 target_os = "redox"
1055 ))]
1056 ECANCELED => "Operation canceled",
1057
1058 #[cfg(any(target_os = "macos", target_os = "ios"))]
1059 EPWROFF => "Device power is off",
1060
1061 #[cfg(any(target_os = "macos", target_os = "ios"))]
1062 EDEVERR => "Device error, e.g. paper out",
1063
1064 #[cfg(any(target_os = "macos", target_os = "ios"))]
1065 EBADEXEC => "Bad executable",
1066
1067 #[cfg(any(target_os = "macos", target_os = "ios"))]
1068 EBADARCH => "Bad CPU type in executable",
1069
1070 #[cfg(any(target_os = "macos", target_os = "ios"))]
1071 ESHLIBVERS => "Shared library version mismatch",
1072
1073 #[cfg(any(target_os = "macos", target_os = "ios"))]
1074 EBADMACHO => "Malformed Macho file",
1075
1076 #[cfg(any(
1077 target_os = "macos",
1078 target_os = "ios",
1079 target_os = "netbsd",
1080 target_os = "haiku"
1081 ))]
1082 EMULTIHOP => "Reserved",
1083
1084 #[cfg(any(
1085 target_os = "macos",
1086 target_os = "ios",
1087 target_os = "netbsd",
1088 target_os = "redox"
1089 ))]
1090 ENODATA => "No message available on STREAM",
1091
1092 #[cfg(any(
1093 target_os = "macos",
1094 target_os = "ios",
1095 target_os = "netbsd",
1096 target_os = "haiku"
1097 ))]
1098 ENOLINK => "Reserved",
1099
1100 #[cfg(any(
1101 target_os = "macos",
1102 target_os = "ios",
1103 target_os = "netbsd",
1104 target_os = "redox"
1105 ))]
1106 ENOSR => "No STREAM resources",
1107
1108 #[cfg(any(
1109 target_os = "macos",
1110 target_os = "ios",
1111 target_os = "netbsd",
1112 target_os = "redox"
1113 ))]
1114 ENOSTR => "Not a STREAM",
1115
1116 #[cfg(any(
1117 target_os = "macos",
1118 target_os = "ios",
1119 target_os = "netbsd",
1120 target_os = "redox"
1121 ))]
1122 ETIME => "STREAM ioctl timeout",
1123
1124 #[cfg(any(
1125 target_os = "macos",
1126 target_os = "ios",
1127 target_os = "illumos",
1128 target_os = "solaris"
1129 ))]
1130 EOPNOTSUPP => "Operation not supported on socket",
1131
1132 #[cfg(any(target_os = "macos", target_os = "ios"))]
1133 ENOPOLICY => "No such policy registered",
1134
1135 #[cfg(any(target_os = "macos", target_os = "ios"))]
1136 EQFULL => "Interface output queue is full",
1137
1138 #[cfg(target_os = "openbsd")]
1139 EOPNOTSUPP => "Operation not supported",
1140
1141 #[cfg(target_os = "openbsd")]
1142 EIPSEC => "IPsec processing failure",
1143
1144 #[cfg(target_os = "dragonfly")]
1145 EASYNC => "Async",
1146
1147 #[cfg(any(target_os = "illumos", target_os = "solaris"))]
1148 EDEADLOCK => "Resource deadlock would occur",
1149
1150 #[cfg(any(target_os = "illumos", target_os = "solaris"))]
1151 ELOCKUNMAPPED => "Locked lock was unmapped",
1152
1153 #[cfg(any(target_os = "illumos", target_os = "solaris"))]
1154 ENOTACTIVE => "Facility is not active",
1155 }
1156}
1157
1158#[cfg(any(target_os = "linux", target_os = "android", target_os = "fuchsia"))]
1159mod consts {
1160 #[derive(Clone, Copy, Debug, Eq, PartialEq)]
1161 #[repr(i32)]
1162 #[non_exhaustive]
1163 pub enum Errno {
1164 UnknownErrno = 0,
1165 EPERM = libc::EPERM,
1166 ENOENT = libc::ENOENT,
1167 ESRCH = libc::ESRCH,
1168 EINTR = libc::EINTR,
1169 EIO = libc::EIO,
1170 ENXIO = libc::ENXIO,
1171 E2BIG = libc::E2BIG,
1172 ENOEXEC = libc::ENOEXEC,
1173 EBADF = libc::EBADF,
1174 ECHILD = libc::ECHILD,
1175 EAGAIN = libc::EAGAIN,
1176 ENOMEM = libc::ENOMEM,
1177 EACCES = libc::EACCES,
1178 EFAULT = libc::EFAULT,
1179 ENOTBLK = libc::ENOTBLK,
1180 EBUSY = libc::EBUSY,
1181 EEXIST = libc::EEXIST,
1182 EXDEV = libc::EXDEV,
1183 ENODEV = libc::ENODEV,
1184 ENOTDIR = libc::ENOTDIR,
1185 EISDIR = libc::EISDIR,
1186 EINVAL = libc::EINVAL,
1187 ENFILE = libc::ENFILE,
1188 EMFILE = libc::EMFILE,
1189 ENOTTY = libc::ENOTTY,
1190 ETXTBSY = libc::ETXTBSY,
1191 EFBIG = libc::EFBIG,
1192 ENOSPC = libc::ENOSPC,
1193 ESPIPE = libc::ESPIPE,
1194 EROFS = libc::EROFS,
1195 EMLINK = libc::EMLINK,
1196 EPIPE = libc::EPIPE,
1197 EDOM = libc::EDOM,
1198 ERANGE = libc::ERANGE,
1199 EDEADLK = libc::EDEADLK,
1200 ENAMETOOLONG = libc::ENAMETOOLONG,
1201 ENOLCK = libc::ENOLCK,
1202 ENOSYS = libc::ENOSYS,
1203 ENOTEMPTY = libc::ENOTEMPTY,
1204 ELOOP = libc::ELOOP,
1205 ENOMSG = libc::ENOMSG,
1206 EIDRM = libc::EIDRM,
1207 ECHRNG = libc::ECHRNG,
1208 EL2NSYNC = libc::EL2NSYNC,
1209 EL3HLT = libc::EL3HLT,
1210 EL3RST = libc::EL3RST,
1211 ELNRNG = libc::ELNRNG,
1212 EUNATCH = libc::EUNATCH,
1213 ENOCSI = libc::ENOCSI,
1214 EL2HLT = libc::EL2HLT,
1215 EBADE = libc::EBADE,
1216 EBADR = libc::EBADR,
1217 EXFULL = libc::EXFULL,
1218 ENOANO = libc::ENOANO,
1219 EBADRQC = libc::EBADRQC,
1220 EBADSLT = libc::EBADSLT,
1221 EBFONT = libc::EBFONT,
1222 ENOSTR = libc::ENOSTR,
1223 ENODATA = libc::ENODATA,
1224 ETIME = libc::ETIME,
1225 ENOSR = libc::ENOSR,
1226 ENONET = libc::ENONET,
1227 ENOPKG = libc::ENOPKG,
1228 EREMOTE = libc::EREMOTE,
1229 ENOLINK = libc::ENOLINK,
1230 EADV = libc::EADV,
1231 ESRMNT = libc::ESRMNT,
1232 ECOMM = libc::ECOMM,
1233 EPROTO = libc::EPROTO,
1234 EMULTIHOP = libc::EMULTIHOP,
1235 EDOTDOT = libc::EDOTDOT,
1236 EBADMSG = libc::EBADMSG,
1237 EOVERFLOW = libc::EOVERFLOW,
1238 ENOTUNIQ = libc::ENOTUNIQ,
1239 EBADFD = libc::EBADFD,
1240 EREMCHG = libc::EREMCHG,
1241 ELIBACC = libc::ELIBACC,
1242 ELIBBAD = libc::ELIBBAD,
1243 ELIBSCN = libc::ELIBSCN,
1244 ELIBMAX = libc::ELIBMAX,
1245 ELIBEXEC = libc::ELIBEXEC,
1246 EILSEQ = libc::EILSEQ,
1247 ERESTART = libc::ERESTART,
1248 ESTRPIPE = libc::ESTRPIPE,
1249 EUSERS = libc::EUSERS,
1250 ENOTSOCK = libc::ENOTSOCK,
1251 EDESTADDRREQ = libc::EDESTADDRREQ,
1252 EMSGSIZE = libc::EMSGSIZE,
1253 EPROTOTYPE = libc::EPROTOTYPE,
1254 ENOPROTOOPT = libc::ENOPROTOOPT,
1255 EPROTONOSUPPORT = libc::EPROTONOSUPPORT,
1256 ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT,
1257 EOPNOTSUPP = libc::EOPNOTSUPP,
1258 EPFNOSUPPORT = libc::EPFNOSUPPORT,
1259 EAFNOSUPPORT = libc::EAFNOSUPPORT,
1260 EADDRINUSE = libc::EADDRINUSE,
1261 EADDRNOTAVAIL = libc::EADDRNOTAVAIL,
1262 ENETDOWN = libc::ENETDOWN,
1263 ENETUNREACH = libc::ENETUNREACH,
1264 ENETRESET = libc::ENETRESET,
1265 ECONNABORTED = libc::ECONNABORTED,
1266 ECONNRESET = libc::ECONNRESET,
1267 ENOBUFS = libc::ENOBUFS,
1268 EISCONN = libc::EISCONN,
1269 ENOTCONN = libc::ENOTCONN,
1270 ESHUTDOWN = libc::ESHUTDOWN,
1271 ETOOMANYREFS = libc::ETOOMANYREFS,
1272 ETIMEDOUT = libc::ETIMEDOUT,
1273 ECONNREFUSED = libc::ECONNREFUSED,
1274 EHOSTDOWN = libc::EHOSTDOWN,
1275 EHOSTUNREACH = libc::EHOSTUNREACH,
1276 EALREADY = libc::EALREADY,
1277 EINPROGRESS = libc::EINPROGRESS,
1278 ESTALE = libc::ESTALE,
1279 EUCLEAN = libc::EUCLEAN,
1280 ENOTNAM = libc::ENOTNAM,
1281 ENAVAIL = libc::ENAVAIL,
1282 EISNAM = libc::EISNAM,
1283 EREMOTEIO = libc::EREMOTEIO,
1284 EDQUOT = libc::EDQUOT,
1285 ENOMEDIUM = libc::ENOMEDIUM,
1286 EMEDIUMTYPE = libc::EMEDIUMTYPE,
1287 ECANCELED = libc::ECANCELED,
1288 ENOKEY = libc::ENOKEY,
1289 EKEYEXPIRED = libc::EKEYEXPIRED,
1290 EKEYREVOKED = libc::EKEYREVOKED,
1291 EKEYREJECTED = libc::EKEYREJECTED,
1292 EOWNERDEAD = libc::EOWNERDEAD,
1293 ENOTRECOVERABLE = libc::ENOTRECOVERABLE,
1294 #[cfg(not(any(target_os = "android", target_arch = "mips")))]
1295 ERFKILL = libc::ERFKILL,
1296 #[cfg(not(any(target_os = "android", target_arch = "mips")))]
1297 EHWPOISON = libc::EHWPOISON,
1298 }
1299
1300 #[deprecated(
1301 since = "0.22.1",
1302 note = "use nix::errno::Errno::EWOULDBLOCK instead"
1303 )]
1304 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
1305 #[deprecated(
1306 since = "0.22.1",
1307 note = "use nix::errno::Errno::EDEADLOCK instead"
1308 )]
1309 pub const EDEADLOCK: Errno = Errno::EDEADLK;
1310 #[deprecated(
1311 since = "0.22.1",
1312 note = "use nix::errno::Errno::ENOTSUP instead"
1313 )]
1314 pub const ENOTSUP: Errno = Errno::EOPNOTSUPP;
1315
1316 impl Errno {
1317 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
1318 pub const EDEADLOCK: Errno = Errno::EDEADLK;
1319 pub const ENOTSUP: Errno = Errno::EOPNOTSUPP;
1320 }
1321
1322 pub const fn from_i32(e: i32) -> Errno {
1323 use self::Errno::*;
1324
1325 match e {
1326 libc::EPERM => EPERM,
1327 libc::ENOENT => ENOENT,
1328 libc::ESRCH => ESRCH,
1329 libc::EINTR => EINTR,
1330 libc::EIO => EIO,
1331 libc::ENXIO => ENXIO,
1332 libc::E2BIG => E2BIG,
1333 libc::ENOEXEC => ENOEXEC,
1334 libc::EBADF => EBADF,
1335 libc::ECHILD => ECHILD,
1336 libc::EAGAIN => EAGAIN,
1337 libc::ENOMEM => ENOMEM,
1338 libc::EACCES => EACCES,
1339 libc::EFAULT => EFAULT,
1340 libc::ENOTBLK => ENOTBLK,
1341 libc::EBUSY => EBUSY,
1342 libc::EEXIST => EEXIST,
1343 libc::EXDEV => EXDEV,
1344 libc::ENODEV => ENODEV,
1345 libc::ENOTDIR => ENOTDIR,
1346 libc::EISDIR => EISDIR,
1347 libc::EINVAL => EINVAL,
1348 libc::ENFILE => ENFILE,
1349 libc::EMFILE => EMFILE,
1350 libc::ENOTTY => ENOTTY,
1351 libc::ETXTBSY => ETXTBSY,
1352 libc::EFBIG => EFBIG,
1353 libc::ENOSPC => ENOSPC,
1354 libc::ESPIPE => ESPIPE,
1355 libc::EROFS => EROFS,
1356 libc::EMLINK => EMLINK,
1357 libc::EPIPE => EPIPE,
1358 libc::EDOM => EDOM,
1359 libc::ERANGE => ERANGE,
1360 libc::EDEADLK => EDEADLK,
1361 libc::ENAMETOOLONG => ENAMETOOLONG,
1362 libc::ENOLCK => ENOLCK,
1363 libc::ENOSYS => ENOSYS,
1364 libc::ENOTEMPTY => ENOTEMPTY,
1365 libc::ELOOP => ELOOP,
1366 libc::ENOMSG => ENOMSG,
1367 libc::EIDRM => EIDRM,
1368 libc::ECHRNG => ECHRNG,
1369 libc::EL2NSYNC => EL2NSYNC,
1370 libc::EL3HLT => EL3HLT,
1371 libc::EL3RST => EL3RST,
1372 libc::ELNRNG => ELNRNG,
1373 libc::EUNATCH => EUNATCH,
1374 libc::ENOCSI => ENOCSI,
1375 libc::EL2HLT => EL2HLT,
1376 libc::EBADE => EBADE,
1377 libc::EBADR => EBADR,
1378 libc::EXFULL => EXFULL,
1379 libc::ENOANO => ENOANO,
1380 libc::EBADRQC => EBADRQC,
1381 libc::EBADSLT => EBADSLT,
1382 libc::EBFONT => EBFONT,
1383 libc::ENOSTR => ENOSTR,
1384 libc::ENODATA => ENODATA,
1385 libc::ETIME => ETIME,
1386 libc::ENOSR => ENOSR,
1387 libc::ENONET => ENONET,
1388 libc::ENOPKG => ENOPKG,
1389 libc::EREMOTE => EREMOTE,
1390 libc::ENOLINK => ENOLINK,
1391 libc::EADV => EADV,
1392 libc::ESRMNT => ESRMNT,
1393 libc::ECOMM => ECOMM,
1394 libc::EPROTO => EPROTO,
1395 libc::EMULTIHOP => EMULTIHOP,
1396 libc::EDOTDOT => EDOTDOT,
1397 libc::EBADMSG => EBADMSG,
1398 libc::EOVERFLOW => EOVERFLOW,
1399 libc::ENOTUNIQ => ENOTUNIQ,
1400 libc::EBADFD => EBADFD,
1401 libc::EREMCHG => EREMCHG,
1402 libc::ELIBACC => ELIBACC,
1403 libc::ELIBBAD => ELIBBAD,
1404 libc::ELIBSCN => ELIBSCN,
1405 libc::ELIBMAX => ELIBMAX,
1406 libc::ELIBEXEC => ELIBEXEC,
1407 libc::EILSEQ => EILSEQ,
1408 libc::ERESTART => ERESTART,
1409 libc::ESTRPIPE => ESTRPIPE,
1410 libc::EUSERS => EUSERS,
1411 libc::ENOTSOCK => ENOTSOCK,
1412 libc::EDESTADDRREQ => EDESTADDRREQ,
1413 libc::EMSGSIZE => EMSGSIZE,
1414 libc::EPROTOTYPE => EPROTOTYPE,
1415 libc::ENOPROTOOPT => ENOPROTOOPT,
1416 libc::EPROTONOSUPPORT => EPROTONOSUPPORT,
1417 libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT,
1418 libc::EOPNOTSUPP => EOPNOTSUPP,
1419 libc::EPFNOSUPPORT => EPFNOSUPPORT,
1420 libc::EAFNOSUPPORT => EAFNOSUPPORT,
1421 libc::EADDRINUSE => EADDRINUSE,
1422 libc::EADDRNOTAVAIL => EADDRNOTAVAIL,
1423 libc::ENETDOWN => ENETDOWN,
1424 libc::ENETUNREACH => ENETUNREACH,
1425 libc::ENETRESET => ENETRESET,
1426 libc::ECONNABORTED => ECONNABORTED,
1427 libc::ECONNRESET => ECONNRESET,
1428 libc::ENOBUFS => ENOBUFS,
1429 libc::EISCONN => EISCONN,
1430 libc::ENOTCONN => ENOTCONN,
1431 libc::ESHUTDOWN => ESHUTDOWN,
1432 libc::ETOOMANYREFS => ETOOMANYREFS,
1433 libc::ETIMEDOUT => ETIMEDOUT,
1434 libc::ECONNREFUSED => ECONNREFUSED,
1435 libc::EHOSTDOWN => EHOSTDOWN,
1436 libc::EHOSTUNREACH => EHOSTUNREACH,
1437 libc::EALREADY => EALREADY,
1438 libc::EINPROGRESS => EINPROGRESS,
1439 libc::ESTALE => ESTALE,
1440 libc::EUCLEAN => EUCLEAN,
1441 libc::ENOTNAM => ENOTNAM,
1442 libc::ENAVAIL => ENAVAIL,
1443 libc::EISNAM => EISNAM,
1444 libc::EREMOTEIO => EREMOTEIO,
1445 libc::EDQUOT => EDQUOT,
1446 libc::ENOMEDIUM => ENOMEDIUM,
1447 libc::EMEDIUMTYPE => EMEDIUMTYPE,
1448 libc::ECANCELED => ECANCELED,
1449 libc::ENOKEY => ENOKEY,
1450 libc::EKEYEXPIRED => EKEYEXPIRED,
1451 libc::EKEYREVOKED => EKEYREVOKED,
1452 libc::EKEYREJECTED => EKEYREJECTED,
1453 libc::EOWNERDEAD => EOWNERDEAD,
1454 libc::ENOTRECOVERABLE => ENOTRECOVERABLE,
1455 #[cfg(not(any(target_os = "android", target_arch = "mips")))]
1456 libc::ERFKILL => ERFKILL,
1457 #[cfg(not(any(target_os = "android", target_arch = "mips")))]
1458 libc::EHWPOISON => EHWPOISON,
1459 _ => UnknownErrno,
1460 }
1461 }
1462}
1463
1464#[cfg(any(target_os = "macos", target_os = "ios"))]
1465mod consts {
1466 #[derive(Clone, Copy, Debug, Eq, PartialEq)]
1467 #[repr(i32)]
1468 #[non_exhaustive]
1469 pub enum Errno {
1470 UnknownErrno = 0,
1471 EPERM = libc::EPERM,
1472 ENOENT = libc::ENOENT,
1473 ESRCH = libc::ESRCH,
1474 EINTR = libc::EINTR,
1475 EIO = libc::EIO,
1476 ENXIO = libc::ENXIO,
1477 E2BIG = libc::E2BIG,
1478 ENOEXEC = libc::ENOEXEC,
1479 EBADF = libc::EBADF,
1480 ECHILD = libc::ECHILD,
1481 EDEADLK = libc::EDEADLK,
1482 ENOMEM = libc::ENOMEM,
1483 EACCES = libc::EACCES,
1484 EFAULT = libc::EFAULT,
1485 ENOTBLK = libc::ENOTBLK,
1486 EBUSY = libc::EBUSY,
1487 EEXIST = libc::EEXIST,
1488 EXDEV = libc::EXDEV,
1489 ENODEV = libc::ENODEV,
1490 ENOTDIR = libc::ENOTDIR,
1491 EISDIR = libc::EISDIR,
1492 EINVAL = libc::EINVAL,
1493 ENFILE = libc::ENFILE,
1494 EMFILE = libc::EMFILE,
1495 ENOTTY = libc::ENOTTY,
1496 ETXTBSY = libc::ETXTBSY,
1497 EFBIG = libc::EFBIG,
1498 ENOSPC = libc::ENOSPC,
1499 ESPIPE = libc::ESPIPE,
1500 EROFS = libc::EROFS,
1501 EMLINK = libc::EMLINK,
1502 EPIPE = libc::EPIPE,
1503 EDOM = libc::EDOM,
1504 ERANGE = libc::ERANGE,
1505 EAGAIN = libc::EAGAIN,
1506 EINPROGRESS = libc::EINPROGRESS,
1507 EALREADY = libc::EALREADY,
1508 ENOTSOCK = libc::ENOTSOCK,
1509 EDESTADDRREQ = libc::EDESTADDRREQ,
1510 EMSGSIZE = libc::EMSGSIZE,
1511 EPROTOTYPE = libc::EPROTOTYPE,
1512 ENOPROTOOPT = libc::ENOPROTOOPT,
1513 EPROTONOSUPPORT = libc::EPROTONOSUPPORT,
1514 ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT,
1515 ENOTSUP = libc::ENOTSUP,
1516 EPFNOSUPPORT = libc::EPFNOSUPPORT,
1517 EAFNOSUPPORT = libc::EAFNOSUPPORT,
1518 EADDRINUSE = libc::EADDRINUSE,
1519 EADDRNOTAVAIL = libc::EADDRNOTAVAIL,
1520 ENETDOWN = libc::ENETDOWN,
1521 ENETUNREACH = libc::ENETUNREACH,
1522 ENETRESET = libc::ENETRESET,
1523 ECONNABORTED = libc::ECONNABORTED,
1524 ECONNRESET = libc::ECONNRESET,
1525 ENOBUFS = libc::ENOBUFS,
1526 EISCONN = libc::EISCONN,
1527 ENOTCONN = libc::ENOTCONN,
1528 ESHUTDOWN = libc::ESHUTDOWN,
1529 ETOOMANYREFS = libc::ETOOMANYREFS,
1530 ETIMEDOUT = libc::ETIMEDOUT,
1531 ECONNREFUSED = libc::ECONNREFUSED,
1532 ELOOP = libc::ELOOP,
1533 ENAMETOOLONG = libc::ENAMETOOLONG,
1534 EHOSTDOWN = libc::EHOSTDOWN,
1535 EHOSTUNREACH = libc::EHOSTUNREACH,
1536 ENOTEMPTY = libc::ENOTEMPTY,
1537 EPROCLIM = libc::EPROCLIM,
1538 EUSERS = libc::EUSERS,
1539 EDQUOT = libc::EDQUOT,
1540 ESTALE = libc::ESTALE,
1541 EREMOTE = libc::EREMOTE,
1542 EBADRPC = libc::EBADRPC,
1543 ERPCMISMATCH = libc::ERPCMISMATCH,
1544 EPROGUNAVAIL = libc::EPROGUNAVAIL,
1545 EPROGMISMATCH = libc::EPROGMISMATCH,
1546 EPROCUNAVAIL = libc::EPROCUNAVAIL,
1547 ENOLCK = libc::ENOLCK,
1548 ENOSYS = libc::ENOSYS,
1549 EFTYPE = libc::EFTYPE,
1550 EAUTH = libc::EAUTH,
1551 ENEEDAUTH = libc::ENEEDAUTH,
1552 EPWROFF = libc::EPWROFF,
1553 EDEVERR = libc::EDEVERR,
1554 EOVERFLOW = libc::EOVERFLOW,
1555 EBADEXEC = libc::EBADEXEC,
1556 EBADARCH = libc::EBADARCH,
1557 ESHLIBVERS = libc::ESHLIBVERS,
1558 EBADMACHO = libc::EBADMACHO,
1559 ECANCELED = libc::ECANCELED,
1560 EIDRM = libc::EIDRM,
1561 ENOMSG = libc::ENOMSG,
1562 EILSEQ = libc::EILSEQ,
1563 ENOATTR = libc::ENOATTR,
1564 EBADMSG = libc::EBADMSG,
1565 EMULTIHOP = libc::EMULTIHOP,
1566 ENODATA = libc::ENODATA,
1567 ENOLINK = libc::ENOLINK,
1568 ENOSR = libc::ENOSR,
1569 ENOSTR = libc::ENOSTR,
1570 EPROTO = libc::EPROTO,
1571 ETIME = libc::ETIME,
1572 EOPNOTSUPP = libc::EOPNOTSUPP,
1573 ENOPOLICY = libc::ENOPOLICY,
1574 ENOTRECOVERABLE = libc::ENOTRECOVERABLE,
1575 EOWNERDEAD = libc::EOWNERDEAD,
1576 EQFULL = libc::EQFULL,
1577 }
1578
1579 #[deprecated(
1580 since = "0.22.1",
1581 note = "use nix::errno::Errno::ELAST instead"
1582 )]
1583 pub const ELAST: Errno = Errno::EQFULL;
1584 #[deprecated(
1585 since = "0.22.1",
1586 note = "use nix::errno::Errno::EWOULDBLOCK instead"
1587 )]
1588 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
1589 #[deprecated(
1590 since = "0.22.1",
1591 note = "use nix::errno::Errno::EDEADLOCK instead"
1592 )]
1593 pub const EDEADLOCK: Errno = Errno::EDEADLK;
1594
1595 impl Errno {
1596 pub const ELAST: Errno = Errno::EQFULL;
1597 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
1598 pub const EDEADLOCK: Errno = Errno::EDEADLK;
1599 }
1600
1601 pub const fn from_i32(e: i32) -> Errno {
1602 use self::Errno::*;
1603
1604 match e {
1605 libc::EPERM => EPERM,
1606 libc::ENOENT => ENOENT,
1607 libc::ESRCH => ESRCH,
1608 libc::EINTR => EINTR,
1609 libc::EIO => EIO,
1610 libc::ENXIO => ENXIO,
1611 libc::E2BIG => E2BIG,
1612 libc::ENOEXEC => ENOEXEC,
1613 libc::EBADF => EBADF,
1614 libc::ECHILD => ECHILD,
1615 libc::EDEADLK => EDEADLK,
1616 libc::ENOMEM => ENOMEM,
1617 libc::EACCES => EACCES,
1618 libc::EFAULT => EFAULT,
1619 libc::ENOTBLK => ENOTBLK,
1620 libc::EBUSY => EBUSY,
1621 libc::EEXIST => EEXIST,
1622 libc::EXDEV => EXDEV,
1623 libc::ENODEV => ENODEV,
1624 libc::ENOTDIR => ENOTDIR,
1625 libc::EISDIR => EISDIR,
1626 libc::EINVAL => EINVAL,
1627 libc::ENFILE => ENFILE,
1628 libc::EMFILE => EMFILE,
1629 libc::ENOTTY => ENOTTY,
1630 libc::ETXTBSY => ETXTBSY,
1631 libc::EFBIG => EFBIG,
1632 libc::ENOSPC => ENOSPC,
1633 libc::ESPIPE => ESPIPE,
1634 libc::EROFS => EROFS,
1635 libc::EMLINK => EMLINK,
1636 libc::EPIPE => EPIPE,
1637 libc::EDOM => EDOM,
1638 libc::ERANGE => ERANGE,
1639 libc::EAGAIN => EAGAIN,
1640 libc::EINPROGRESS => EINPROGRESS,
1641 libc::EALREADY => EALREADY,
1642 libc::ENOTSOCK => ENOTSOCK,
1643 libc::EDESTADDRREQ => EDESTADDRREQ,
1644 libc::EMSGSIZE => EMSGSIZE,
1645 libc::EPROTOTYPE => EPROTOTYPE,
1646 libc::ENOPROTOOPT => ENOPROTOOPT,
1647 libc::EPROTONOSUPPORT => EPROTONOSUPPORT,
1648 libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT,
1649 libc::ENOTSUP => ENOTSUP,
1650 libc::EPFNOSUPPORT => EPFNOSUPPORT,
1651 libc::EAFNOSUPPORT => EAFNOSUPPORT,
1652 libc::EADDRINUSE => EADDRINUSE,
1653 libc::EADDRNOTAVAIL => EADDRNOTAVAIL,
1654 libc::ENETDOWN => ENETDOWN,
1655 libc::ENETUNREACH => ENETUNREACH,
1656 libc::ENETRESET => ENETRESET,
1657 libc::ECONNABORTED => ECONNABORTED,
1658 libc::ECONNRESET => ECONNRESET,
1659 libc::ENOBUFS => ENOBUFS,
1660 libc::EISCONN => EISCONN,
1661 libc::ENOTCONN => ENOTCONN,
1662 libc::ESHUTDOWN => ESHUTDOWN,
1663 libc::ETOOMANYREFS => ETOOMANYREFS,
1664 libc::ETIMEDOUT => ETIMEDOUT,
1665 libc::ECONNREFUSED => ECONNREFUSED,
1666 libc::ELOOP => ELOOP,
1667 libc::ENAMETOOLONG => ENAMETOOLONG,
1668 libc::EHOSTDOWN => EHOSTDOWN,
1669 libc::EHOSTUNREACH => EHOSTUNREACH,
1670 libc::ENOTEMPTY => ENOTEMPTY,
1671 libc::EPROCLIM => EPROCLIM,
1672 libc::EUSERS => EUSERS,
1673 libc::EDQUOT => EDQUOT,
1674 libc::ESTALE => ESTALE,
1675 libc::EREMOTE => EREMOTE,
1676 libc::EBADRPC => EBADRPC,
1677 libc::ERPCMISMATCH => ERPCMISMATCH,
1678 libc::EPROGUNAVAIL => EPROGUNAVAIL,
1679 libc::EPROGMISMATCH => EPROGMISMATCH,
1680 libc::EPROCUNAVAIL => EPROCUNAVAIL,
1681 libc::ENOLCK => ENOLCK,
1682 libc::ENOSYS => ENOSYS,
1683 libc::EFTYPE => EFTYPE,
1684 libc::EAUTH => EAUTH,
1685 libc::ENEEDAUTH => ENEEDAUTH,
1686 libc::EPWROFF => EPWROFF,
1687 libc::EDEVERR => EDEVERR,
1688 libc::EOVERFLOW => EOVERFLOW,
1689 libc::EBADEXEC => EBADEXEC,
1690 libc::EBADARCH => EBADARCH,
1691 libc::ESHLIBVERS => ESHLIBVERS,
1692 libc::EBADMACHO => EBADMACHO,
1693 libc::ECANCELED => ECANCELED,
1694 libc::EIDRM => EIDRM,
1695 libc::ENOMSG => ENOMSG,
1696 libc::EILSEQ => EILSEQ,
1697 libc::ENOATTR => ENOATTR,
1698 libc::EBADMSG => EBADMSG,
1699 libc::EMULTIHOP => EMULTIHOP,
1700 libc::ENODATA => ENODATA,
1701 libc::ENOLINK => ENOLINK,
1702 libc::ENOSR => ENOSR,
1703 libc::ENOSTR => ENOSTR,
1704 libc::EPROTO => EPROTO,
1705 libc::ETIME => ETIME,
1706 libc::EOPNOTSUPP => EOPNOTSUPP,
1707 libc::ENOPOLICY => ENOPOLICY,
1708 libc::ENOTRECOVERABLE => ENOTRECOVERABLE,
1709 libc::EOWNERDEAD => EOWNERDEAD,
1710 libc::EQFULL => EQFULL,
1711 _ => UnknownErrno,
1712 }
1713 }
1714}
1715
1716#[cfg(target_os = "freebsd")]
1717mod consts {
1718 #[derive(Clone, Copy, Debug, Eq, PartialEq)]
1719 #[repr(i32)]
1720 #[non_exhaustive]
1721 pub enum Errno {
1722 UnknownErrno = 0,
1723 EPERM = libc::EPERM,
1724 ENOENT = libc::ENOENT,
1725 ESRCH = libc::ESRCH,
1726 EINTR = libc::EINTR,
1727 EIO = libc::EIO,
1728 ENXIO = libc::ENXIO,
1729 E2BIG = libc::E2BIG,
1730 ENOEXEC = libc::ENOEXEC,
1731 EBADF = libc::EBADF,
1732 ECHILD = libc::ECHILD,
1733 EDEADLK = libc::EDEADLK,
1734 ENOMEM = libc::ENOMEM,
1735 EACCES = libc::EACCES,
1736 EFAULT = libc::EFAULT,
1737 ENOTBLK = libc::ENOTBLK,
1738 EBUSY = libc::EBUSY,
1739 EEXIST = libc::EEXIST,
1740 EXDEV = libc::EXDEV,
1741 ENODEV = libc::ENODEV,
1742 ENOTDIR = libc::ENOTDIR,
1743 EISDIR = libc::EISDIR,
1744 EINVAL = libc::EINVAL,
1745 ENFILE = libc::ENFILE,
1746 EMFILE = libc::EMFILE,
1747 ENOTTY = libc::ENOTTY,
1748 ETXTBSY = libc::ETXTBSY,
1749 EFBIG = libc::EFBIG,
1750 ENOSPC = libc::ENOSPC,
1751 ESPIPE = libc::ESPIPE,
1752 EROFS = libc::EROFS,
1753 EMLINK = libc::EMLINK,
1754 EPIPE = libc::EPIPE,
1755 EDOM = libc::EDOM,
1756 ERANGE = libc::ERANGE,
1757 EAGAIN = libc::EAGAIN,
1758 EINPROGRESS = libc::EINPROGRESS,
1759 EALREADY = libc::EALREADY,
1760 ENOTSOCK = libc::ENOTSOCK,
1761 EDESTADDRREQ = libc::EDESTADDRREQ,
1762 EMSGSIZE = libc::EMSGSIZE,
1763 EPROTOTYPE = libc::EPROTOTYPE,
1764 ENOPROTOOPT = libc::ENOPROTOOPT,
1765 EPROTONOSUPPORT = libc::EPROTONOSUPPORT,
1766 ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT,
1767 ENOTSUP = libc::ENOTSUP,
1768 EPFNOSUPPORT = libc::EPFNOSUPPORT,
1769 EAFNOSUPPORT = libc::EAFNOSUPPORT,
1770 EADDRINUSE = libc::EADDRINUSE,
1771 EADDRNOTAVAIL = libc::EADDRNOTAVAIL,
1772 ENETDOWN = libc::ENETDOWN,
1773 ENETUNREACH = libc::ENETUNREACH,
1774 ENETRESET = libc::ENETRESET,
1775 ECONNABORTED = libc::ECONNABORTED,
1776 ECONNRESET = libc::ECONNRESET,
1777 ENOBUFS = libc::ENOBUFS,
1778 EISCONN = libc::EISCONN,
1779 ENOTCONN = libc::ENOTCONN,
1780 ESHUTDOWN = libc::ESHUTDOWN,
1781 ETOOMANYREFS = libc::ETOOMANYREFS,
1782 ETIMEDOUT = libc::ETIMEDOUT,
1783 ECONNREFUSED = libc::ECONNREFUSED,
1784 ELOOP = libc::ELOOP,
1785 ENAMETOOLONG = libc::ENAMETOOLONG,
1786 EHOSTDOWN = libc::EHOSTDOWN,
1787 EHOSTUNREACH = libc::EHOSTUNREACH,
1788 ENOTEMPTY = libc::ENOTEMPTY,
1789 EPROCLIM = libc::EPROCLIM,
1790 EUSERS = libc::EUSERS,
1791 EDQUOT = libc::EDQUOT,
1792 ESTALE = libc::ESTALE,
1793 EREMOTE = libc::EREMOTE,
1794 EBADRPC = libc::EBADRPC,
1795 ERPCMISMATCH = libc::ERPCMISMATCH,
1796 EPROGUNAVAIL = libc::EPROGUNAVAIL,
1797 EPROGMISMATCH = libc::EPROGMISMATCH,
1798 EPROCUNAVAIL = libc::EPROCUNAVAIL,
1799 ENOLCK = libc::ENOLCK,
1800 ENOSYS = libc::ENOSYS,
1801 EFTYPE = libc::EFTYPE,
1802 EAUTH = libc::EAUTH,
1803 ENEEDAUTH = libc::ENEEDAUTH,
1804 EIDRM = libc::EIDRM,
1805 ENOMSG = libc::ENOMSG,
1806 EOVERFLOW = libc::EOVERFLOW,
1807 ECANCELED = libc::ECANCELED,
1808 EILSEQ = libc::EILSEQ,
1809 ENOATTR = libc::ENOATTR,
1810 EDOOFUS = libc::EDOOFUS,
1811 EBADMSG = libc::EBADMSG,
1812 EMULTIHOP = libc::EMULTIHOP,
1813 ENOLINK = libc::ENOLINK,
1814 EPROTO = libc::EPROTO,
1815 ENOTCAPABLE = libc::ENOTCAPABLE,
1816 ECAPMODE = libc::ECAPMODE,
1817 ENOTRECOVERABLE = libc::ENOTRECOVERABLE,
1818 EOWNERDEAD = libc::EOWNERDEAD,
1819 }
1820
1821 #[deprecated(
1822 since = "0.22.1",
1823 note = "use nix::errno::Errno::ELAST instead"
1824 )]
1825 pub const ELAST: Errno = Errno::EOWNERDEAD;
1826 #[deprecated(
1827 since = "0.22.1",
1828 note = "use nix::errno::Errno::EWOULDBLOCK instead"
1829 )]
1830 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
1831 #[deprecated(
1832 since = "0.22.1",
1833 note = "use nix::errno::Errno::EDEADLOCK instead"
1834 )]
1835 pub const EDEADLOCK: Errno = Errno::EDEADLK;
1836 #[deprecated(
1837 since = "0.22.1",
1838 note = "use nix::errno::Errno::EOPNOTSUPP instead"
1839 )]
1840 pub const EOPNOTSUPP: Errno = Errno::ENOTSUP;
1841
1842 impl Errno {
1843 pub const ELAST: Errno = Errno::EOWNERDEAD;
1844 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
1845 pub const EDEADLOCK: Errno = Errno::EDEADLK;
1846 pub const EOPNOTSUPP: Errno = Errno::ENOTSUP;
1847 }
1848
1849 pub const fn from_i32(e: i32) -> Errno {
1850 use self::Errno::*;
1851
1852 match e {
1853 libc::EPERM => EPERM,
1854 libc::ENOENT => ENOENT,
1855 libc::ESRCH => ESRCH,
1856 libc::EINTR => EINTR,
1857 libc::EIO => EIO,
1858 libc::ENXIO => ENXIO,
1859 libc::E2BIG => E2BIG,
1860 libc::ENOEXEC => ENOEXEC,
1861 libc::EBADF => EBADF,
1862 libc::ECHILD => ECHILD,
1863 libc::EDEADLK => EDEADLK,
1864 libc::ENOMEM => ENOMEM,
1865 libc::EACCES => EACCES,
1866 libc::EFAULT => EFAULT,
1867 libc::ENOTBLK => ENOTBLK,
1868 libc::EBUSY => EBUSY,
1869 libc::EEXIST => EEXIST,
1870 libc::EXDEV => EXDEV,
1871 libc::ENODEV => ENODEV,
1872 libc::ENOTDIR => ENOTDIR,
1873 libc::EISDIR => EISDIR,
1874 libc::EINVAL => EINVAL,
1875 libc::ENFILE => ENFILE,
1876 libc::EMFILE => EMFILE,
1877 libc::ENOTTY => ENOTTY,
1878 libc::ETXTBSY => ETXTBSY,
1879 libc::EFBIG => EFBIG,
1880 libc::ENOSPC => ENOSPC,
1881 libc::ESPIPE => ESPIPE,
1882 libc::EROFS => EROFS,
1883 libc::EMLINK => EMLINK,
1884 libc::EPIPE => EPIPE,
1885 libc::EDOM => EDOM,
1886 libc::ERANGE => ERANGE,
1887 libc::EAGAIN => EAGAIN,
1888 libc::EINPROGRESS => EINPROGRESS,
1889 libc::EALREADY => EALREADY,
1890 libc::ENOTSOCK => ENOTSOCK,
1891 libc::EDESTADDRREQ => EDESTADDRREQ,
1892 libc::EMSGSIZE => EMSGSIZE,
1893 libc::EPROTOTYPE => EPROTOTYPE,
1894 libc::ENOPROTOOPT => ENOPROTOOPT,
1895 libc::EPROTONOSUPPORT => EPROTONOSUPPORT,
1896 libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT,
1897 libc::ENOTSUP => ENOTSUP,
1898 libc::EPFNOSUPPORT => EPFNOSUPPORT,
1899 libc::EAFNOSUPPORT => EAFNOSUPPORT,
1900 libc::EADDRINUSE => EADDRINUSE,
1901 libc::EADDRNOTAVAIL => EADDRNOTAVAIL,
1902 libc::ENETDOWN => ENETDOWN,
1903 libc::ENETUNREACH => ENETUNREACH,
1904 libc::ENETRESET => ENETRESET,
1905 libc::ECONNABORTED => ECONNABORTED,
1906 libc::ECONNRESET => ECONNRESET,
1907 libc::ENOBUFS => ENOBUFS,
1908 libc::EISCONN => EISCONN,
1909 libc::ENOTCONN => ENOTCONN,
1910 libc::ESHUTDOWN => ESHUTDOWN,
1911 libc::ETOOMANYREFS => ETOOMANYREFS,
1912 libc::ETIMEDOUT => ETIMEDOUT,
1913 libc::ECONNREFUSED => ECONNREFUSED,
1914 libc::ELOOP => ELOOP,
1915 libc::ENAMETOOLONG => ENAMETOOLONG,
1916 libc::EHOSTDOWN => EHOSTDOWN,
1917 libc::EHOSTUNREACH => EHOSTUNREACH,
1918 libc::ENOTEMPTY => ENOTEMPTY,
1919 libc::EPROCLIM => EPROCLIM,
1920 libc::EUSERS => EUSERS,
1921 libc::EDQUOT => EDQUOT,
1922 libc::ESTALE => ESTALE,
1923 libc::EREMOTE => EREMOTE,
1924 libc::EBADRPC => EBADRPC,
1925 libc::ERPCMISMATCH => ERPCMISMATCH,
1926 libc::EPROGUNAVAIL => EPROGUNAVAIL,
1927 libc::EPROGMISMATCH => EPROGMISMATCH,
1928 libc::EPROCUNAVAIL => EPROCUNAVAIL,
1929 libc::ENOLCK => ENOLCK,
1930 libc::ENOSYS => ENOSYS,
1931 libc::EFTYPE => EFTYPE,
1932 libc::EAUTH => EAUTH,
1933 libc::ENEEDAUTH => ENEEDAUTH,
1934 libc::EIDRM => EIDRM,
1935 libc::ENOMSG => ENOMSG,
1936 libc::EOVERFLOW => EOVERFLOW,
1937 libc::ECANCELED => ECANCELED,
1938 libc::EILSEQ => EILSEQ,
1939 libc::ENOATTR => ENOATTR,
1940 libc::EDOOFUS => EDOOFUS,
1941 libc::EBADMSG => EBADMSG,
1942 libc::EMULTIHOP => EMULTIHOP,
1943 libc::ENOLINK => ENOLINK,
1944 libc::EPROTO => EPROTO,
1945 libc::ENOTCAPABLE => ENOTCAPABLE,
1946 libc::ECAPMODE => ECAPMODE,
1947 libc::ENOTRECOVERABLE => ENOTRECOVERABLE,
1948 libc::EOWNERDEAD => EOWNERDEAD,
1949 _ => UnknownErrno,
1950 }
1951 }
1952}
1953
1954#[cfg(target_os = "dragonfly")]
1955mod consts {
1956 #[derive(Clone, Copy, Debug, Eq, PartialEq)]
1957 #[repr(i32)]
1958 #[non_exhaustive]
1959 pub enum Errno {
1960 UnknownErrno = 0,
1961 EPERM = libc::EPERM,
1962 ENOENT = libc::ENOENT,
1963 ESRCH = libc::ESRCH,
1964 EINTR = libc::EINTR,
1965 EIO = libc::EIO,
1966 ENXIO = libc::ENXIO,
1967 E2BIG = libc::E2BIG,
1968 ENOEXEC = libc::ENOEXEC,
1969 EBADF = libc::EBADF,
1970 ECHILD = libc::ECHILD,
1971 EDEADLK = libc::EDEADLK,
1972 ENOMEM = libc::ENOMEM,
1973 EACCES = libc::EACCES,
1974 EFAULT = libc::EFAULT,
1975 ENOTBLK = libc::ENOTBLK,
1976 EBUSY = libc::EBUSY,
1977 EEXIST = libc::EEXIST,
1978 EXDEV = libc::EXDEV,
1979 ENODEV = libc::ENODEV,
1980 ENOTDIR = libc::ENOTDIR,
1981 EISDIR = libc::EISDIR,
1982 EINVAL = libc::EINVAL,
1983 ENFILE = libc::ENFILE,
1984 EMFILE = libc::EMFILE,
1985 ENOTTY = libc::ENOTTY,
1986 ETXTBSY = libc::ETXTBSY,
1987 EFBIG = libc::EFBIG,
1988 ENOSPC = libc::ENOSPC,
1989 ESPIPE = libc::ESPIPE,
1990 EROFS = libc::EROFS,
1991 EMLINK = libc::EMLINK,
1992 EPIPE = libc::EPIPE,
1993 EDOM = libc::EDOM,
1994 ERANGE = libc::ERANGE,
1995 EAGAIN = libc::EAGAIN,
1996 EINPROGRESS = libc::EINPROGRESS,
1997 EALREADY = libc::EALREADY,
1998 ENOTSOCK = libc::ENOTSOCK,
1999 EDESTADDRREQ = libc::EDESTADDRREQ,
2000 EMSGSIZE = libc::EMSGSIZE,
2001 EPROTOTYPE = libc::EPROTOTYPE,
2002 ENOPROTOOPT = libc::ENOPROTOOPT,
2003 EPROTONOSUPPORT = libc::EPROTONOSUPPORT,
2004 ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT,
2005 ENOTSUP = libc::ENOTSUP,
2006 EPFNOSUPPORT = libc::EPFNOSUPPORT,
2007 EAFNOSUPPORT = libc::EAFNOSUPPORT,
2008 EADDRINUSE = libc::EADDRINUSE,
2009 EADDRNOTAVAIL = libc::EADDRNOTAVAIL,
2010 ENETDOWN = libc::ENETDOWN,
2011 ENETUNREACH = libc::ENETUNREACH,
2012 ENETRESET = libc::ENETRESET,
2013 ECONNABORTED = libc::ECONNABORTED,
2014 ECONNRESET = libc::ECONNRESET,
2015 ENOBUFS = libc::ENOBUFS,
2016 EISCONN = libc::EISCONN,
2017 ENOTCONN = libc::ENOTCONN,
2018 ESHUTDOWN = libc::ESHUTDOWN,
2019 ETOOMANYREFS = libc::ETOOMANYREFS,
2020 ETIMEDOUT = libc::ETIMEDOUT,
2021 ECONNREFUSED = libc::ECONNREFUSED,
2022 ELOOP = libc::ELOOP,
2023 ENAMETOOLONG = libc::ENAMETOOLONG,
2024 EHOSTDOWN = libc::EHOSTDOWN,
2025 EHOSTUNREACH = libc::EHOSTUNREACH,
2026 ENOTEMPTY = libc::ENOTEMPTY,
2027 EPROCLIM = libc::EPROCLIM,
2028 EUSERS = libc::EUSERS,
2029 EDQUOT = libc::EDQUOT,
2030 ESTALE = libc::ESTALE,
2031 EREMOTE = libc::EREMOTE,
2032 EBADRPC = libc::EBADRPC,
2033 ERPCMISMATCH = libc::ERPCMISMATCH,
2034 EPROGUNAVAIL = libc::EPROGUNAVAIL,
2035 EPROGMISMATCH = libc::EPROGMISMATCH,
2036 EPROCUNAVAIL = libc::EPROCUNAVAIL,
2037 ENOLCK = libc::ENOLCK,
2038 ENOSYS = libc::ENOSYS,
2039 EFTYPE = libc::EFTYPE,
2040 EAUTH = libc::EAUTH,
2041 ENEEDAUTH = libc::ENEEDAUTH,
2042 EIDRM = libc::EIDRM,
2043 ENOMSG = libc::ENOMSG,
2044 EOVERFLOW = libc::EOVERFLOW,
2045 ECANCELED = libc::ECANCELED,
2046 EILSEQ = libc::EILSEQ,
2047 ENOATTR = libc::ENOATTR,
2048 EDOOFUS = libc::EDOOFUS,
2049 EBADMSG = libc::EBADMSG,
2050 EMULTIHOP = libc::EMULTIHOP,
2051 ENOLINK = libc::ENOLINK,
2052 EPROTO = libc::EPROTO,
2053 ENOMEDIUM = libc::ENOMEDIUM,
2054 ENOTRECOVERABLE = libc::ENOTRECOVERABLE,
2055 EOWNERDEAD = libc::EOWNERDEAD,
2056 EASYNC = libc::EASYNC,
2057 }
2058
2059 #[deprecated(
2060 since = "0.22.1",
2061 note = "use nix::errno::Errno::ELAST instead"
2062 )]
2063 pub const ELAST: Errno = Errno::EASYNC;
2064 #[deprecated(
2065 since = "0.22.1",
2066 note = "use nix::errno::Errno::EWOULDBLOCK instead"
2067 )]
2068 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
2069 #[deprecated(
2070 since = "0.22.1",
2071 note = "use nix::errno::Errno::EDEADLOCK instead"
2072 )]
2073 pub const EDEADLOCK: Errno = Errno::EDEADLK;
2074 #[deprecated(
2075 since = "0.22.1",
2076 note = "use nix::errno::Errno::EOPNOTSUPP instead"
2077 )]
2078 pub const EOPNOTSUPP: Errno = Errno::ENOTSUP;
2079
2080 impl Errno {
2081 pub const ELAST: Errno = Errno::EASYNC;
2082 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
2083 pub const EDEADLOCK: Errno = Errno::EDEADLK;
2084 pub const EOPNOTSUPP: Errno = Errno::ENOTSUP;
2085 }
2086
2087 pub const fn from_i32(e: i32) -> Errno {
2088 use self::Errno::*;
2089
2090 match e {
2091 libc::EPERM => EPERM,
2092 libc::ENOENT => ENOENT,
2093 libc::ESRCH => ESRCH,
2094 libc::EINTR => EINTR,
2095 libc::EIO => EIO,
2096 libc::ENXIO => ENXIO,
2097 libc::E2BIG => E2BIG,
2098 libc::ENOEXEC => ENOEXEC,
2099 libc::EBADF => EBADF,
2100 libc::ECHILD => ECHILD,
2101 libc::EDEADLK => EDEADLK,
2102 libc::ENOMEM => ENOMEM,
2103 libc::EACCES => EACCES,
2104 libc::EFAULT => EFAULT,
2105 libc::ENOTBLK => ENOTBLK,
2106 libc::EBUSY => EBUSY,
2107 libc::EEXIST => EEXIST,
2108 libc::EXDEV => EXDEV,
2109 libc::ENODEV => ENODEV,
2110 libc::ENOTDIR => ENOTDIR,
2111 libc::EISDIR => EISDIR,
2112 libc::EINVAL => EINVAL,
2113 libc::ENFILE => ENFILE,
2114 libc::EMFILE => EMFILE,
2115 libc::ENOTTY => ENOTTY,
2116 libc::ETXTBSY => ETXTBSY,
2117 libc::EFBIG => EFBIG,
2118 libc::ENOSPC => ENOSPC,
2119 libc::ESPIPE => ESPIPE,
2120 libc::EROFS => EROFS,
2121 libc::EMLINK => EMLINK,
2122 libc::EPIPE => EPIPE,
2123 libc::EDOM => EDOM,
2124 libc::ERANGE => ERANGE,
2125 libc::EAGAIN => EAGAIN,
2126 libc::EINPROGRESS => EINPROGRESS,
2127 libc::EALREADY => EALREADY,
2128 libc::ENOTSOCK => ENOTSOCK,
2129 libc::EDESTADDRREQ => EDESTADDRREQ,
2130 libc::EMSGSIZE => EMSGSIZE,
2131 libc::EPROTOTYPE => EPROTOTYPE,
2132 libc::ENOPROTOOPT => ENOPROTOOPT,
2133 libc::EPROTONOSUPPORT => EPROTONOSUPPORT,
2134 libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT,
2135 libc::ENOTSUP => ENOTSUP,
2136 libc::EPFNOSUPPORT => EPFNOSUPPORT,
2137 libc::EAFNOSUPPORT => EAFNOSUPPORT,
2138 libc::EADDRINUSE => EADDRINUSE,
2139 libc::EADDRNOTAVAIL => EADDRNOTAVAIL,
2140 libc::ENETDOWN => ENETDOWN,
2141 libc::ENETUNREACH => ENETUNREACH,
2142 libc::ENETRESET => ENETRESET,
2143 libc::ECONNABORTED => ECONNABORTED,
2144 libc::ECONNRESET => ECONNRESET,
2145 libc::ENOBUFS => ENOBUFS,
2146 libc::EISCONN => EISCONN,
2147 libc::ENOTCONN => ENOTCONN,
2148 libc::ESHUTDOWN => ESHUTDOWN,
2149 libc::ETOOMANYREFS => ETOOMANYREFS,
2150 libc::ETIMEDOUT => ETIMEDOUT,
2151 libc::ECONNREFUSED => ECONNREFUSED,
2152 libc::ELOOP => ELOOP,
2153 libc::ENAMETOOLONG => ENAMETOOLONG,
2154 libc::EHOSTDOWN => EHOSTDOWN,
2155 libc::EHOSTUNREACH => EHOSTUNREACH,
2156 libc::ENOTEMPTY => ENOTEMPTY,
2157 libc::EPROCLIM => EPROCLIM,
2158 libc::EUSERS => EUSERS,
2159 libc::EDQUOT => EDQUOT,
2160 libc::ESTALE => ESTALE,
2161 libc::EREMOTE => EREMOTE,
2162 libc::EBADRPC => EBADRPC,
2163 libc::ERPCMISMATCH => ERPCMISMATCH,
2164 libc::EPROGUNAVAIL => EPROGUNAVAIL,
2165 libc::EPROGMISMATCH => EPROGMISMATCH,
2166 libc::EPROCUNAVAIL => EPROCUNAVAIL,
2167 libc::ENOLCK => ENOLCK,
2168 libc::ENOSYS => ENOSYS,
2169 libc::EFTYPE => EFTYPE,
2170 libc::EAUTH => EAUTH,
2171 libc::ENEEDAUTH => ENEEDAUTH,
2172 libc::EIDRM => EIDRM,
2173 libc::ENOMSG => ENOMSG,
2174 libc::EOVERFLOW => EOVERFLOW,
2175 libc::ECANCELED => ECANCELED,
2176 libc::EILSEQ => EILSEQ,
2177 libc::ENOATTR => ENOATTR,
2178 libc::EDOOFUS => EDOOFUS,
2179 libc::EBADMSG => EBADMSG,
2180 libc::EMULTIHOP => EMULTIHOP,
2181 libc::ENOLINK => ENOLINK,
2182 libc::EPROTO => EPROTO,
2183 libc::ENOMEDIUM => ENOMEDIUM,
2184 libc::EASYNC => EASYNC,
2185 _ => UnknownErrno,
2186 }
2187 }
2188}
2189
2190#[cfg(target_os = "openbsd")]
2191mod consts {
2192 #[derive(Clone, Copy, Debug, Eq, PartialEq)]
2193 #[repr(i32)]
2194 #[non_exhaustive]
2195 pub enum Errno {
2196 UnknownErrno = 0,
2197 EPERM = libc::EPERM,
2198 ENOENT = libc::ENOENT,
2199 ESRCH = libc::ESRCH,
2200 EINTR = libc::EINTR,
2201 EIO = libc::EIO,
2202 ENXIO = libc::ENXIO,
2203 E2BIG = libc::E2BIG,
2204 ENOEXEC = libc::ENOEXEC,
2205 EBADF = libc::EBADF,
2206 ECHILD = libc::ECHILD,
2207 EDEADLK = libc::EDEADLK,
2208 ENOMEM = libc::ENOMEM,
2209 EACCES = libc::EACCES,
2210 EFAULT = libc::EFAULT,
2211 ENOTBLK = libc::ENOTBLK,
2212 EBUSY = libc::EBUSY,
2213 EEXIST = libc::EEXIST,
2214 EXDEV = libc::EXDEV,
2215 ENODEV = libc::ENODEV,
2216 ENOTDIR = libc::ENOTDIR,
2217 EISDIR = libc::EISDIR,
2218 EINVAL = libc::EINVAL,
2219 ENFILE = libc::ENFILE,
2220 EMFILE = libc::EMFILE,
2221 ENOTTY = libc::ENOTTY,
2222 ETXTBSY = libc::ETXTBSY,
2223 EFBIG = libc::EFBIG,
2224 ENOSPC = libc::ENOSPC,
2225 ESPIPE = libc::ESPIPE,
2226 EROFS = libc::EROFS,
2227 EMLINK = libc::EMLINK,
2228 EPIPE = libc::EPIPE,
2229 EDOM = libc::EDOM,
2230 ERANGE = libc::ERANGE,
2231 EAGAIN = libc::EAGAIN,
2232 EINPROGRESS = libc::EINPROGRESS,
2233 EALREADY = libc::EALREADY,
2234 ENOTSOCK = libc::ENOTSOCK,
2235 EDESTADDRREQ = libc::EDESTADDRREQ,
2236 EMSGSIZE = libc::EMSGSIZE,
2237 EPROTOTYPE = libc::EPROTOTYPE,
2238 ENOPROTOOPT = libc::ENOPROTOOPT,
2239 EPROTONOSUPPORT = libc::EPROTONOSUPPORT,
2240 ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT,
2241 EOPNOTSUPP = libc::EOPNOTSUPP,
2242 EPFNOSUPPORT = libc::EPFNOSUPPORT,
2243 EAFNOSUPPORT = libc::EAFNOSUPPORT,
2244 EADDRINUSE = libc::EADDRINUSE,
2245 EADDRNOTAVAIL = libc::EADDRNOTAVAIL,
2246 ENETDOWN = libc::ENETDOWN,
2247 ENETUNREACH = libc::ENETUNREACH,
2248 ENETRESET = libc::ENETRESET,
2249 ECONNABORTED = libc::ECONNABORTED,
2250 ECONNRESET = libc::ECONNRESET,
2251 ENOBUFS = libc::ENOBUFS,
2252 EISCONN = libc::EISCONN,
2253 ENOTCONN = libc::ENOTCONN,
2254 ESHUTDOWN = libc::ESHUTDOWN,
2255 ETOOMANYREFS = libc::ETOOMANYREFS,
2256 ETIMEDOUT = libc::ETIMEDOUT,
2257 ECONNREFUSED = libc::ECONNREFUSED,
2258 ELOOP = libc::ELOOP,
2259 ENAMETOOLONG = libc::ENAMETOOLONG,
2260 EHOSTDOWN = libc::EHOSTDOWN,
2261 EHOSTUNREACH = libc::EHOSTUNREACH,
2262 ENOTEMPTY = libc::ENOTEMPTY,
2263 EPROCLIM = libc::EPROCLIM,
2264 EUSERS = libc::EUSERS,
2265 EDQUOT = libc::EDQUOT,
2266 ESTALE = libc::ESTALE,
2267 EREMOTE = libc::EREMOTE,
2268 EBADRPC = libc::EBADRPC,
2269 ERPCMISMATCH = libc::ERPCMISMATCH,
2270 EPROGUNAVAIL = libc::EPROGUNAVAIL,
2271 EPROGMISMATCH = libc::EPROGMISMATCH,
2272 EPROCUNAVAIL = libc::EPROCUNAVAIL,
2273 ENOLCK = libc::ENOLCK,
2274 ENOSYS = libc::ENOSYS,
2275 EFTYPE = libc::EFTYPE,
2276 EAUTH = libc::EAUTH,
2277 ENEEDAUTH = libc::ENEEDAUTH,
2278 EIPSEC = libc::EIPSEC,
2279 ENOATTR = libc::ENOATTR,
2280 EILSEQ = libc::EILSEQ,
2281 ENOMEDIUM = libc::ENOMEDIUM,
2282 EMEDIUMTYPE = libc::EMEDIUMTYPE,
2283 EOVERFLOW = libc::EOVERFLOW,
2284 ECANCELED = libc::ECANCELED,
2285 EIDRM = libc::EIDRM,
2286 ENOMSG = libc::ENOMSG,
2287 ENOTSUP = libc::ENOTSUP,
2288 EBADMSG = libc::EBADMSG,
2289 ENOTRECOVERABLE = libc::ENOTRECOVERABLE,
2290 EOWNERDEAD = libc::EOWNERDEAD,
2291 EPROTO = libc::EPROTO,
2292 }
2293
2294 #[deprecated(
2295 since = "0.22.1",
2296 note = "use nix::errno::Errno::ELAST instead"
2297 )]
2298 pub const ELAST: Errno = Errno::ENOTSUP;
2299 #[deprecated(
2300 since = "0.22.1",
2301 note = "use nix::errno::Errno::EWOULDBLOCK instead"
2302 )]
2303 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
2304
2305 impl Errno {
2306 pub const ELAST: Errno = Errno::ENOTSUP;
2307 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
2308 }
2309
2310 pub const fn from_i32(e: i32) -> Errno {
2311 use self::Errno::*;
2312
2313 match e {
2314 libc::EPERM => EPERM,
2315 libc::ENOENT => ENOENT,
2316 libc::ESRCH => ESRCH,
2317 libc::EINTR => EINTR,
2318 libc::EIO => EIO,
2319 libc::ENXIO => ENXIO,
2320 libc::E2BIG => E2BIG,
2321 libc::ENOEXEC => ENOEXEC,
2322 libc::EBADF => EBADF,
2323 libc::ECHILD => ECHILD,
2324 libc::EDEADLK => EDEADLK,
2325 libc::ENOMEM => ENOMEM,
2326 libc::EACCES => EACCES,
2327 libc::EFAULT => EFAULT,
2328 libc::ENOTBLK => ENOTBLK,
2329 libc::EBUSY => EBUSY,
2330 libc::EEXIST => EEXIST,
2331 libc::EXDEV => EXDEV,
2332 libc::ENODEV => ENODEV,
2333 libc::ENOTDIR => ENOTDIR,
2334 libc::EISDIR => EISDIR,
2335 libc::EINVAL => EINVAL,
2336 libc::ENFILE => ENFILE,
2337 libc::EMFILE => EMFILE,
2338 libc::ENOTTY => ENOTTY,
2339 libc::ETXTBSY => ETXTBSY,
2340 libc::EFBIG => EFBIG,
2341 libc::ENOSPC => ENOSPC,
2342 libc::ESPIPE => ESPIPE,
2343 libc::EROFS => EROFS,
2344 libc::EMLINK => EMLINK,
2345 libc::EPIPE => EPIPE,
2346 libc::EDOM => EDOM,
2347 libc::ERANGE => ERANGE,
2348 libc::EAGAIN => EAGAIN,
2349 libc::EINPROGRESS => EINPROGRESS,
2350 libc::EALREADY => EALREADY,
2351 libc::ENOTSOCK => ENOTSOCK,
2352 libc::EDESTADDRREQ => EDESTADDRREQ,
2353 libc::EMSGSIZE => EMSGSIZE,
2354 libc::EPROTOTYPE => EPROTOTYPE,
2355 libc::ENOPROTOOPT => ENOPROTOOPT,
2356 libc::EPROTONOSUPPORT => EPROTONOSUPPORT,
2357 libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT,
2358 libc::EOPNOTSUPP => EOPNOTSUPP,
2359 libc::EPFNOSUPPORT => EPFNOSUPPORT,
2360 libc::EAFNOSUPPORT => EAFNOSUPPORT,
2361 libc::EADDRINUSE => EADDRINUSE,
2362 libc::EADDRNOTAVAIL => EADDRNOTAVAIL,
2363 libc::ENETDOWN => ENETDOWN,
2364 libc::ENETUNREACH => ENETUNREACH,
2365 libc::ENETRESET => ENETRESET,
2366 libc::ECONNABORTED => ECONNABORTED,
2367 libc::ECONNRESET => ECONNRESET,
2368 libc::ENOBUFS => ENOBUFS,
2369 libc::EISCONN => EISCONN,
2370 libc::ENOTCONN => ENOTCONN,
2371 libc::ESHUTDOWN => ESHUTDOWN,
2372 libc::ETOOMANYREFS => ETOOMANYREFS,
2373 libc::ETIMEDOUT => ETIMEDOUT,
2374 libc::ECONNREFUSED => ECONNREFUSED,
2375 libc::ELOOP => ELOOP,
2376 libc::ENAMETOOLONG => ENAMETOOLONG,
2377 libc::EHOSTDOWN => EHOSTDOWN,
2378 libc::EHOSTUNREACH => EHOSTUNREACH,
2379 libc::ENOTEMPTY => ENOTEMPTY,
2380 libc::EPROCLIM => EPROCLIM,
2381 libc::EUSERS => EUSERS,
2382 libc::EDQUOT => EDQUOT,
2383 libc::ESTALE => ESTALE,
2384 libc::EREMOTE => EREMOTE,
2385 libc::EBADRPC => EBADRPC,
2386 libc::ERPCMISMATCH => ERPCMISMATCH,
2387 libc::EPROGUNAVAIL => EPROGUNAVAIL,
2388 libc::EPROGMISMATCH => EPROGMISMATCH,
2389 libc::EPROCUNAVAIL => EPROCUNAVAIL,
2390 libc::ENOLCK => ENOLCK,
2391 libc::ENOSYS => ENOSYS,
2392 libc::EFTYPE => EFTYPE,
2393 libc::EAUTH => EAUTH,
2394 libc::ENEEDAUTH => ENEEDAUTH,
2395 libc::EIPSEC => EIPSEC,
2396 libc::ENOATTR => ENOATTR,
2397 libc::EILSEQ => EILSEQ,
2398 libc::ENOMEDIUM => ENOMEDIUM,
2399 libc::EMEDIUMTYPE => EMEDIUMTYPE,
2400 libc::EOVERFLOW => EOVERFLOW,
2401 libc::ECANCELED => ECANCELED,
2402 libc::EIDRM => EIDRM,
2403 libc::ENOMSG => ENOMSG,
2404 libc::ENOTSUP => ENOTSUP,
2405 libc::EBADMSG => EBADMSG,
2406 libc::ENOTRECOVERABLE => ENOTRECOVERABLE,
2407 libc::EOWNERDEAD => EOWNERDEAD,
2408 libc::EPROTO => EPROTO,
2409 _ => UnknownErrno,
2410 }
2411 }
2412}
2413
2414#[cfg(target_os = "netbsd")]
2415mod consts {
2416 #[derive(Clone, Copy, Debug, Eq, PartialEq)]
2417 #[repr(i32)]
2418 #[non_exhaustive]
2419 pub enum Errno {
2420 UnknownErrno = 0,
2421 EPERM = libc::EPERM,
2422 ENOENT = libc::ENOENT,
2423 ESRCH = libc::ESRCH,
2424 EINTR = libc::EINTR,
2425 EIO = libc::EIO,
2426 ENXIO = libc::ENXIO,
2427 E2BIG = libc::E2BIG,
2428 ENOEXEC = libc::ENOEXEC,
2429 EBADF = libc::EBADF,
2430 ECHILD = libc::ECHILD,
2431 EDEADLK = libc::EDEADLK,
2432 ENOMEM = libc::ENOMEM,
2433 EACCES = libc::EACCES,
2434 EFAULT = libc::EFAULT,
2435 ENOTBLK = libc::ENOTBLK,
2436 EBUSY = libc::EBUSY,
2437 EEXIST = libc::EEXIST,
2438 EXDEV = libc::EXDEV,
2439 ENODEV = libc::ENODEV,
2440 ENOTDIR = libc::ENOTDIR,
2441 EISDIR = libc::EISDIR,
2442 EINVAL = libc::EINVAL,
2443 ENFILE = libc::ENFILE,
2444 EMFILE = libc::EMFILE,
2445 ENOTTY = libc::ENOTTY,
2446 ETXTBSY = libc::ETXTBSY,
2447 EFBIG = libc::EFBIG,
2448 ENOSPC = libc::ENOSPC,
2449 ESPIPE = libc::ESPIPE,
2450 EROFS = libc::EROFS,
2451 EMLINK = libc::EMLINK,
2452 EPIPE = libc::EPIPE,
2453 EDOM = libc::EDOM,
2454 ERANGE = libc::ERANGE,
2455 EAGAIN = libc::EAGAIN,
2456 EINPROGRESS = libc::EINPROGRESS,
2457 EALREADY = libc::EALREADY,
2458 ENOTSOCK = libc::ENOTSOCK,
2459 EDESTADDRREQ = libc::EDESTADDRREQ,
2460 EMSGSIZE = libc::EMSGSIZE,
2461 EPROTOTYPE = libc::EPROTOTYPE,
2462 ENOPROTOOPT = libc::ENOPROTOOPT,
2463 EPROTONOSUPPORT = libc::EPROTONOSUPPORT,
2464 ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT,
2465 EOPNOTSUPP = libc::EOPNOTSUPP,
2466 EPFNOSUPPORT = libc::EPFNOSUPPORT,
2467 EAFNOSUPPORT = libc::EAFNOSUPPORT,
2468 EADDRINUSE = libc::EADDRINUSE,
2469 EADDRNOTAVAIL = libc::EADDRNOTAVAIL,
2470 ENETDOWN = libc::ENETDOWN,
2471 ENETUNREACH = libc::ENETUNREACH,
2472 ENETRESET = libc::ENETRESET,
2473 ECONNABORTED = libc::ECONNABORTED,
2474 ECONNRESET = libc::ECONNRESET,
2475 ENOBUFS = libc::ENOBUFS,
2476 EISCONN = libc::EISCONN,
2477 ENOTCONN = libc::ENOTCONN,
2478 ESHUTDOWN = libc::ESHUTDOWN,
2479 ETOOMANYREFS = libc::ETOOMANYREFS,
2480 ETIMEDOUT = libc::ETIMEDOUT,
2481 ECONNREFUSED = libc::ECONNREFUSED,
2482 ELOOP = libc::ELOOP,
2483 ENAMETOOLONG = libc::ENAMETOOLONG,
2484 EHOSTDOWN = libc::EHOSTDOWN,
2485 EHOSTUNREACH = libc::EHOSTUNREACH,
2486 ENOTEMPTY = libc::ENOTEMPTY,
2487 EPROCLIM = libc::EPROCLIM,
2488 EUSERS = libc::EUSERS,
2489 EDQUOT = libc::EDQUOT,
2490 ESTALE = libc::ESTALE,
2491 EREMOTE = libc::EREMOTE,
2492 EBADRPC = libc::EBADRPC,
2493 ERPCMISMATCH = libc::ERPCMISMATCH,
2494 EPROGUNAVAIL = libc::EPROGUNAVAIL,
2495 EPROGMISMATCH = libc::EPROGMISMATCH,
2496 EPROCUNAVAIL = libc::EPROCUNAVAIL,
2497 ENOLCK = libc::ENOLCK,
2498 ENOSYS = libc::ENOSYS,
2499 EFTYPE = libc::EFTYPE,
2500 EAUTH = libc::EAUTH,
2501 ENEEDAUTH = libc::ENEEDAUTH,
2502 EIDRM = libc::EIDRM,
2503 ENOMSG = libc::ENOMSG,
2504 EOVERFLOW = libc::EOVERFLOW,
2505 EILSEQ = libc::EILSEQ,
2506 ENOTSUP = libc::ENOTSUP,
2507 ECANCELED = libc::ECANCELED,
2508 EBADMSG = libc::EBADMSG,
2509 ENODATA = libc::ENODATA,
2510 ENOSR = libc::ENOSR,
2511 ENOSTR = libc::ENOSTR,
2512 ETIME = libc::ETIME,
2513 ENOATTR = libc::ENOATTR,
2514 EMULTIHOP = libc::EMULTIHOP,
2515 ENOLINK = libc::ENOLINK,
2516 EPROTO = libc::EPROTO,
2517 }
2518
2519 #[deprecated(
2520 since = "0.22.1",
2521 note = "use nix::errno::Errno::ELAST instead"
2522 )]
2523 pub const ELAST: Errno = Errno::ENOTSUP;
2524 #[deprecated(
2525 since = "0.22.1",
2526 note = "use nix::errno::Errno::EWOULDBLOCK instead"
2527 )]
2528 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
2529
2530 impl Errno {
2531 pub const ELAST: Errno = Errno::ENOTSUP;
2532 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
2533 }
2534
2535 pub const fn from_i32(e: i32) -> Errno {
2536 use self::Errno::*;
2537
2538 match e {
2539 libc::EPERM => EPERM,
2540 libc::ENOENT => ENOENT,
2541 libc::ESRCH => ESRCH,
2542 libc::EINTR => EINTR,
2543 libc::EIO => EIO,
2544 libc::ENXIO => ENXIO,
2545 libc::E2BIG => E2BIG,
2546 libc::ENOEXEC => ENOEXEC,
2547 libc::EBADF => EBADF,
2548 libc::ECHILD => ECHILD,
2549 libc::EDEADLK => EDEADLK,
2550 libc::ENOMEM => ENOMEM,
2551 libc::EACCES => EACCES,
2552 libc::EFAULT => EFAULT,
2553 libc::ENOTBLK => ENOTBLK,
2554 libc::EBUSY => EBUSY,
2555 libc::EEXIST => EEXIST,
2556 libc::EXDEV => EXDEV,
2557 libc::ENODEV => ENODEV,
2558 libc::ENOTDIR => ENOTDIR,
2559 libc::EISDIR => EISDIR,
2560 libc::EINVAL => EINVAL,
2561 libc::ENFILE => ENFILE,
2562 libc::EMFILE => EMFILE,
2563 libc::ENOTTY => ENOTTY,
2564 libc::ETXTBSY => ETXTBSY,
2565 libc::EFBIG => EFBIG,
2566 libc::ENOSPC => ENOSPC,
2567 libc::ESPIPE => ESPIPE,
2568 libc::EROFS => EROFS,
2569 libc::EMLINK => EMLINK,
2570 libc::EPIPE => EPIPE,
2571 libc::EDOM => EDOM,
2572 libc::ERANGE => ERANGE,
2573 libc::EAGAIN => EAGAIN,
2574 libc::EINPROGRESS => EINPROGRESS,
2575 libc::EALREADY => EALREADY,
2576 libc::ENOTSOCK => ENOTSOCK,
2577 libc::EDESTADDRREQ => EDESTADDRREQ,
2578 libc::EMSGSIZE => EMSGSIZE,
2579 libc::EPROTOTYPE => EPROTOTYPE,
2580 libc::ENOPROTOOPT => ENOPROTOOPT,
2581 libc::EPROTONOSUPPORT => EPROTONOSUPPORT,
2582 libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT,
2583 libc::EOPNOTSUPP => EOPNOTSUPP,
2584 libc::EPFNOSUPPORT => EPFNOSUPPORT,
2585 libc::EAFNOSUPPORT => EAFNOSUPPORT,
2586 libc::EADDRINUSE => EADDRINUSE,
2587 libc::EADDRNOTAVAIL => EADDRNOTAVAIL,
2588 libc::ENETDOWN => ENETDOWN,
2589 libc::ENETUNREACH => ENETUNREACH,
2590 libc::ENETRESET => ENETRESET,
2591 libc::ECONNABORTED => ECONNABORTED,
2592 libc::ECONNRESET => ECONNRESET,
2593 libc::ENOBUFS => ENOBUFS,
2594 libc::EISCONN => EISCONN,
2595 libc::ENOTCONN => ENOTCONN,
2596 libc::ESHUTDOWN => ESHUTDOWN,
2597 libc::ETOOMANYREFS => ETOOMANYREFS,
2598 libc::ETIMEDOUT => ETIMEDOUT,
2599 libc::ECONNREFUSED => ECONNREFUSED,
2600 libc::ELOOP => ELOOP,
2601 libc::ENAMETOOLONG => ENAMETOOLONG,
2602 libc::EHOSTDOWN => EHOSTDOWN,
2603 libc::EHOSTUNREACH => EHOSTUNREACH,
2604 libc::ENOTEMPTY => ENOTEMPTY,
2605 libc::EPROCLIM => EPROCLIM,
2606 libc::EUSERS => EUSERS,
2607 libc::EDQUOT => EDQUOT,
2608 libc::ESTALE => ESTALE,
2609 libc::EREMOTE => EREMOTE,
2610 libc::EBADRPC => EBADRPC,
2611 libc::ERPCMISMATCH => ERPCMISMATCH,
2612 libc::EPROGUNAVAIL => EPROGUNAVAIL,
2613 libc::EPROGMISMATCH => EPROGMISMATCH,
2614 libc::EPROCUNAVAIL => EPROCUNAVAIL,
2615 libc::ENOLCK => ENOLCK,
2616 libc::ENOSYS => ENOSYS,
2617 libc::EFTYPE => EFTYPE,
2618 libc::EAUTH => EAUTH,
2619 libc::ENEEDAUTH => ENEEDAUTH,
2620 libc::EIDRM => EIDRM,
2621 libc::ENOMSG => ENOMSG,
2622 libc::EOVERFLOW => EOVERFLOW,
2623 libc::EILSEQ => EILSEQ,
2624 libc::ENOTSUP => ENOTSUP,
2625 libc::ECANCELED => ECANCELED,
2626 libc::EBADMSG => EBADMSG,
2627 libc::ENODATA => ENODATA,
2628 libc::ENOSR => ENOSR,
2629 libc::ENOSTR => ENOSTR,
2630 libc::ETIME => ETIME,
2631 libc::ENOATTR => ENOATTR,
2632 libc::EMULTIHOP => EMULTIHOP,
2633 libc::ENOLINK => ENOLINK,
2634 libc::EPROTO => EPROTO,
2635 _ => UnknownErrno,
2636 }
2637 }
2638}
2639
2640#[cfg(target_os = "redox")]
2641mod consts {
2642 #[derive(Clone, Copy, Debug, Eq, PartialEq)]
2643 #[repr(i32)]
2644 #[non_exhaustive]
2645 pub enum Errno {
2646 UnknownErrno = 0,
2647 EPERM = libc::EPERM,
2648 ENOENT = libc::ENOENT,
2649 ESRCH = libc::ESRCH,
2650 EINTR = libc::EINTR,
2651 EIO = libc::EIO,
2652 ENXIO = libc::ENXIO,
2653 E2BIG = libc::E2BIG,
2654 ENOEXEC = libc::ENOEXEC,
2655 EBADF = libc::EBADF,
2656 ECHILD = libc::ECHILD,
2657 EDEADLK = libc::EDEADLK,
2658 ENOMEM = libc::ENOMEM,
2659 EACCES = libc::EACCES,
2660 EFAULT = libc::EFAULT,
2661 ENOTBLK = libc::ENOTBLK,
2662 EBUSY = libc::EBUSY,
2663 EEXIST = libc::EEXIST,
2664 EXDEV = libc::EXDEV,
2665 ENODEV = libc::ENODEV,
2666 ENOTDIR = libc::ENOTDIR,
2667 EISDIR = libc::EISDIR,
2668 EINVAL = libc::EINVAL,
2669 ENFILE = libc::ENFILE,
2670 EMFILE = libc::EMFILE,
2671 ENOTTY = libc::ENOTTY,
2672 ETXTBSY = libc::ETXTBSY,
2673 EFBIG = libc::EFBIG,
2674 ENOSPC = libc::ENOSPC,
2675 ESPIPE = libc::ESPIPE,
2676 EROFS = libc::EROFS,
2677 EMLINK = libc::EMLINK,
2678 EPIPE = libc::EPIPE,
2679 EDOM = libc::EDOM,
2680 ERANGE = libc::ERANGE,
2681 EAGAIN = libc::EAGAIN,
2682 EINPROGRESS = libc::EINPROGRESS,
2683 EALREADY = libc::EALREADY,
2684 ENOTSOCK = libc::ENOTSOCK,
2685 EDESTADDRREQ = libc::EDESTADDRREQ,
2686 EMSGSIZE = libc::EMSGSIZE,
2687 EPROTOTYPE = libc::EPROTOTYPE,
2688 ENOPROTOOPT = libc::ENOPROTOOPT,
2689 EPROTONOSUPPORT = libc::EPROTONOSUPPORT,
2690 ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT,
2691 EOPNOTSUPP = libc::EOPNOTSUPP,
2692 EPFNOSUPPORT = libc::EPFNOSUPPORT,
2693 EAFNOSUPPORT = libc::EAFNOSUPPORT,
2694 EADDRINUSE = libc::EADDRINUSE,
2695 EADDRNOTAVAIL = libc::EADDRNOTAVAIL,
2696 ENETDOWN = libc::ENETDOWN,
2697 ENETUNREACH = libc::ENETUNREACH,
2698 ENETRESET = libc::ENETRESET,
2699 ECONNABORTED = libc::ECONNABORTED,
2700 ECONNRESET = libc::ECONNRESET,
2701 ENOBUFS = libc::ENOBUFS,
2702 EISCONN = libc::EISCONN,
2703 ENOTCONN = libc::ENOTCONN,
2704 ESHUTDOWN = libc::ESHUTDOWN,
2705 ETOOMANYREFS = libc::ETOOMANYREFS,
2706 ETIMEDOUT = libc::ETIMEDOUT,
2707 ECONNREFUSED = libc::ECONNREFUSED,
2708 ELOOP = libc::ELOOP,
2709 ENAMETOOLONG = libc::ENAMETOOLONG,
2710 EHOSTDOWN = libc::EHOSTDOWN,
2711 EHOSTUNREACH = libc::EHOSTUNREACH,
2712 ENOTEMPTY = libc::ENOTEMPTY,
2713 EUSERS = libc::EUSERS,
2714 EDQUOT = libc::EDQUOT,
2715 ESTALE = libc::ESTALE,
2716 EREMOTE = libc::EREMOTE,
2717 ENOLCK = libc::ENOLCK,
2718 ENOSYS = libc::ENOSYS,
2719 EIDRM = libc::EIDRM,
2720 ENOMSG = libc::ENOMSG,
2721 EOVERFLOW = libc::EOVERFLOW,
2722 EILSEQ = libc::EILSEQ,
2723 ECANCELED = libc::ECANCELED,
2724 EBADMSG = libc::EBADMSG,
2725 ENODATA = libc::ENODATA,
2726 ENOSR = libc::ENOSR,
2727 ENOSTR = libc::ENOSTR,
2728 ETIME = libc::ETIME,
2729 EMULTIHOP = libc::EMULTIHOP,
2730 ENOLINK = libc::ENOLINK,
2731 EPROTO = libc::EPROTO,
2732 }
2733
2734 #[deprecated(
2735 since = "0.22.1",
2736 note = "use nix::errno::Errno::EWOULDBLOCK instead"
2737 )]
2738 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
2739
2740 impl Errno {
2741 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
2742 }
2743
2744 pub const fn from_i32(e: i32) -> Errno {
2745 use self::Errno::*;
2746
2747 match e {
2748 libc::EPERM => EPERM,
2749 libc::ENOENT => ENOENT,
2750 libc::ESRCH => ESRCH,
2751 libc::EINTR => EINTR,
2752 libc::EIO => EIO,
2753 libc::ENXIO => ENXIO,
2754 libc::E2BIG => E2BIG,
2755 libc::ENOEXEC => ENOEXEC,
2756 libc::EBADF => EBADF,
2757 libc::ECHILD => ECHILD,
2758 libc::EDEADLK => EDEADLK,
2759 libc::ENOMEM => ENOMEM,
2760 libc::EACCES => EACCES,
2761 libc::EFAULT => EFAULT,
2762 libc::ENOTBLK => ENOTBLK,
2763 libc::EBUSY => EBUSY,
2764 libc::EEXIST => EEXIST,
2765 libc::EXDEV => EXDEV,
2766 libc::ENODEV => ENODEV,
2767 libc::ENOTDIR => ENOTDIR,
2768 libc::EISDIR => EISDIR,
2769 libc::EINVAL => EINVAL,
2770 libc::ENFILE => ENFILE,
2771 libc::EMFILE => EMFILE,
2772 libc::ENOTTY => ENOTTY,
2773 libc::ETXTBSY => ETXTBSY,
2774 libc::EFBIG => EFBIG,
2775 libc::ENOSPC => ENOSPC,
2776 libc::ESPIPE => ESPIPE,
2777 libc::EROFS => EROFS,
2778 libc::EMLINK => EMLINK,
2779 libc::EPIPE => EPIPE,
2780 libc::EDOM => EDOM,
2781 libc::ERANGE => ERANGE,
2782 libc::EAGAIN => EAGAIN,
2783 libc::EINPROGRESS => EINPROGRESS,
2784 libc::EALREADY => EALREADY,
2785 libc::ENOTSOCK => ENOTSOCK,
2786 libc::EDESTADDRREQ => EDESTADDRREQ,
2787 libc::EMSGSIZE => EMSGSIZE,
2788 libc::EPROTOTYPE => EPROTOTYPE,
2789 libc::ENOPROTOOPT => ENOPROTOOPT,
2790 libc::EPROTONOSUPPORT => EPROTONOSUPPORT,
2791 libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT,
2792 libc::EOPNOTSUPP => EOPNOTSUPP,
2793 libc::EPFNOSUPPORT => EPFNOSUPPORT,
2794 libc::EAFNOSUPPORT => EAFNOSUPPORT,
2795 libc::EADDRINUSE => EADDRINUSE,
2796 libc::EADDRNOTAVAIL => EADDRNOTAVAIL,
2797 libc::ENETDOWN => ENETDOWN,
2798 libc::ENETUNREACH => ENETUNREACH,
2799 libc::ENETRESET => ENETRESET,
2800 libc::ECONNABORTED => ECONNABORTED,
2801 libc::ECONNRESET => ECONNRESET,
2802 libc::ENOBUFS => ENOBUFS,
2803 libc::EISCONN => EISCONN,
2804 libc::ENOTCONN => ENOTCONN,
2805 libc::ESHUTDOWN => ESHUTDOWN,
2806 libc::ETOOMANYREFS => ETOOMANYREFS,
2807 libc::ETIMEDOUT => ETIMEDOUT,
2808 libc::ECONNREFUSED => ECONNREFUSED,
2809 libc::ELOOP => ELOOP,
2810 libc::ENAMETOOLONG => ENAMETOOLONG,
2811 libc::EHOSTDOWN => EHOSTDOWN,
2812 libc::EHOSTUNREACH => EHOSTUNREACH,
2813 libc::ENOTEMPTY => ENOTEMPTY,
2814 libc::EUSERS => EUSERS,
2815 libc::EDQUOT => EDQUOT,
2816 libc::ESTALE => ESTALE,
2817 libc::EREMOTE => EREMOTE,
2818 libc::ENOLCK => ENOLCK,
2819 libc::ENOSYS => ENOSYS,
2820 libc::EIDRM => EIDRM,
2821 libc::ENOMSG => ENOMSG,
2822 libc::EOVERFLOW => EOVERFLOW,
2823 libc::EILSEQ => EILSEQ,
2824 libc::ECANCELED => ECANCELED,
2825 libc::EBADMSG => EBADMSG,
2826 libc::ENODATA => ENODATA,
2827 libc::ENOSR => ENOSR,
2828 libc::ENOSTR => ENOSTR,
2829 libc::ETIME => ETIME,
2830 libc::EMULTIHOP => EMULTIHOP,
2831 libc::ENOLINK => ENOLINK,
2832 libc::EPROTO => EPROTO,
2833 _ => UnknownErrno,
2834 }
2835 }
2836}
2837
2838#[cfg(any(target_os = "illumos", target_os = "solaris"))]
2839mod consts {
2840 #[derive(Clone, Copy, Debug, Eq, PartialEq)]
2841 #[repr(i32)]
2842 #[non_exhaustive]
2843 pub enum Errno {
2844 UnknownErrno = 0,
2845 EPERM = libc::EPERM,
2846 ENOENT = libc::ENOENT,
2847 ESRCH = libc::ESRCH,
2848 EINTR = libc::EINTR,
2849 EIO = libc::EIO,
2850 ENXIO = libc::ENXIO,
2851 E2BIG = libc::E2BIG,
2852 ENOEXEC = libc::ENOEXEC,
2853 EBADF = libc::EBADF,
2854 ECHILD = libc::ECHILD,
2855 EAGAIN = libc::EAGAIN,
2856 ENOMEM = libc::ENOMEM,
2857 EACCES = libc::EACCES,
2858 EFAULT = libc::EFAULT,
2859 ENOTBLK = libc::ENOTBLK,
2860 EBUSY = libc::EBUSY,
2861 EEXIST = libc::EEXIST,
2862 EXDEV = libc::EXDEV,
2863 ENODEV = libc::ENODEV,
2864 ENOTDIR = libc::ENOTDIR,
2865 EISDIR = libc::EISDIR,
2866 EINVAL = libc::EINVAL,
2867 ENFILE = libc::ENFILE,
2868 EMFILE = libc::EMFILE,
2869 ENOTTY = libc::ENOTTY,
2870 ETXTBSY = libc::ETXTBSY,
2871 EFBIG = libc::EFBIG,
2872 ENOSPC = libc::ENOSPC,
2873 ESPIPE = libc::ESPIPE,
2874 EROFS = libc::EROFS,
2875 EMLINK = libc::EMLINK,
2876 EPIPE = libc::EPIPE,
2877 EDOM = libc::EDOM,
2878 ERANGE = libc::ERANGE,
2879 ENOMSG = libc::ENOMSG,
2880 EIDRM = libc::EIDRM,
2881 ECHRNG = libc::ECHRNG,
2882 EL2NSYNC = libc::EL2NSYNC,
2883 EL3HLT = libc::EL3HLT,
2884 EL3RST = libc::EL3RST,
2885 ELNRNG = libc::ELNRNG,
2886 EUNATCH = libc::EUNATCH,
2887 ENOCSI = libc::ENOCSI,
2888 EL2HLT = libc::EL2HLT,
2889 EDEADLK = libc::EDEADLK,
2890 ENOLCK = libc::ENOLCK,
2891 ECANCELED = libc::ECANCELED,
2892 ENOTSUP = libc::ENOTSUP,
2893 EDQUOT = libc::EDQUOT,
2894 EBADE = libc::EBADE,
2895 EBADR = libc::EBADR,
2896 EXFULL = libc::EXFULL,
2897 ENOANO = libc::ENOANO,
2898 EBADRQC = libc::EBADRQC,
2899 EBADSLT = libc::EBADSLT,
2900 EDEADLOCK = libc::EDEADLOCK,
2901 EBFONT = libc::EBFONT,
2902 EOWNERDEAD = libc::EOWNERDEAD,
2903 ENOTRECOVERABLE = libc::ENOTRECOVERABLE,
2904 ENOSTR = libc::ENOSTR,
2905 ENODATA = libc::ENODATA,
2906 ETIME = libc::ETIME,
2907 ENOSR = libc::ENOSR,
2908 ENONET = libc::ENONET,
2909 ENOPKG = libc::ENOPKG,
2910 EREMOTE = libc::EREMOTE,
2911 ENOLINK = libc::ENOLINK,
2912 EADV = libc::EADV,
2913 ESRMNT = libc::ESRMNT,
2914 ECOMM = libc::ECOMM,
2915 EPROTO = libc::EPROTO,
2916 ELOCKUNMAPPED = libc::ELOCKUNMAPPED,
2917 ENOTACTIVE = libc::ENOTACTIVE,
2918 EMULTIHOP = libc::EMULTIHOP,
2919 EBADMSG = libc::EBADMSG,
2920 ENAMETOOLONG = libc::ENAMETOOLONG,
2921 EOVERFLOW = libc::EOVERFLOW,
2922 ENOTUNIQ = libc::ENOTUNIQ,
2923 EBADFD = libc::EBADFD,
2924 EREMCHG = libc::EREMCHG,
2925 ELIBACC = libc::ELIBACC,
2926 ELIBBAD = libc::ELIBBAD,
2927 ELIBSCN = libc::ELIBSCN,
2928 ELIBMAX = libc::ELIBMAX,
2929 ELIBEXEC = libc::ELIBEXEC,
2930 EILSEQ = libc::EILSEQ,
2931 ENOSYS = libc::ENOSYS,
2932 ELOOP = libc::ELOOP,
2933 ERESTART = libc::ERESTART,
2934 ESTRPIPE = libc::ESTRPIPE,
2935 ENOTEMPTY = libc::ENOTEMPTY,
2936 EUSERS = libc::EUSERS,
2937 ENOTSOCK = libc::ENOTSOCK,
2938 EDESTADDRREQ = libc::EDESTADDRREQ,
2939 EMSGSIZE = libc::EMSGSIZE,
2940 EPROTOTYPE = libc::EPROTOTYPE,
2941 ENOPROTOOPT = libc::ENOPROTOOPT,
2942 EPROTONOSUPPORT = libc::EPROTONOSUPPORT,
2943 ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT,
2944 EOPNOTSUPP = libc::EOPNOTSUPP,
2945 EPFNOSUPPORT = libc::EPFNOSUPPORT,
2946 EAFNOSUPPORT = libc::EAFNOSUPPORT,
2947 EADDRINUSE = libc::EADDRINUSE,
2948 EADDRNOTAVAIL = libc::EADDRNOTAVAIL,
2949 ENETDOWN = libc::ENETDOWN,
2950 ENETUNREACH = libc::ENETUNREACH,
2951 ENETRESET = libc::ENETRESET,
2952 ECONNABORTED = libc::ECONNABORTED,
2953 ECONNRESET = libc::ECONNRESET,
2954 ENOBUFS = libc::ENOBUFS,
2955 EISCONN = libc::EISCONN,
2956 ENOTCONN = libc::ENOTCONN,
2957 ESHUTDOWN = libc::ESHUTDOWN,
2958 ETOOMANYREFS = libc::ETOOMANYREFS,
2959 ETIMEDOUT = libc::ETIMEDOUT,
2960 ECONNREFUSED = libc::ECONNREFUSED,
2961 EHOSTDOWN = libc::EHOSTDOWN,
2962 EHOSTUNREACH = libc::EHOSTUNREACH,
2963 EALREADY = libc::EALREADY,
2964 EINPROGRESS = libc::EINPROGRESS,
2965 ESTALE = libc::ESTALE,
2966 }
2967
2968 #[deprecated(
2969 since = "0.22.1",
2970 note = "use nix::errno::Errno::ELAST instead"
2971 )]
2972 pub const ELAST: Errno = Errno::ELAST;
2973 #[deprecated(
2974 since = "0.22.1",
2975 note = "use nix::errno::Errno::EWOULDBLOCK instead"
2976 )]
2977 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
2978
2979 impl Errno {
2980 pub const ELAST: Errno = Errno::ESTALE;
2981 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
2982 }
2983
2984 pub const fn from_i32(e: i32) -> Errno {
2985 use self::Errno::*;
2986
2987 match e {
2988 libc::EPERM => EPERM,
2989 libc::ENOENT => ENOENT,
2990 libc::ESRCH => ESRCH,
2991 libc::EINTR => EINTR,
2992 libc::EIO => EIO,
2993 libc::ENXIO => ENXIO,
2994 libc::E2BIG => E2BIG,
2995 libc::ENOEXEC => ENOEXEC,
2996 libc::EBADF => EBADF,
2997 libc::ECHILD => ECHILD,
2998 libc::EAGAIN => EAGAIN,
2999 libc::ENOMEM => ENOMEM,
3000 libc::EACCES => EACCES,
3001 libc::EFAULT => EFAULT,
3002 libc::ENOTBLK => ENOTBLK,
3003 libc::EBUSY => EBUSY,
3004 libc::EEXIST => EEXIST,
3005 libc::EXDEV => EXDEV,
3006 libc::ENODEV => ENODEV,
3007 libc::ENOTDIR => ENOTDIR,
3008 libc::EISDIR => EISDIR,
3009 libc::EINVAL => EINVAL,
3010 libc::ENFILE => ENFILE,
3011 libc::EMFILE => EMFILE,
3012 libc::ENOTTY => ENOTTY,
3013 libc::ETXTBSY => ETXTBSY,
3014 libc::EFBIG => EFBIG,
3015 libc::ENOSPC => ENOSPC,
3016 libc::ESPIPE => ESPIPE,
3017 libc::EROFS => EROFS,
3018 libc::EMLINK => EMLINK,
3019 libc::EPIPE => EPIPE,
3020 libc::EDOM => EDOM,
3021 libc::ERANGE => ERANGE,
3022 libc::ENOMSG => ENOMSG,
3023 libc::EIDRM => EIDRM,
3024 libc::ECHRNG => ECHRNG,
3025 libc::EL2NSYNC => EL2NSYNC,
3026 libc::EL3HLT => EL3HLT,
3027 libc::EL3RST => EL3RST,
3028 libc::ELNRNG => ELNRNG,
3029 libc::EUNATCH => EUNATCH,
3030 libc::ENOCSI => ENOCSI,
3031 libc::EL2HLT => EL2HLT,
3032 libc::EDEADLK => EDEADLK,
3033 libc::ENOLCK => ENOLCK,
3034 libc::ECANCELED => ECANCELED,
3035 libc::ENOTSUP => ENOTSUP,
3036 libc::EDQUOT => EDQUOT,
3037 libc::EBADE => EBADE,
3038 libc::EBADR => EBADR,
3039 libc::EXFULL => EXFULL,
3040 libc::ENOANO => ENOANO,
3041 libc::EBADRQC => EBADRQC,
3042 libc::EBADSLT => EBADSLT,
3043 libc::EDEADLOCK => EDEADLOCK,
3044 libc::EBFONT => EBFONT,
3045 libc::EOWNERDEAD => EOWNERDEAD,
3046 libc::ENOTRECOVERABLE => ENOTRECOVERABLE,
3047 libc::ENOSTR => ENOSTR,
3048 libc::ENODATA => ENODATA,
3049 libc::ETIME => ETIME,
3050 libc::ENOSR => ENOSR,
3051 libc::ENONET => ENONET,
3052 libc::ENOPKG => ENOPKG,
3053 libc::EREMOTE => EREMOTE,
3054 libc::ENOLINK => ENOLINK,
3055 libc::EADV => EADV,
3056 libc::ESRMNT => ESRMNT,
3057 libc::ECOMM => ECOMM,
3058 libc::EPROTO => EPROTO,
3059 libc::ELOCKUNMAPPED => ELOCKUNMAPPED,
3060 libc::ENOTACTIVE => ENOTACTIVE,
3061 libc::EMULTIHOP => EMULTIHOP,
3062 libc::EBADMSG => EBADMSG,
3063 libc::ENAMETOOLONG => ENAMETOOLONG,
3064 libc::EOVERFLOW => EOVERFLOW,
3065 libc::ENOTUNIQ => ENOTUNIQ,
3066 libc::EBADFD => EBADFD,
3067 libc::EREMCHG => EREMCHG,
3068 libc::ELIBACC => ELIBACC,
3069 libc::ELIBBAD => ELIBBAD,
3070 libc::ELIBSCN => ELIBSCN,
3071 libc::ELIBMAX => ELIBMAX,
3072 libc::ELIBEXEC => ELIBEXEC,
3073 libc::EILSEQ => EILSEQ,
3074 libc::ENOSYS => ENOSYS,
3075 libc::ELOOP => ELOOP,
3076 libc::ERESTART => ERESTART,
3077 libc::ESTRPIPE => ESTRPIPE,
3078 libc::ENOTEMPTY => ENOTEMPTY,
3079 libc::EUSERS => EUSERS,
3080 libc::ENOTSOCK => ENOTSOCK,
3081 libc::EDESTADDRREQ => EDESTADDRREQ,
3082 libc::EMSGSIZE => EMSGSIZE,
3083 libc::EPROTOTYPE => EPROTOTYPE,
3084 libc::ENOPROTOOPT => ENOPROTOOPT,
3085 libc::EPROTONOSUPPORT => EPROTONOSUPPORT,
3086 libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT,
3087 libc::EOPNOTSUPP => EOPNOTSUPP,
3088 libc::EPFNOSUPPORT => EPFNOSUPPORT,
3089 libc::EAFNOSUPPORT => EAFNOSUPPORT,
3090 libc::EADDRINUSE => EADDRINUSE,
3091 libc::EADDRNOTAVAIL => EADDRNOTAVAIL,
3092 libc::ENETDOWN => ENETDOWN,
3093 libc::ENETUNREACH => ENETUNREACH,
3094 libc::ENETRESET => ENETRESET,
3095 libc::ECONNABORTED => ECONNABORTED,
3096 libc::ECONNRESET => ECONNRESET,
3097 libc::ENOBUFS => ENOBUFS,
3098 libc::EISCONN => EISCONN,
3099 libc::ENOTCONN => ENOTCONN,
3100 libc::ESHUTDOWN => ESHUTDOWN,
3101 libc::ETOOMANYREFS => ETOOMANYREFS,
3102 libc::ETIMEDOUT => ETIMEDOUT,
3103 libc::ECONNREFUSED => ECONNREFUSED,
3104 libc::EHOSTDOWN => EHOSTDOWN,
3105 libc::EHOSTUNREACH => EHOSTUNREACH,
3106 libc::EALREADY => EALREADY,
3107 libc::EINPROGRESS => EINPROGRESS,
3108 libc::ESTALE => ESTALE,
3109 _ => UnknownErrno,
3110 }
3111 }
3112}
3113
3114#[cfg(target_os = "haiku")]
3115mod consts {
3116 #[derive(Clone, Copy, Debug, Eq, PartialEq)]
3117 #[repr(i32)]
3118 #[non_exhaustive]
3119 pub enum Errno {
3120 UnknownErrno = 0,
3121 EPERM = libc::EPERM,
3122 ENOENT = libc::ENOENT,
3123 ESRCH = libc::ESRCH,
3124 EINTR = libc::EINTR,
3125 EIO = libc::EIO,
3126 ENXIO = libc::ENXIO,
3127 E2BIG = libc::E2BIG,
3128 ENOEXEC = libc::ENOEXEC,
3129 EBADF = libc::EBADF,
3130 ECHILD = libc::ECHILD,
3131 EDEADLK = libc::EDEADLK,
3132 ENOMEM = libc::ENOMEM,
3133 EACCES = libc::EACCES,
3134 EFAULT = libc::EFAULT,
3135 EBUSY = libc::EBUSY,
3136 EEXIST = libc::EEXIST,
3137 EXDEV = libc::EXDEV,
3138 ENODEV = libc::ENODEV,
3139 ENOTDIR = libc::ENOTDIR,
3140 EISDIR = libc::EISDIR,
3141 EINVAL = libc::EINVAL,
3142 ENFILE = libc::ENFILE,
3143 EMFILE = libc::EMFILE,
3144 ENOTTY = libc::ENOTTY,
3145 ETXTBSY = libc::ETXTBSY,
3146 EFBIG = libc::EFBIG,
3147 ENOSPC = libc::ENOSPC,
3148 ESPIPE = libc::ESPIPE,
3149 EROFS = libc::EROFS,
3150 EMLINK = libc::EMLINK,
3151 EPIPE = libc::EPIPE,
3152 EDOM = libc::EDOM,
3153 ERANGE = libc::ERANGE,
3154 EAGAIN = libc::EAGAIN,
3155 EINPROGRESS = libc::EINPROGRESS,
3156 EALREADY = libc::EALREADY,
3157 ENOTSOCK = libc::ENOTSOCK,
3158 EDESTADDRREQ = libc::EDESTADDRREQ,
3159 EMSGSIZE = libc::EMSGSIZE,
3160 EPROTOTYPE = libc::EPROTOTYPE,
3161 ENOPROTOOPT = libc::ENOPROTOOPT,
3162 EPROTONOSUPPORT = libc::EPROTONOSUPPORT,
3163 ENOTSUP = libc::ENOTSUP,
3164 EADDRINUSE = libc::EADDRINUSE,
3165 EADDRNOTAVAIL = libc::EADDRNOTAVAIL,
3166 ENETDOWN = libc::ENETDOWN,
3167 ENETUNREACH = libc::ENETUNREACH,
3168 ENETRESET = libc::ENETRESET,
3169 ECONNABORTED = libc::ECONNABORTED,
3170 ECONNRESET = libc::ECONNRESET,
3171 ENOBUFS = libc::ENOBUFS,
3172 EISCONN = libc::EISCONN,
3173 ENOTCONN = libc::ENOTCONN,
3174 ESHUTDOWN = libc::ESHUTDOWN,
3175 ETIMEDOUT = libc::ETIMEDOUT,
3176 ECONNREFUSED = libc::ECONNREFUSED,
3177 ELOOP = libc::ELOOP,
3178 ENAMETOOLONG = libc::ENAMETOOLONG,
3179 EHOSTDOWN = libc::EHOSTDOWN,
3180 EHOSTUNREACH = libc::EHOSTUNREACH,
3181 ENOTEMPTY = libc::ENOTEMPTY,
3182 EDQUOT = libc::EDQUOT,
3183 ESTALE = libc::ESTALE,
3184 ENOLCK = libc::ENOLCK,
3185 ENOSYS = libc::ENOSYS,
3186 EIDRM = libc::EIDRM,
3187 ENOMSG = libc::ENOMSG,
3188 EOVERFLOW = libc::EOVERFLOW,
3189 ECANCELED = libc::ECANCELED,
3190 EILSEQ = libc::EILSEQ,
3191 ENOATTR = libc::ENOATTR,
3192 EBADMSG = libc::EBADMSG,
3193 EMULTIHOP = libc::EMULTIHOP,
3194 ENOLINK = libc::ENOLINK,
3195 EPROTO = libc::EPROTO,
3196 }
3197
3198 impl Errno {
3199 pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
3200 pub const EDEADLOCK: Errno = Errno::EDEADLK;
3201 pub const EOPNOTSUPP: Errno = Errno::ENOTSUP;
3202 }
3203
3204 pub const fn from_i32(e: i32) -> Errno {
3205 use self::Errno::*;
3206
3207 match e {
3208 libc::EPERM => EPERM,
3209 libc::ENOENT => ENOENT,
3210 libc::ESRCH => ESRCH,
3211 libc::EINTR => EINTR,
3212 libc::EIO => EIO,
3213 libc::ENXIO => ENXIO,
3214 libc::E2BIG => E2BIG,
3215 libc::ENOEXEC => ENOEXEC,
3216 libc::EBADF => EBADF,
3217 libc::ECHILD => ECHILD,
3218 libc::EDEADLK => EDEADLK,
3219 libc::ENOMEM => ENOMEM,
3220 libc::EACCES => EACCES,
3221 libc::EFAULT => EFAULT,
3222 libc::EBUSY => EBUSY,
3223 libc::EEXIST => EEXIST,
3224 libc::EXDEV => EXDEV,
3225 libc::ENODEV => ENODEV,
3226 libc::ENOTDIR => ENOTDIR,
3227 libc::EISDIR => EISDIR,
3228 libc::EINVAL => EINVAL,
3229 libc::ENFILE => ENFILE,
3230 libc::EMFILE => EMFILE,
3231 libc::ENOTTY => ENOTTY,
3232 libc::ETXTBSY => ETXTBSY,
3233 libc::EFBIG => EFBIG,
3234 libc::ENOSPC => ENOSPC,
3235 libc::ESPIPE => ESPIPE,
3236 libc::EROFS => EROFS,
3237 libc::EMLINK => EMLINK,
3238 libc::EPIPE => EPIPE,
3239 libc::EDOM => EDOM,
3240 libc::ERANGE => ERANGE,
3241 libc::EAGAIN => EAGAIN,
3242 libc::EINPROGRESS => EINPROGRESS,
3243 libc::EALREADY => EALREADY,
3244 libc::ENOTSOCK => ENOTSOCK,
3245 libc::EDESTADDRREQ => EDESTADDRREQ,
3246 libc::EMSGSIZE => EMSGSIZE,
3247 libc::EPROTOTYPE => EPROTOTYPE,
3248 libc::ENOPROTOOPT => ENOPROTOOPT,
3249 libc::EPROTONOSUPPORT => EPROTONOSUPPORT,
3250 libc::ENOTSUP => ENOTSUP,
3251 libc::EADDRINUSE => EADDRINUSE,
3252 libc::EADDRNOTAVAIL => EADDRNOTAVAIL,
3253 libc::ENETDOWN => ENETDOWN,
3254 libc::ENETUNREACH => ENETUNREACH,
3255 libc::ENETRESET => ENETRESET,
3256 libc::ECONNABORTED => ECONNABORTED,
3257 libc::ECONNRESET => ECONNRESET,
3258 libc::ENOBUFS => ENOBUFS,
3259 libc::EISCONN => EISCONN,
3260 libc::ENOTCONN => ENOTCONN,
3261 libc::ESHUTDOWN => ESHUTDOWN,
3262 libc::ETIMEDOUT => ETIMEDOUT,
3263 libc::ECONNREFUSED => ECONNREFUSED,
3264 libc::ELOOP => ELOOP,
3265 libc::ENAMETOOLONG => ENAMETOOLONG,
3266 libc::EHOSTDOWN => EHOSTDOWN,
3267 libc::EHOSTUNREACH => EHOSTUNREACH,
3268 libc::ENOTEMPTY => ENOTEMPTY,
3269 libc::EDQUOT => EDQUOT,
3270 libc::ESTALE => ESTALE,
3271 libc::ENOLCK => ENOLCK,
3272 libc::ENOSYS => ENOSYS,
3273 libc::EIDRM => EIDRM,
3274 libc::ENOMSG => ENOMSG,
3275 libc::EOVERFLOW => EOVERFLOW,
3276 libc::ECANCELED => ECANCELED,
3277 libc::EILSEQ => EILSEQ,
3278 libc::ENOATTR => ENOATTR,
3279 libc::EBADMSG => EBADMSG,
3280 libc::EMULTIHOP => EMULTIHOP,
3281 libc::ENOLINK => ENOLINK,
3282 libc::EPROTO => EPROTO,
3283 _ => UnknownErrno,
3284 }
3285 }
3286}