Skip to content

Commit e37b654

Browse files
Darksonnojeda
authored andcommitted
rust: error: add missing error codes
This adds the error codes from `include/linux/errno.h` to the list of Rust error constants. These errors were not included originally, because they are not supposed to be visible from userspace. However, they are still a perfectly valid error to use when writing a kernel driver. For example, you might want to return ERESTARTSYS if you receive a signal during a call to `schedule`. This patch inserts an annotation to skip rustfmt on the list of error codes. Without it, three of the error codes are split over several lines, which looks terribly inconsistent. Signed-off-by: Alice Ryhl <[email protected]> Reviewed-by: Martin Rodriguez Reboredo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 66bd753 commit e37b654

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

rust/kernel/error.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use core::num::TryFromIntError;
1414
use core::str::Utf8Error;
1515

1616
/// Contains the C-compatible error codes.
17+
#[rustfmt::skip]
1718
pub mod code {
1819
macro_rules! declare_err {
1920
($err:tt $(,)? $($doc:expr),+) => {
@@ -58,6 +59,25 @@ pub mod code {
5859
declare_err!(EPIPE, "Broken pipe.");
5960
declare_err!(EDOM, "Math argument out of domain of func.");
6061
declare_err!(ERANGE, "Math result not representable.");
62+
declare_err!(ERESTARTSYS, "Restart the system call.");
63+
declare_err!(ERESTARTNOINTR, "System call was interrupted by a signal and will be restarted.");
64+
declare_err!(ERESTARTNOHAND, "Restart if no handler.");
65+
declare_err!(ENOIOCTLCMD, "No ioctl command.");
66+
declare_err!(ERESTART_RESTARTBLOCK, "Restart by calling sys_restart_syscall.");
67+
declare_err!(EPROBE_DEFER, "Driver requests probe retry.");
68+
declare_err!(EOPENSTALE, "Open found a stale dentry.");
69+
declare_err!(ENOPARAM, "Parameter not supported.");
70+
declare_err!(EBADHANDLE, "Illegal NFS file handle.");
71+
declare_err!(ENOTSYNC, "Update synchronization mismatch.");
72+
declare_err!(EBADCOOKIE, "Cookie is stale.");
73+
declare_err!(ENOTSUPP, "Operation is not supported.");
74+
declare_err!(ETOOSMALL, "Buffer or request is too small.");
75+
declare_err!(ESERVERFAULT, "An untranslatable error occurred.");
76+
declare_err!(EBADTYPE, "Type not supported by server.");
77+
declare_err!(EJUKEBOX, "Request initiated, but will not complete before timeout.");
78+
declare_err!(EIOCBQUEUED, "iocb queued, will get completion event.");
79+
declare_err!(ERECALLCONFLICT, "Conflict with recalled state.");
80+
declare_err!(ENOGRACE, "NFS file lock reclaim refused.");
6181
}
6282

6383
/// Generic integer kernel error.

0 commit comments

Comments
 (0)