diff --git a/hermit-abi/Cargo.toml b/hermit-abi/Cargo.toml index 3fec2f17d..26f9504ee 100644 --- a/hermit-abi/Cargo.toml +++ b/hermit-abi/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hermit-abi" -version = "0.3.8" +version = "0.3.9" authors = ["Stefan Lankes"] license = "MIT OR Apache-2.0" edition = "2021" diff --git a/hermit-abi/src/errno.rs b/hermit-abi/src/errno.rs index dc22dc8ce..1c4a320af 100644 --- a/hermit-abi/src/errno.rs +++ b/hermit-abi/src/errno.rs @@ -395,3 +395,138 @@ pub const ERFKILL: i32 = 132; /// Robust mutexes: Memory page has hardware error pub const EHWPOISON: i32 = 133; + +/// Converts an error number to a corresponding error string +pub fn error_string(errno: i32) -> &'static str { + match errno { + 0 => "Operation successful", + EPERM => "Operation not permitted", + ENOENT => "No such file or directory", + ESRCH => "No such process", + EINTR => "Interrupted system call", + EIO => "I/O error", + ENXIO => "No such device or address", + E2BIG => "Argument list too long", + ENOEXEC => "Exec format error", + EBADF => "Bad file number", + ECHILD => "No child processes", + EAGAIN => "Try again", + ENOMEM => "Out of memory", + EACCES => "Permission denied", + EFAULT => "Bad address", + ENOTBLK => "Block device required", + EBUSY => "Device or resource busy", + EEXIST => "File exists", + EXDEV => "Cross-device link", + ENODEV => "No such device", + ENOTDIR => "Not a directory", + EISDIR => "Is a directory", + EINVAL => "Invalid argument", + ENFILE => "File table overflow", + EMFILE => "Too many open files", + ENOTTY => "Not a typewriter", + ETXTBSY => "Text file busy", + EFBIG => "File too large", + ENOSPC => "No space left on device", + ESPIPE => "Illegal seek", + EROFS => "Read-only file system", + EMLINK => "Too many links", + EPIPE => "Broken pipe", + EDOM => "Math argument out of domain of func", + ERANGE => "Math result not representable", + EDEADLK => "Resource deadlock would occur", + ENAMETOOLONG => "File name too long", + ENOLCK => "No record locks available", + ENOSYS => "Function not implemented", + ENOTEMPTY => "Directory not empty", + ELOOP => "Too many symbolic links encountered", + ENOMSG => "No message of desired type", + EIDRM => "Identifier removed", + ECHRNG => "Channel number out of range", + EL2NSYNC => "Level 2 not synchronized", + EL3HLT => "Level 3 halted", + EL3RST => "Level 3 reset", + ELNRNG => "Link number out of range", + EUNATCH => "Protocol driver not attached", + ENOCSI => "No CSI structure available", + EL2HLT => "Level 2 halted", + EBADE => "Invalid exchange", + EBADR => "Invalid request descriptor", + EXFULL => "Exchange full", + ENOANO => "No anode", + EBADRQC => "Invalid request code", + EBADSLT => "Invalid slot", + EBFONT => "Bad font file format", + ENOSTR => "Device not a stream", + ENODATA => "No data available", + ETIME => "Timer expired", + ENOSR => "Out of streams resources", + ENONET => "Machine is not on the network", + ENOPKG => "Package not installed", + EREMOTE => "Object is remote", + ENOLINK => "Link has been severed", + EADV => "Advertise error", + ESRMNT => "Srmount error", + ECOMM => "Communication error on send", + EPROTO => "Protocol error", + EMULTIHOP => "Multihop attempted", + EDOTDOT => "RFS specific error", + EBADMSG => "Not a data message", + EOVERFLOW => "Value too large for defined data type", + ENOTUNIQ => "Name not unique on network", + EBADFD => "File descriptor in bad state", + EREMCHG => "Remote address changed", + ELIBACC => "Can not access a needed shared library", + ELIBBAD => "Accessing a corrupted shared library", + ELIBSCN => "Lib section in a.out corrupted", + ELIBMAX => "Attempting to link in too many shared libraries", + ELIBEXEC => "Cannot exec a shared library directly", + EILSEQ => "Illegal byte sequence", + ERESTART => "Interrupted system call should be restarted", + ESTRPIPE => "Streams pipe error", + EUSERS => "Too many users", + ENOTSOCK => "Socket operation on non-socket", + EDESTADDRREQ => "Destination address required", + EMSGSIZE => "Message too long", + EPROTOTYPE => "Protocol wrong type for socket", + ENOPROTOOPT => "Protocol not available", + EPROTONOSUPPORT => "Protocol not supported", + ESOCKTNOSUPPORT => "Socket type not supported", + EOPNOTSUPP => "Operation not supported on transport endpoint", + EPFNOSUPPORT => "Protocol family not supported", + EAFNOSUPPORT => "Address family not supported by protocol", + EADDRINUSE => "Address already in use", + EADDRNOTAVAIL => "Cannot assign requested address", + ENETDOWN => "Network is down", + ENETUNREACH => "Network is unreachable", + ENETRESET => "Network dropped connection because of reset", + ECONNABORTED => "Software caused connection abort", + ECONNRESET => "Connection reset by peer", + ENOBUFS => "No buffer space available", + EISCONN => "Transport endpoint is already connected", + ENOTCONN => "Transport endpoint is not connected", + ESHUTDOWN => "Cannot send after transport endpoint shutdown", + ETOOMANYREFS => "Too many references: cannot splice", + ETIMEDOUT => "Connection timed out", + ECONNREFUSED => "Connection refused", + EHOSTDOWN => "Host is down", + EHOSTUNREACH => "No route to host", + EALREADY => "Operation already in progress", + EINPROGRESS => "Operation now in progress", + ESTALE => "Stale file handle", + EUCLEAN => "Structure needs cleaning", + EDQUOT => "Quota exceeded", + ENOMEDIUM => "No medium found", + EMEDIUMTYPE => "Wrong medium type", + ECANCELED => "Operation Canceled", + ENOKEY => "Required key not available", + EKEYEXPIRED => "Key has expired", + EKEYREVOKED => "Key has been revoked", + EKEYREJECTED => "Key was rejected by service", + EOWNERDEAD => "Robust mutexes: Owner died", + ENOTRECOVERABLE => "Robust mutexes: State not recoverable", + ERFKILL => "Robust mutexes: Operation not possible due to RF-kill", + EHWPOISON => "Robust mutexes: Memory page has hardware error", + _ => "Unknown error", + } +} diff --git a/hermit-abi/src/lib.rs b/hermit-abi/src/lib.rs index 482ab2b3e..321f9e1dd 100644 --- a/hermit-abi/src/lib.rs +++ b/hermit-abi/src/lib.rs @@ -337,6 +337,10 @@ pub const S_IFMT: u32 = 0xF000; // sysmbols, which are part of the library operating system extern "C" { + /// Get the last error number from the thread local storage + #[link_name = "sys_get_errno"] + pub fn get_errno() -> i32; + /// If the value at address matches the expected value, park the current thread until it is either /// woken up with [`futex_wake`] (returns 0) or an optional timeout elapses (returns -ETIMEDOUT). /// diff --git a/kernel b/kernel index 962dba1ee..3aa35154d 160000 --- a/kernel +++ b/kernel @@ -1 +1 @@ -Subproject commit 962dba1ee13823d485e5eafd32beb45a0e1401ef +Subproject commit 3aa35154d370c2d2fbdc1ac737f41652af89866f