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