rust: error: add remaining error codes
PATCH 1/1 rust: error: add remaining error codes
Add all of the remaining error codes from include/uapi/asm-generic/errno.h.
Previous updates to error.rs have been piecemeal -- adding single error codes as needed. Instead, we can avoid future problems by adding all the remaining error code in one swoop.
EDEADLOCK and EWOULDBLOCK are intentionally left out: they are just deprecated compatibility aliases of EDEADLK and EAGAIN, kept around for non-Linux/POSIX code, and have no use in new kernel code.
--- rust/kernel/error.rs | 105 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+)
rust/kernel/error.rs +105 -0
@@ -30,6 +30,8 @@ macro_rules! declare_err { }; } +// From include/uapi/asm-generic/errno-base.h +declare_err! (EPERM ,"Operation not permitted." );declare_err! (ENOENT ,"No such file or directory." );declare_err! (ESRCH ,"No such process." );
@@ -64,9 +66,112 @@ macro_rules! declare_err {declare_err! (EPIPE ,"Broken pipe." );declare_err! (EDOM ,"Math argument out of domain of func." );declare_err! (ERANGE ,"Math result not representable." ); + +// From include/uapi/asm-generic/errno.h + +declare_err! (EDEADLK ,"Resource deadlock would occur." ); +declare_err! (ENAMETOOLONG ,"File name too long." ); +declare_err! (ENOLCK ,"No record locks available." ); +declare_err! (ENOSYS ,"Invalid system call number." ); +declare_err! (ENOTEMPTY ,"Directory not empty." ); +declare_err! (ELOOP ,"Too many symbolic links encountered." ); +declare_err! (ENOMSG ,"No message of desired type." ); +declare_err! (EIDRM ,"Identifier removed." ); +declare_err! (ECHRNG ,"Channel number out of range." ); +declare_err! (EL2NSYNC ,"Level 2 not synchronized." ); +declare_err! (EL3HLT ,"Level 3 halted." ); +declare_err! (EL3RST ,"Level 3 reset." ); +declare_err! (ELNRNG ,"Link number out of range." ); +declare_err! (EUNATCH ,"Protocol driver not attached." ); +declare_err! (ENOCSI ,"No CSI structure available." ); +declare_err! (EL2HLT ,"Level 2 halted." ); +declare_err! (EBADE ,"Invalid exchange." ); +declare_err! (EBADR ,"Invalid request descriptor." ); +declare_err! (EXFULL ,"Exchange full." ); +declare_err! (ENOANO ,"No anode." ); +declare_err! (EBADRQC ,"Invalid request code." ); +declare_err! (EBADSLT ,"Invalid slot." ); +declare_err! (EBFONT ,"Bad font file format." ); +declare_err! (ENOSTR ,"Device not a stream." ); +declare_err! (ENODATA ,"No data available." ); +declare_err! (ETIME ,"Timer expired." ); +declare_err! (ENOSR ,"Out of streams resources." ); +declare_err! (ENONET ,"Machine is not on the network." ); +declare_err! (ENOPKG ,"Package not installed." ); +declare_err! (EREMOTE ,"Object is remote." ); +declare_err! (ENOLINK ,"Link has been severed." ); +declare_err! (EADV ,"Advertise error." ); +declare_err! (ESRMNT ,"Srmount error." ); +declare_err! (ECOMM ,"Communication error on send." ); +declare_err! (EPROTO ,"Protocol error." ); +declare_err! (EMULTIHOP ,"Multihop attempted." ); +declare_err! (EDOTDOT ,"RFS specific error." ); +declare_err! (EBADMSG ,"Not a data message." ); +declare_err! (EFSBADCRC ,"Bad CRC detected." );declare_err! (EOVERFLOW ,"Value too large for defined data type." ); +declare_err! (ENOTUNIQ ,"Name not unique on network." ); +declare_err! (EBADFD ,"File descriptor in bad state." ); +declare_err! (EREMCHG ,"Remote address changed." ); +declare_err! (ELIBACC ,"Can not access a needed shared library." ); +declare_err! (ELIBBAD ,"Accessing a corrupted shared library." ); +declare_err! (ELIBSCN ,".lib section in a.out corrupted." ); +declare_err! (ELIBMAX ,"Attempting to link in too many shared libraries." ); +declare_err! (ELIBEXEC ,"Cannot exec a shared library directly." ); +declare_err! (EILSEQ ,"Illegal byte sequence." ); +declare_err! (ERESTART ,"Interrupted system call should be restarted." ); +declare_err! (ESTRPIPE ,"Streams pipe error." ); +declare_err! (EUSERS ,"Too many users." ); +declare_err! (ENOTSOCK ,"Socket operation on non-socket." ); +declare_err! (EDESTADDRREQ ,"Destination address required." );declare_err! (EMSGSIZE ,"Message too long." ); +declare_err! (EPROTOTYPE ,"Protocol wrong type for socket." ); +declare_err! (ENOPROTOOPT ,"Protocol not available." ); +declare_err! (EPROTONOSUPPORT ,"Protocol not supported." ); +declare_err! (ESOCKTNOSUPPORT ,"Socket type not supported." ); +declare_err! (EOPNOTSUPP ,"Operation not supported on transport endpoint." ); +declare_err! (EPFNOSUPPORT ,"Protocol family not supported." ); +declare_err! (EAFNOSUPPORT ,"Address family not supported by protocol." ); +declare_err! (EADDRINUSE ,"Address already in use." ); +declare_err! (EADDRNOTAVAIL ,"Cannot assign requested address." ); +declare_err! (ENETDOWN ,"Network is down." ); +declare_err! (ENETUNREACH ,"Network is unreachable." ); +declare_err! (ENETRESET ,"Network dropped connection because of reset." ); +declare_err! (ECONNABORTED ,"Software caused connection abort." ); +declare_err! (ECONNRESET ,"Connection reset by peer." ); +declare_err! (ENOBUFS ,"No buffer space available." ); +declare_err! (EISCONN ,"Transport endpoint is already connected." ); +declare_err! (ENOTCONN ,"Transport endpoint is not connected." ); +declare_err! (ESHUTDOWN ,"Cannot send after transport endpoint shutdown." ); +declare_err! (ETOOMANYREFS ,"Too many references: cannot splice." );declare_err! (ETIMEDOUT ,"Connection timed out." ); +declare_err! (ECONNREFUSED ,"Connection refused." ); +declare_err! (EHOSTDOWN ,"Host is down." ); +declare_err! (EHOSTUNREACH ,"No route to host." ); +declare_err! (EALREADY ,"Operation already in progress." ); +declare_err! (EINPROGRESS ,"Operation now in progress." ); +declare_err! (ESTALE ,"Stale file handle." ); +declare_err! (EUCLEAN ,"Structure needs cleaning." ); +declare_err! (EFSCORRUPTED ,"Filesystem is corrupted." ); +declare_err! (ENOTNAM ,"Not a XENIX named type file." ); +declare_err! (ENAVAIL ,"No XENIX semaphores available." ); +declare_err! (EISNAM ,"Is a named type file." ); +declare_err! (EREMOTEIO ,"Remote I/O error." ); +declare_err! (EDQUOT ,"Quota exceeded." ); +declare_err! (ENOMEDIUM ,"No medium found." ); +declare_err! (EMEDIUMTYPE ,"Wrong medium type." ); +declare_err! (ECANCELED ,"Operation Canceled." ); +declare_err! (ENOKEY ,"Required key not available." ); +declare_err! (EKEYEXPIRED ,"Key has expired." ); +declare_err! (EKEYREVOKED ,"Key has been revoked." ); +declare_err! (EKEYREJECTED ,"Key was rejected by service." ); +declare_err! (EOWNERDEAD ,"Owner died." ); +declare_err! (ENOTRECOVERABLE ,"State not recoverable." ); +declare_err! (ERFKILL ,"Operation not possible due to RF-kill." ); +declare_err! (EHWPOISON ,"Memory page has hardware error." ); +declare_err! (EFTYPE ,"Wrong file type for the intended operation." ); + +// From include/linux/errno.h +declare_err! (ERESTARTSYS ,"Restart the system call." );declare_err! (ERESTARTNOINTR ,"System call was interrupted by a signal and will be restarted." );declare_err! (ERESTARTNOHAND ,"Restart if no handler." );
Signature · 1 line
2.54.0
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 8 lines · On Mon, 2026-06-29 at 18:42 +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The commit intentionally omits theEDEADLOCKconstant fromrust/kernel/error.rsbased on the incorrect assumption that it is purely a deprecated compatibility alias forEDEADLK. While true on generic architectures (like x86 and ARM64),EDEADLOCKandEDEADLKmap to distinct integer values on MIPS, SPARC, and PowerPC (e.g., on PowerPCEDEADLOCKis 58, butEDEADLKis 35). Several kernel C subsystems, such as XFS (fs/xfs/scrub/scrub.c), DRM, HID-BPF, and IOMMUFD actively return-EDEADLOCK. BecauseEDEADLOCKis missing from the Rust bindings, Rust developers must usekernel::error::code::EDEADLKto match these errors.
Yes, my understanding is that new Rust code should use EDEADLK, as there is no expectation for this code to be ported to other operating systems.
But I could be wrong. These aliases are ancient -- predating the git tree itself.
Quoted 11 lines · Timur Tabi
Add all of the remaining error codes from
include/uapi/asm-generic/errno.h.Previous updates to
error.rshave been piecemeal -- adding single error codes as needed. Instead, we can avoid future problems by adding all the remaining error code in one swoop.EDEADLOCK and EWOULDBLOCK are intentionally left out: they are just deprecated compatibility aliases of EDEADLK and EAGAIN, kept around for non-Linux/POSIX code, and have no use in new kernel code.
Signed-off-by Timur Tabi <[email protected]>
Nice, no more ad-hoc patches to add newly required error codes! :) I remember having some of these conflict in the past.
Quoted 11 lines · Timur Tabi
Add all of the remaining error codes from
include/uapi/asm-generic/errno.h.Previous updates to
error.rshave been piecemeal -- adding single error codes as needed. Instead, we can avoid future problems by adding all the remaining error code in one swoop.EDEADLOCK and EWOULDBLOCK are intentionally left out: they are just deprecated compatibility aliases of EDEADLK and EAGAIN, kept around for non-Linux/POSIX code, and have no use in new kernel code.
Signed-off-by Timur Tabi <[email protected]>
Quoted 3 lines
--- rust/kernel/error.rs | 105 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+)
Quoted 11 lines · Timur Tabi
Add all of the remaining error codes from
include/uapi/asm-generic/errno.h.Previous updates to
error.rshave been piecemeal -- adding single error codes as needed. Instead, we can avoid future problems by adding all the remaining error code in one swoop.EDEADLOCK and EWOULDBLOCK are intentionally left out: they are just deprecated compatibility aliases of EDEADLK and EAGAIN, kept around for non-Linux/POSIX code, and have no use in new kernel code.
Signed-off-by Timur Tabi <[email protected]>
Seems reasonable,
Quoted 11 lines · Timur Tabi
Add all of the remaining error codes from
include/uapi/asm-generic/errno.h.Previous updates to
error.rshave been piecemeal -- adding single error codes as needed. Instead, we can avoid future problems by adding all the remaining error code in one swoop.EDEADLOCK and EWOULDBLOCK are intentionally left out: they are just deprecated compatibility aliases of EDEADLK and EAGAIN, kept around for non-Linux/POSIX code, and have no use in new kernel code.
Signed-off-by Timur Tabi <[email protected]>