priv_sep

Privilege separation library.
git clone https://git.philomathiclife.com/repos/priv_sep
Log | Files | Refs | README

err.rs (105697B)


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