1 //! The `rustix` `Errno` type.
2 //!
3 //! This type holds an OS error code, which conceptually corresponds to an
4 //! `errno` value.
5 //!
6 //! # Safety
7 //!
8 //! Linux uses error codes in `-4095..0`; we use rustc attributes to describe
9 //! this restricted range of values.
10 #![allow(unsafe_code)]
11 #![cfg_attr(not(rustc_attrs), allow(unused_unsafe))]
12
13 use crate::backend::c;
14 use crate::backend::fd::RawFd;
15 use crate::backend::reg::{RetNumber, RetReg};
16 use crate::io;
17 use linux_raw_sys::errno;
18
19 /// `errno`—An error code.
20 ///
21 /// The error type for `rustix` APIs. This is similar to [`std::io::Error`],
22 /// but only holds an OS error code, and no extra error value.
23 ///
24 /// # References
25 /// - [POSIX]
26 /// - [Linux]
27 /// - [Winsock]
28 /// - [FreeBSD]
29 /// - [NetBSD]
30 /// - [OpenBSD]
31 /// - [DragonFly BSD]
32 /// - [illumos]
33 /// - [glibc]
34 ///
35 /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/errno.html
36 /// [Linux]: https://man7.org/linux/man-pages/man3/errno.3.html
37 /// [Winsock]: https://learn.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
38 /// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?errno
39 /// [NetBSD]: https://man.netbsd.org/errno.2
40 /// [OpenBSD]: https://man.openbsd.org/errno.2
41 /// [DragonFly BSD]: https://man.dragonflybsd.org/?command=errno§ion=2
42 /// [illumos]: https://illumos.org/man/3C/errno
43 /// [glibc]: https://www.gnu.org/software/libc/manual/html_node/Error-Codes.html
44 /// [`std::io::Error`]: Result
45 #[repr(transparent)]
46 #[doc(alias = "errno")]
47 #[derive(Eq, PartialEq, Hash, Copy, Clone)]
48 // Linux returns negated error codes, and we leave them in negated form, so
49 // error codes are in `-4095..0`.
50 #[cfg_attr(rustc_attrs, rustc_layout_scalar_valid_range_start(0xf001))]
51 #[cfg_attr(rustc_attrs, rustc_layout_scalar_valid_range_end(0xffff))]
52 pub struct Errno(u16);
53
54 impl Errno {
55 /// Extract an `Errno` value from a `std::io::Error`.
56 ///
57 /// This isn't a `From` conversion because it's expected to be relatively
58 /// uncommon.
59 #[cfg(feature = "std")]
60 #[inline]
from_io_error(io_err: &std::io::Error) -> Option<Self>61 pub fn from_io_error(io_err: &std::io::Error) -> Option<Self> {
62 io_err.raw_os_error().and_then(|raw| {
63 // `std::io::Error` could theoretically have arbitrary OS error
64 // values, so check that they're in Linux's range.
65 if (1..4096).contains(&raw) {
66 Some(Self::from_errno(raw as u32))
67 } else {
68 None
69 }
70 })
71 }
72
73 /// Extract the raw OS error number from this error.
74 #[inline]
raw_os_error(self) -> i3275 pub const fn raw_os_error(self) -> i32 {
76 (self.0 as i16 as i32).wrapping_neg()
77 }
78
79 /// Construct an `Errno` from a raw OS error number.
80 #[inline]
from_raw_os_error(raw: i32) -> Self81 pub const fn from_raw_os_error(raw: i32) -> Self {
82 Self::from_errno(raw as u32)
83 }
84
85 /// Convert from a C `errno` value (which is positive) to an `Errno`.
from_errno(raw: u32) -> Self86 const fn from_errno(raw: u32) -> Self {
87 // We store error values in negated form, so that we don't have to
88 // negate them after every syscall.
89 let encoded = raw.wrapping_neg() as u16;
90
91 // TODO: Use Range::contains, once that's `const`.
92 assert!(encoded >= 0xf001);
93
94 // SAFETY: Linux syscalls return negated error values in the range
95 // `-4095..0`, which we just asserted.
96 unsafe { Self(encoded) }
97 }
98 }
99
100 /// Check for an error from the result of a syscall which encodes a
101 /// `c::c_int` on success.
102 #[inline]
try_decode_c_int<Num: RetNumber>( raw: RetReg<Num>, ) -> io::Result<c::c_int>103 pub(in crate::backend) fn try_decode_c_int<Num: RetNumber>(
104 raw: RetReg<Num>,
105 ) -> io::Result<c::c_int> {
106 if raw.is_in_range(-4095..0) {
107 // SAFETY: `raw` must be in `-4095..0`, and we just checked that raw is
108 // in that range.
109 return Err(unsafe { Errno(raw.decode_error_code()) });
110 }
111
112 Ok(raw.decode_c_int())
113 }
114
115 /// Check for an error from the result of a syscall which encodes a
116 /// `c::c_uint` on success.
117 #[inline]
try_decode_c_uint<Num: RetNumber>( raw: RetReg<Num>, ) -> io::Result<c::c_uint>118 pub(in crate::backend) fn try_decode_c_uint<Num: RetNumber>(
119 raw: RetReg<Num>,
120 ) -> io::Result<c::c_uint> {
121 if raw.is_in_range(-4095..0) {
122 // SAFETY: `raw` must be in `-4095..0`, and we just checked that raw is
123 // in that range.
124 return Err(unsafe { Errno(raw.decode_error_code()) });
125 }
126
127 Ok(raw.decode_c_uint())
128 }
129
130 /// Check for an error from the result of a syscall which encodes a `usize` on
131 /// success.
132 #[inline]
try_decode_usize<Num: RetNumber>(raw: RetReg<Num>) -> io::Result<usize>133 pub(in crate::backend) fn try_decode_usize<Num: RetNumber>(raw: RetReg<Num>) -> io::Result<usize> {
134 if raw.is_in_range(-4095..0) {
135 // SAFETY: `raw` must be in `-4095..0`, and we just checked that raw is
136 // in that range.
137 return Err(unsafe { Errno(raw.decode_error_code()) });
138 }
139
140 Ok(raw.decode_usize())
141 }
142
143 /// Check for an error from the result of a syscall which encodes a
144 /// `*mut c_void` on success.
145 #[inline]
try_decode_void_star<Num: RetNumber>( raw: RetReg<Num>, ) -> io::Result<*mut c::c_void>146 pub(in crate::backend) fn try_decode_void_star<Num: RetNumber>(
147 raw: RetReg<Num>,
148 ) -> io::Result<*mut c::c_void> {
149 if raw.is_in_range(-4095..0) {
150 // SAFETY: `raw` must be in `-4095..0`, and we just checked that raw is
151 // in that range.
152 return Err(unsafe { Errno(raw.decode_error_code()) });
153 }
154
155 Ok(raw.decode_void_star())
156 }
157
158 /// Check for an error from the result of a syscall which encodes a
159 /// `u64` on success.
160 #[cfg(target_pointer_width = "64")]
161 #[inline]
try_decode_u64<Num: RetNumber>(raw: RetReg<Num>) -> io::Result<u64>162 pub(in crate::backend) fn try_decode_u64<Num: RetNumber>(raw: RetReg<Num>) -> io::Result<u64> {
163 if raw.is_in_range(-4095..0) {
164 // SAFETY: `raw` must be in `-4095..0`, and we just checked that raw is
165 // in that range.
166 return Err(unsafe { Errno(raw.decode_error_code()) });
167 }
168
169 Ok(raw.decode_u64())
170 }
171
172 /// Check for an error from the result of a syscall which encodes a file
173 /// descriptor on success.
174 ///
175 /// # Safety
176 ///
177 /// This must only be used with syscalls which return file descriptors on
178 /// success.
179 #[inline]
try_decode_raw_fd<Num: RetNumber>( raw: RetReg<Num>, ) -> io::Result<RawFd>180 pub(in crate::backend) unsafe fn try_decode_raw_fd<Num: RetNumber>(
181 raw: RetReg<Num>,
182 ) -> io::Result<RawFd> {
183 // Instead of using `check_result` here, we just check for negative, since
184 // this function is only used for system calls which return file
185 // descriptors, and this produces smaller code.
186 if raw.is_negative() {
187 debug_assert!(raw.is_in_range(-4095..0));
188
189 // Tell the optimizer that we know the value is in the error range.
190 // This helps it avoid unnecessary integer conversions.
191 #[cfg(core_intrinsics)]
192 {
193 core::intrinsics::assume(raw.is_in_range(-4095..0));
194 }
195
196 return Err(Errno(raw.decode_error_code()));
197 }
198
199 Ok(raw.decode_raw_fd())
200 }
201
202 /// Check for an error from the result of a syscall which encodes no value on
203 /// success. On success, return the unconsumed `raw` value.
204 ///
205 /// # Safety
206 ///
207 /// This must only be used with syscalls which return no value on success.
208 #[inline]
try_decode_void<Num: RetNumber>( raw: RetReg<Num>, ) -> io::Result<()>209 pub(in crate::backend) unsafe fn try_decode_void<Num: RetNumber>(
210 raw: RetReg<Num>,
211 ) -> io::Result<()> {
212 // Instead of using `check_result` here, we just check for zero, since this
213 // function is only used for system calls which have no other return value,
214 // and this produces smaller code.
215 if raw.is_nonzero() {
216 debug_assert!(raw.is_in_range(-4095..0));
217
218 // Tell the optimizer that we know the value is in the error range.
219 // This helps it avoid unnecessary integer conversions.
220 #[cfg(core_intrinsics)]
221 {
222 core::intrinsics::assume(raw.is_in_range(-4095..0));
223 }
224
225 return Err(Errno(raw.decode_error_code()));
226 }
227
228 raw.decode_void();
229
230 Ok(())
231 }
232
233 /// Check for an error from the result of a syscall which does not return on
234 /// success. On success, return the unconsumed `raw` value.
235 ///
236 /// # Safety
237 ///
238 /// This must only be used with syscalls which do not return on success.
239 #[cfg(any(feature = "event", feature = "runtime"))]
240 #[inline]
try_decode_error<Num: RetNumber>(raw: RetReg<Num>) -> io::Errno241 pub(in crate::backend) unsafe fn try_decode_error<Num: RetNumber>(raw: RetReg<Num>) -> io::Errno {
242 debug_assert!(raw.is_in_range(-4095..0));
243
244 // Tell the optimizer that we know the value is in the error range.
245 // This helps it avoid unnecessary integer conversions.
246 #[cfg(core_intrinsics)]
247 {
248 core::intrinsics::assume(raw.is_in_range(-4095..0));
249 }
250
251 Errno(raw.decode_error_code())
252 }
253
254 /// Return the contained `usize` value.
255 #[cfg(not(debug_assertions))]
256 #[inline]
decode_usize_infallible<Num: RetNumber>(raw: RetReg<Num>) -> usize257 pub(in crate::backend) fn decode_usize_infallible<Num: RetNumber>(raw: RetReg<Num>) -> usize {
258 raw.decode_usize()
259 }
260
261 /// Return the contained `c_int` value.
262 #[cfg(not(debug_assertions))]
263 #[inline]
decode_c_int_infallible<Num: RetNumber>(raw: RetReg<Num>) -> c::c_int264 pub(in crate::backend) fn decode_c_int_infallible<Num: RetNumber>(raw: RetReg<Num>) -> c::c_int {
265 raw.decode_c_int()
266 }
267
268 /// Return the contained `c_uint` value.
269 #[cfg(not(debug_assertions))]
270 #[inline]
decode_c_uint_infallible<Num: RetNumber>(raw: RetReg<Num>) -> c::c_uint271 pub(in crate::backend) fn decode_c_uint_infallible<Num: RetNumber>(raw: RetReg<Num>) -> c::c_uint {
272 raw.decode_c_uint()
273 }
274
275 impl Errno {
276 /// `EACCES`
277 #[doc(alias = "ACCES")]
278 pub const ACCESS: Self = Self::from_errno(errno::EACCES);
279 /// `EADDRINUSE`
280 pub const ADDRINUSE: Self = Self::from_errno(errno::EADDRINUSE);
281 /// `EADDRNOTAVAIL`
282 pub const ADDRNOTAVAIL: Self = Self::from_errno(errno::EADDRNOTAVAIL);
283 /// `EADV`
284 pub const ADV: Self = Self::from_errno(errno::EADV);
285 /// `EAFNOSUPPORT`
286 pub const AFNOSUPPORT: Self = Self::from_errno(errno::EAFNOSUPPORT);
287 /// `EAGAIN`
288 pub const AGAIN: Self = Self::from_errno(errno::EAGAIN);
289 /// `EALREADY`
290 pub const ALREADY: Self = Self::from_errno(errno::EALREADY);
291 /// `EBADE`
292 pub const BADE: Self = Self::from_errno(errno::EBADE);
293 /// `EBADF`
294 pub const BADF: Self = Self::from_errno(errno::EBADF);
295 /// `EBADFD`
296 pub const BADFD: Self = Self::from_errno(errno::EBADFD);
297 /// `EBADMSG`
298 pub const BADMSG: Self = Self::from_errno(errno::EBADMSG);
299 /// `EBADR`
300 pub const BADR: Self = Self::from_errno(errno::EBADR);
301 /// `EBADRQC`
302 pub const BADRQC: Self = Self::from_errno(errno::EBADRQC);
303 /// `EBADSLT`
304 pub const BADSLT: Self = Self::from_errno(errno::EBADSLT);
305 /// `EBFONT`
306 pub const BFONT: Self = Self::from_errno(errno::EBFONT);
307 /// `EBUSY`
308 pub const BUSY: Self = Self::from_errno(errno::EBUSY);
309 /// `ECANCELED`
310 pub const CANCELED: Self = Self::from_errno(errno::ECANCELED);
311 /// `ECHILD`
312 pub const CHILD: Self = Self::from_errno(errno::ECHILD);
313 /// `ECHRNG`
314 pub const CHRNG: Self = Self::from_errno(errno::ECHRNG);
315 /// `ECOMM`
316 pub const COMM: Self = Self::from_errno(errno::ECOMM);
317 /// `ECONNABORTED`
318 pub const CONNABORTED: Self = Self::from_errno(errno::ECONNABORTED);
319 /// `ECONNREFUSED`
320 pub const CONNREFUSED: Self = Self::from_errno(errno::ECONNREFUSED);
321 /// `ECONNRESET`
322 pub const CONNRESET: Self = Self::from_errno(errno::ECONNRESET);
323 /// `EDEADLK`
324 pub const DEADLK: Self = Self::from_errno(errno::EDEADLK);
325 /// `EDEADLOCK`
326 pub const DEADLOCK: Self = Self::from_errno(errno::EDEADLOCK);
327 /// `EDESTADDRREQ`
328 pub const DESTADDRREQ: Self = Self::from_errno(errno::EDESTADDRREQ);
329 /// `EDOM`
330 pub const DOM: Self = Self::from_errno(errno::EDOM);
331 /// `EDOTDOT`
332 pub const DOTDOT: Self = Self::from_errno(errno::EDOTDOT);
333 /// `EDQUOT`
334 pub const DQUOT: Self = Self::from_errno(errno::EDQUOT);
335 /// `EEXIST`
336 pub const EXIST: Self = Self::from_errno(errno::EEXIST);
337 /// `EFAULT`
338 pub const FAULT: Self = Self::from_errno(errno::EFAULT);
339 /// `EFBIG`
340 pub const FBIG: Self = Self::from_errno(errno::EFBIG);
341 /// `EHOSTDOWN`
342 pub const HOSTDOWN: Self = Self::from_errno(errno::EHOSTDOWN);
343 /// `EHOSTUNREACH`
344 pub const HOSTUNREACH: Self = Self::from_errno(errno::EHOSTUNREACH);
345 /// `EHWPOISON`
346 pub const HWPOISON: Self = Self::from_errno(errno::EHWPOISON);
347 /// `EIDRM`
348 pub const IDRM: Self = Self::from_errno(errno::EIDRM);
349 /// `EILSEQ`
350 pub const ILSEQ: Self = Self::from_errno(errno::EILSEQ);
351 /// `EINPROGRESS`
352 pub const INPROGRESS: Self = Self::from_errno(errno::EINPROGRESS);
353 /// `EINTR`.
354 ///
355 /// For a convenient way to retry system calls that exit with `INTR`, use
356 /// [`retry_on_intr`].
357 ///
358 /// [`retry_on_intr`]: io::retry_on_intr
359 pub const INTR: Self = Self::from_errno(errno::EINTR);
360 /// `EINVAL`
361 pub const INVAL: Self = Self::from_errno(errno::EINVAL);
362 /// `EIO`
363 pub const IO: Self = Self::from_errno(errno::EIO);
364 /// `EISCONN`
365 pub const ISCONN: Self = Self::from_errno(errno::EISCONN);
366 /// `EISDIR`
367 pub const ISDIR: Self = Self::from_errno(errno::EISDIR);
368 /// `EISNAM`
369 pub const ISNAM: Self = Self::from_errno(errno::EISNAM);
370 /// `EKEYEXPIRED`
371 pub const KEYEXPIRED: Self = Self::from_errno(errno::EKEYEXPIRED);
372 /// `EKEYREJECTED`
373 pub const KEYREJECTED: Self = Self::from_errno(errno::EKEYREJECTED);
374 /// `EKEYREVOKED`
375 pub const KEYREVOKED: Self = Self::from_errno(errno::EKEYREVOKED);
376 /// `EL2HLT`
377 pub const L2HLT: Self = Self::from_errno(errno::EL2HLT);
378 /// `EL2NSYNC`
379 pub const L2NSYNC: Self = Self::from_errno(errno::EL2NSYNC);
380 /// `EL3HLT`
381 pub const L3HLT: Self = Self::from_errno(errno::EL3HLT);
382 /// `EL3RST`
383 pub const L3RST: Self = Self::from_errno(errno::EL3RST);
384 /// `ELIBACC`
385 pub const LIBACC: Self = Self::from_errno(errno::ELIBACC);
386 /// `ELIBBAD`
387 pub const LIBBAD: Self = Self::from_errno(errno::ELIBBAD);
388 /// `ELIBEXEC`
389 pub const LIBEXEC: Self = Self::from_errno(errno::ELIBEXEC);
390 /// `ELIBMAX`
391 pub const LIBMAX: Self = Self::from_errno(errno::ELIBMAX);
392 /// `ELIBSCN`
393 pub const LIBSCN: Self = Self::from_errno(errno::ELIBSCN);
394 /// `ELNRNG`
395 pub const LNRNG: Self = Self::from_errno(errno::ELNRNG);
396 /// `ELOOP`
397 pub const LOOP: Self = Self::from_errno(errno::ELOOP);
398 /// `EMEDIUMTYPE`
399 pub const MEDIUMTYPE: Self = Self::from_errno(errno::EMEDIUMTYPE);
400 /// `EMFILE`
401 pub const MFILE: Self = Self::from_errno(errno::EMFILE);
402 /// `EMLINK`
403 pub const MLINK: Self = Self::from_errno(errno::EMLINK);
404 /// `EMSGSIZE`
405 pub const MSGSIZE: Self = Self::from_errno(errno::EMSGSIZE);
406 /// `EMULTIHOP`
407 pub const MULTIHOP: Self = Self::from_errno(errno::EMULTIHOP);
408 /// `ENAMETOOLONG`
409 pub const NAMETOOLONG: Self = Self::from_errno(errno::ENAMETOOLONG);
410 /// `ENAVAIL`
411 pub const NAVAIL: Self = Self::from_errno(errno::ENAVAIL);
412 /// `ENETDOWN`
413 pub const NETDOWN: Self = Self::from_errno(errno::ENETDOWN);
414 /// `ENETRESET`
415 pub const NETRESET: Self = Self::from_errno(errno::ENETRESET);
416 /// `ENETUNREACH`
417 pub const NETUNREACH: Self = Self::from_errno(errno::ENETUNREACH);
418 /// `ENFILE`
419 pub const NFILE: Self = Self::from_errno(errno::ENFILE);
420 /// `ENOANO`
421 pub const NOANO: Self = Self::from_errno(errno::ENOANO);
422 /// `ENOBUFS`
423 pub const NOBUFS: Self = Self::from_errno(errno::ENOBUFS);
424 /// `ENOCSI`
425 pub const NOCSI: Self = Self::from_errno(errno::ENOCSI);
426 /// `ENODATA`
427 #[doc(alias = "NOATTR")]
428 pub const NODATA: Self = Self::from_errno(errno::ENODATA);
429 /// `ENODEV`
430 pub const NODEV: Self = Self::from_errno(errno::ENODEV);
431 /// `ENOENT`
432 pub const NOENT: Self = Self::from_errno(errno::ENOENT);
433 /// `ENOEXEC`
434 pub const NOEXEC: Self = Self::from_errno(errno::ENOEXEC);
435 /// `ENOKEY`
436 pub const NOKEY: Self = Self::from_errno(errno::ENOKEY);
437 /// `ENOLCK`
438 pub const NOLCK: Self = Self::from_errno(errno::ENOLCK);
439 /// `ENOLINK`
440 pub const NOLINK: Self = Self::from_errno(errno::ENOLINK);
441 /// `ENOMEDIUM`
442 pub const NOMEDIUM: Self = Self::from_errno(errno::ENOMEDIUM);
443 /// `ENOMEM`
444 pub const NOMEM: Self = Self::from_errno(errno::ENOMEM);
445 /// `ENOMSG`
446 pub const NOMSG: Self = Self::from_errno(errno::ENOMSG);
447 /// `ENONET`
448 pub const NONET: Self = Self::from_errno(errno::ENONET);
449 /// `ENOPKG`
450 pub const NOPKG: Self = Self::from_errno(errno::ENOPKG);
451 /// `ENOPROTOOPT`
452 pub const NOPROTOOPT: Self = Self::from_errno(errno::ENOPROTOOPT);
453 /// `ENOSPC`
454 pub const NOSPC: Self = Self::from_errno(errno::ENOSPC);
455 /// `ENOSR`
456 pub const NOSR: Self = Self::from_errno(errno::ENOSR);
457 /// `ENOSTR`
458 pub const NOSTR: Self = Self::from_errno(errno::ENOSTR);
459 /// `ENOSYS`
460 pub const NOSYS: Self = Self::from_errno(errno::ENOSYS);
461 /// `ENOTBLK`
462 pub const NOTBLK: Self = Self::from_errno(errno::ENOTBLK);
463 /// `ENOTCONN`
464 pub const NOTCONN: Self = Self::from_errno(errno::ENOTCONN);
465 /// `ENOTDIR`
466 pub const NOTDIR: Self = Self::from_errno(errno::ENOTDIR);
467 /// `ENOTEMPTY`
468 pub const NOTEMPTY: Self = Self::from_errno(errno::ENOTEMPTY);
469 /// `ENOTNAM`
470 pub const NOTNAM: Self = Self::from_errno(errno::ENOTNAM);
471 /// `ENOTRECOVERABLE`
472 pub const NOTRECOVERABLE: Self = Self::from_errno(errno::ENOTRECOVERABLE);
473 /// `ENOTSOCK`
474 pub const NOTSOCK: Self = Self::from_errno(errno::ENOTSOCK);
475 /// `ENOTSUP`
476 // On Linux, `ENOTSUP` has the same value as `EOPNOTSUPP`.
477 pub const NOTSUP: Self = Self::from_errno(errno::EOPNOTSUPP);
478 /// `ENOTTY`
479 pub const NOTTY: Self = Self::from_errno(errno::ENOTTY);
480 /// `ENOTUNIQ`
481 pub const NOTUNIQ: Self = Self::from_errno(errno::ENOTUNIQ);
482 /// `ENXIO`
483 pub const NXIO: Self = Self::from_errno(errno::ENXIO);
484 /// `EOPNOTSUPP`
485 pub const OPNOTSUPP: Self = Self::from_errno(errno::EOPNOTSUPP);
486 /// `EOVERFLOW`
487 pub const OVERFLOW: Self = Self::from_errno(errno::EOVERFLOW);
488 /// `EOWNERDEAD`
489 pub const OWNERDEAD: Self = Self::from_errno(errno::EOWNERDEAD);
490 /// `EPERM`
491 pub const PERM: Self = Self::from_errno(errno::EPERM);
492 /// `EPFNOSUPPORT`
493 pub const PFNOSUPPORT: Self = Self::from_errno(errno::EPFNOSUPPORT);
494 /// `EPIPE`
495 pub const PIPE: Self = Self::from_errno(errno::EPIPE);
496 /// `EPROTO`
497 pub const PROTO: Self = Self::from_errno(errno::EPROTO);
498 /// `EPROTONOSUPPORT`
499 pub const PROTONOSUPPORT: Self = Self::from_errno(errno::EPROTONOSUPPORT);
500 /// `EPROTOTYPE`
501 pub const PROTOTYPE: Self = Self::from_errno(errno::EPROTOTYPE);
502 /// `ERANGE`
503 pub const RANGE: Self = Self::from_errno(errno::ERANGE);
504 /// `EREMCHG`
505 pub const REMCHG: Self = Self::from_errno(errno::EREMCHG);
506 /// `EREMOTE`
507 pub const REMOTE: Self = Self::from_errno(errno::EREMOTE);
508 /// `EREMOTEIO`
509 pub const REMOTEIO: Self = Self::from_errno(errno::EREMOTEIO);
510 /// `ERESTART`
511 pub const RESTART: Self = Self::from_errno(errno::ERESTART);
512 /// `ERFKILL`
513 pub const RFKILL: Self = Self::from_errno(errno::ERFKILL);
514 /// `EROFS`
515 pub const ROFS: Self = Self::from_errno(errno::EROFS);
516 /// `ESHUTDOWN`
517 pub const SHUTDOWN: Self = Self::from_errno(errno::ESHUTDOWN);
518 /// `ESOCKTNOSUPPORT`
519 pub const SOCKTNOSUPPORT: Self = Self::from_errno(errno::ESOCKTNOSUPPORT);
520 /// `ESPIPE`
521 pub const SPIPE: Self = Self::from_errno(errno::ESPIPE);
522 /// `ESRCH`
523 pub const SRCH: Self = Self::from_errno(errno::ESRCH);
524 /// `ESRMNT`
525 pub const SRMNT: Self = Self::from_errno(errno::ESRMNT);
526 /// `ESTALE`
527 pub const STALE: Self = Self::from_errno(errno::ESTALE);
528 /// `ESTRPIPE`
529 pub const STRPIPE: Self = Self::from_errno(errno::ESTRPIPE);
530 /// `ETIME`
531 pub const TIME: Self = Self::from_errno(errno::ETIME);
532 /// `ETIMEDOUT`
533 pub const TIMEDOUT: Self = Self::from_errno(errno::ETIMEDOUT);
534 /// `E2BIG`
535 #[doc(alias = "2BIG")]
536 pub const TOOBIG: Self = Self::from_errno(errno::E2BIG);
537 /// `ETOOMANYREFS`
538 pub const TOOMANYREFS: Self = Self::from_errno(errno::ETOOMANYREFS);
539 /// `ETXTBSY`
540 pub const TXTBSY: Self = Self::from_errno(errno::ETXTBSY);
541 /// `EUCLEAN`
542 pub const UCLEAN: Self = Self::from_errno(errno::EUCLEAN);
543 /// `EUNATCH`
544 pub const UNATCH: Self = Self::from_errno(errno::EUNATCH);
545 /// `EUSERS`
546 pub const USERS: Self = Self::from_errno(errno::EUSERS);
547 /// `EWOULDBLOCK`
548 pub const WOULDBLOCK: Self = Self::from_errno(errno::EWOULDBLOCK);
549 /// `EXDEV`
550 pub const XDEV: Self = Self::from_errno(errno::EXDEV);
551 /// `EXFULL`
552 pub const XFULL: Self = Self::from_errno(errno::EXFULL);
553 }
554