2022-11-10 17:04:49

by Miguel Ojeda

[permalink] [raw]
Subject: [PATCH v1 09/28] rust: error: add codes from `errno-base.h`

From: Viktor Garske <[email protected]>

Only a few codes were added so far. With the `declare_err!`
macro in place, add the remaining ones (which is most of them)
from `include/uapi/asm-generic/errno-base.h`.

Co-developed-by: Wedson Almeida Filho <[email protected]>
Signed-off-by: Wedson Almeida Filho <[email protected]>
Signed-off-by: Viktor Garske <[email protected]>
[Reworded, adapted for upstream and applied latest changes]
Signed-off-by: Miguel Ojeda <[email protected]>
---
rust/kernel/error.rs | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)

diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs
index b843f3445483..861746f2422d 100644
--- a/rust/kernel/error.rs
+++ b/rust/kernel/error.rs
@@ -17,7 +17,40 @@ pub mod code {
};
}

+ declare_err!(EPERM, "Operation not permitted.");
+ declare_err!(ENOENT, "No such file or directory.");
+ declare_err!(ESRCH, "No such process.");
+ declare_err!(EINTR, "Interrupted system call.");
+ declare_err!(EIO, "I/O error.");
+ declare_err!(ENXIO, "No such device or address.");
+ declare_err!(E2BIG, "Argument list too long.");
+ declare_err!(ENOEXEC, "Exec format error.");
+ declare_err!(EBADF, "Bad file number.");
+ declare_err!(ECHILD, "Exec format error.");
+ declare_err!(EAGAIN, "Try again.");
declare_err!(ENOMEM, "Out of memory.");
+ declare_err!(EACCES, "Permission denied.");
+ declare_err!(EFAULT, "Bad address.");
+ declare_err!(ENOTBLK, "Block device required.");
+ declare_err!(EBUSY, "Device or resource busy.");
+ declare_err!(EEXIST, "File exists.");
+ declare_err!(EXDEV, "Cross-device link.");
+ declare_err!(ENODEV, "No such device.");
+ declare_err!(ENOTDIR, "Not a directory.");
+ declare_err!(EISDIR, "Is a directory.");
+ declare_err!(EINVAL, "Invalid argument.");
+ declare_err!(ENFILE, "File table overflow.");
+ declare_err!(EMFILE, "Too many open files.");
+ declare_err!(ENOTTY, "Not a typewriter.");
+ declare_err!(ETXTBSY, "Text file busy.");
+ declare_err!(EFBIG, "File too large.");
+ declare_err!(ENOSPC, "No space left on device.");
+ declare_err!(ESPIPE, "Illegal seek.");
+ declare_err!(EROFS, "Read-only file system.");
+ declare_err!(EMLINK, "Too many links.");
+ declare_err!(EPIPE, "Broken pipe.");
+ declare_err!(EDOM, "Math argument out of domain of func.");
+ declare_err!(ERANGE, "Math result not representable.");
}

/// Generic integer kernel error.
--
2.38.1



2022-11-14 14:37:30

by Gary Guo

[permalink] [raw]
Subject: Re: [PATCH v1 09/28] rust: error: add codes from `errno-base.h`

On Thu, 10 Nov 2022 17:41:21 +0100
Miguel Ojeda <[email protected]> wrote:

> From: Viktor Garske <[email protected]>
>
> Only a few codes were added so far. With the `declare_err!`
> macro in place, add the remaining ones (which is most of them)
> from `include/uapi/asm-generic/errno-base.h`.
>
> Co-developed-by: Wedson Almeida Filho <[email protected]>
> Signed-off-by: Wedson Almeida Filho <[email protected]>
> Signed-off-by: Viktor Garske <[email protected]>
> [Reworded, adapted for upstream and applied latest changes]
> Signed-off-by: Miguel Ojeda <[email protected]>

Reviewed-by: Gary Guo <[email protected]>

> ---
> rust/kernel/error.rs | 33 +++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs
> index b843f3445483..861746f2422d 100644
> --- a/rust/kernel/error.rs
> +++ b/rust/kernel/error.rs
> @@ -17,7 +17,40 @@ pub mod code {
> };
> }
>
> + declare_err!(EPERM, "Operation not permitted.");
> + declare_err!(ENOENT, "No such file or directory.");
> + declare_err!(ESRCH, "No such process.");
> + declare_err!(EINTR, "Interrupted system call.");
> + declare_err!(EIO, "I/O error.");
> + declare_err!(ENXIO, "No such device or address.");
> + declare_err!(E2BIG, "Argument list too long.");
> + declare_err!(ENOEXEC, "Exec format error.");
> + declare_err!(EBADF, "Bad file number.");
> + declare_err!(ECHILD, "Exec format error.");
> + declare_err!(EAGAIN, "Try again.");
> declare_err!(ENOMEM, "Out of memory.");
> + declare_err!(EACCES, "Permission denied.");
> + declare_err!(EFAULT, "Bad address.");
> + declare_err!(ENOTBLK, "Block device required.");
> + declare_err!(EBUSY, "Device or resource busy.");
> + declare_err!(EEXIST, "File exists.");
> + declare_err!(EXDEV, "Cross-device link.");
> + declare_err!(ENODEV, "No such device.");
> + declare_err!(ENOTDIR, "Not a directory.");
> + declare_err!(EISDIR, "Is a directory.");
> + declare_err!(EINVAL, "Invalid argument.");
> + declare_err!(ENFILE, "File table overflow.");
> + declare_err!(EMFILE, "Too many open files.");
> + declare_err!(ENOTTY, "Not a typewriter.");
> + declare_err!(ETXTBSY, "Text file busy.");
> + declare_err!(EFBIG, "File too large.");
> + declare_err!(ENOSPC, "No space left on device.");
> + declare_err!(ESPIPE, "Illegal seek.");
> + declare_err!(EROFS, "Read-only file system.");
> + declare_err!(EMLINK, "Too many links.");
> + declare_err!(EPIPE, "Broken pipe.");
> + declare_err!(EDOM, "Math argument out of domain of func.");
> + declare_err!(ERANGE, "Math result not representable.");
> }
>
> /// Generic integer kernel error.