Skip to content

Commit e97ba67

Browse files
authored
Merge pull request #436 from v-gar/error-sort-and-add
Sort and add remaining errors in error.rs
2 parents cded685 + 26944af commit e97ba67

File tree

1 file changed

+88
-19
lines changed

1 file changed

+88
-19
lines changed

rust/kernel/error.rs

Lines changed: 88 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,41 +24,110 @@ use core::str::{self, Utf8Error};
2424
pub struct Error(c_types::c_int);
2525

2626
impl Error {
27-
/// Invalid argument.
28-
pub const EINVAL: Self = Error(-(bindings::EINVAL as i32));
27+
/// Operation not permitted.
28+
pub const EPERM: Self = Error(-(bindings::EPERM as i32));
29+
30+
/// No such file or directory.
31+
pub const ENOENT: Self = Error(-(bindings::ENOENT as i32));
32+
33+
/// No such process.
34+
pub const ESRCH: Self = Error(-(bindings::ESRCH as i32));
35+
36+
/// Interrupted system call.
37+
pub const EINTR: Self = Error(-(bindings::EINTR as i32));
38+
39+
/// I/O error.
40+
pub const EIO: Self = Error(-(bindings::EIO as i32));
41+
42+
/// No such device or address.
43+
pub const ENXIO: Self = Error(-(bindings::ENXIO as i32));
44+
45+
/// Argument list too long.
46+
pub const E2BIG: Self = Error(-(bindings::E2BIG as i32));
47+
48+
/// Exec format error.
49+
pub const ENOEXEC: Self = Error(-(bindings::ENOEXEC as i32));
50+
51+
/// Bad file number.
52+
pub const EBADF: Self = Error(-(bindings::EBADF as i32));
53+
54+
/// No child processes.
55+
pub const ECHILD: Self = Error(-(bindings::ECHILD as i32));
56+
57+
/// Try again.
58+
pub const EAGAIN: Self = Error(-(bindings::EAGAIN as i32));
2959

3060
/// Out of memory.
3161
pub const ENOMEM: Self = Error(-(bindings::ENOMEM as i32));
3262

63+
/// Permission denied.
64+
pub const EACCES: Self = Error(-(bindings::EACCES as i32));
65+
3366
/// Bad address.
3467
pub const EFAULT: Self = Error(-(bindings::EFAULT as i32));
3568

36-
/// Illegal seek.
37-
pub const ESPIPE: Self = Error(-(bindings::ESPIPE as i32));
38-
39-
/// Try again.
40-
pub const EAGAIN: Self = Error(-(bindings::EAGAIN as i32));
69+
/// Block device required.
70+
pub const ENOTBLK: Self = Error(-(bindings::ENOTBLK as i32));
4171

4272
/// Device or resource busy.
4373
pub const EBUSY: Self = Error(-(bindings::EBUSY as i32));
4474

45-
/// Restart the system call.
46-
pub const ERESTARTSYS: Self = Error(-(bindings::ERESTARTSYS as i32));
75+
/// File exists.
76+
pub const EEXIST: Self = Error(-(bindings::EEXIST as i32));
4777

48-
/// Operation not permitted.
49-
pub const EPERM: Self = Error(-(bindings::EPERM as i32));
78+
/// Cross-device link.
79+
pub const EXDEV: Self = Error(-(bindings::EXDEV as i32));
5080

51-
/// No such process.
52-
pub const ESRCH: Self = Error(-(bindings::ESRCH as i32));
81+
/// No such device.
82+
pub const ENODEV: Self = Error(-(bindings::ENODEV as i32));
5383

54-
/// No such file or directory.
55-
pub const ENOENT: Self = Error(-(bindings::ENOENT as i32));
84+
/// Not a directory.
85+
pub const ENOTDIR: Self = Error(-(bindings::ENOTDIR as i32));
5686

57-
/// Interrupted system call.
58-
pub const EINTR: Self = Error(-(bindings::EINTR as i32));
87+
/// Is a directory.
88+
pub const EISDIR: Self = Error(-(bindings::EISDIR as i32));
5989

60-
/// Bad file number.
61-
pub const EBADF: Self = Error(-(bindings::EBADF as i32));
90+
/// Invalid argument.
91+
pub const EINVAL: Self = Error(-(bindings::EINVAL as i32));
92+
93+
/// File table overflow.
94+
pub const ENFILE: Self = Error(-(bindings::ENFILE as i32));
95+
96+
/// Too many open files.
97+
pub const EMFILE: Self = Error(-(bindings::EMFILE as i32));
98+
99+
/// Not a typewriter.
100+
pub const ENOTTY: Self = Error(-(bindings::ENOTTY as i32));
101+
102+
/// Text file busy.
103+
pub const ETXTBSY: Self = Error(-(bindings::ETXTBSY as i32));
104+
105+
/// File too large.
106+
pub const EFBIG: Self = Error(-(bindings::EFBIG as i32));
107+
108+
/// No space left on device.
109+
pub const ENOSPC: Self = Error(-(bindings::ENOSPC as i32));
110+
111+
/// Illegal seek.
112+
pub const ESPIPE: Self = Error(-(bindings::ESPIPE as i32));
113+
114+
/// Read-only file system.
115+
pub const EROFS: Self = Error(-(bindings::EROFS as i32));
116+
117+
/// Too many links.
118+
pub const EMLINK: Self = Error(-(bindings::EMLINK as i32));
119+
120+
/// Broken pipe.
121+
pub const EPIPE: Self = Error(-(bindings::EPIPE as i32));
122+
123+
/// Math argument out of domain of func.
124+
pub const EDOM: Self = Error(-(bindings::EDOM as i32));
125+
126+
/// Math result not representable.
127+
pub const ERANGE: Self = Error(-(bindings::ERANGE as i32));
128+
129+
/// Restart the system call.
130+
pub const ERESTARTSYS: Self = Error(-(bindings::ERESTARTSYS as i32));
62131

63132
/// Creates an [`Error`] from a kernel error code.
64133
///

0 commit comments

Comments
 (0)