strat9_abi/errno.rs
1//! Strat9 OS error codes (errno values).
2//!
3//! ABI convention: syscalls return `usize` in RAX.
4//! - **Success**: any non-negative value.
5//! - **Error**: negative errno in two's complement.
6//!
7//! Userspace detects errors with `if result > 0xFFFF_F000`, then converts:
8//! ```ignore
9//! let errno = !result + 1; // or equivalently: -(result as isize) as usize
10//! ```
11
12/// Operation not permitted (e.g., missing capability).
13pub const EPERM: usize = 1;
14
15/// No such file or directory.
16pub const ENOENT: usize = 2;
17
18/// No such process (invalid PID/TID).
19pub const ESRCH: usize = 3;
20
21/// Interrupted system call (signal delivered during blocking op).
22pub const EINTR: usize = 4;
23
24/// Input/output error (hardware failure, bad sector, etc.).
25pub const EIO: usize = 5;
26
27/// Argument list too long (execve path or argv exceeds limit).
28pub const E2BIG: usize = 7;
29
30/// Exec format error (invalid ELF binary, wrong architecture).
31pub const ENOEXEC: usize = 8;
32
33/// Bad file descriptor (fd not open or already closed).
34pub const EBADF: usize = 9;
35
36/// No child processes (waitpid on non-existent child).
37pub const ECHILD: usize = 10;
38
39/// Resource temporarily unavailable (non-blocking would block).
40pub const EAGAIN: usize = 11;
41
42/// Cannot allocate memory (kernel heap or page allocation failed).
43pub const ENOMEM: usize = 12;
44
45/// Permission denied (capability check failed, file mode mismatch).
46pub const EACCES: usize = 13;
47
48/// Bad address (invalid pointer in syscall argument).
49pub const EFAULT: usize = 14;
50
51/// File exists (O_CREAT | O_EXCL on existing file).
52pub const EEXIST: usize = 17;
53
54/// Not a directory (expected directory, got file or device).
55pub const ENOTDIR: usize = 20;
56
57/// Is a directory (expected file, got directory).
58pub const EISDIR: usize = 21;
59
60/// Invalid argument (bad alignment, invalid flags, etc.).
61pub const EINVAL: usize = 22;
62
63/// Not a typewriter (ioctl on non-TTY device).
64pub const ENOTTY: usize = 25;
65
66/// No space left on device (disk full, inode exhaustion).
67pub const ENOSPC: usize = 28;
68
69/// Broken pipe (write to pipe with no readers).
70pub const EPIPE: usize = 32;
71
72/// Result too large (numeric overflow in math operation).
73pub const ERANGE: usize = 34;
74
75/// File name too long (path exceeds PATH_MAX).
76pub const ENAMETOOLONG: usize = 36;
77
78/// Function not implemented (syscall not supported by kernel).
79pub const ENOSYS: usize = 38;
80
81/// Directory not empty (rmdir on non-empty directory).
82pub const ENOTEMPTY: usize = 39;
83
84/// Too many levels of symbolic links (symlink loop detected).
85pub const ELOOP: usize = 40;
86
87/// Not supported (operation not supported by this filesystem/device).
88pub const ENOTSUP: usize = 52;
89
90/// Address family not supported (socket type not available).
91pub const EAFNOSUPPORT: usize = 97;
92
93/// Address already in use (socket bind to occupied port/address).
94pub const EADDRINUSE: usize = 98;
95
96/// No buffer space available (network buffer exhaustion).
97pub const ENOBUFS: usize = 105;
98
99/// Connection timed out (network or device timeout).
100pub const ETIMEDOUT: usize = 110;
101
102/// Connection refused (no listener on target port).
103pub const ECONNREFUSED: usize = 111;