//+private package os2 import "core:sys/linux" _errno_strings : [int(max(linux.Errno)) + 1]string = { linux.Errno.NONE = "Success", linux.Errno.EPERM = "Operation not permitted", linux.Errno.ENOENT = "No such file or directory", linux.Errno.ESRCH = "No such process", linux.Errno.EINTR = "Interrupted system call", linux.Errno.EIO = "Input/output error", linux.Errno.ENXIO = "No such device or address", linux.Errno.E2BIG = "Argument list too long", linux.Errno.ENOEXEC = "Exec format error", linux.Errno.EBADF = "Bad file descriptor", linux.Errno.ECHILD = "No child processes", linux.Errno.EAGAIN = "Resource temporarily unavailable", linux.Errno.ENOMEM = "Cannot allocate memory", linux.Errno.EACCES = "Permission denied", linux.Errno.EFAULT = "Bad address", linux.Errno.ENOTBLK = "Block device required", linux.Errno.EBUSY = "Device or resource busy", linux.Errno.EEXIST = "File exists", linux.Errno.EXDEV = "Invalid cross-device link", linux.Errno.ENODEV = "No such device", linux.Errno.ENOTDIR = "Not a directory", linux.Errno.EISDIR = "Is a directory", linux.Errno.EINVAL = "Invalid argument", linux.Errno.ENFILE = "Too many open files in system", linux.Errno.EMFILE = "Too many open files", linux.Errno.ENOTTY = "Inappropriate ioctl for device", linux.Errno.ETXTBSY = "Text file busy", linux.Errno.EFBIG = "File too large", linux.Errno.ENOSPC = "No space left on device", linux.Errno.ESPIPE = "Illegal seek", linux.Errno.EROFS = "Read-only file system", linux.Errno.EMLINK = "Too many links", linux.Errno.EPIPE = "Broken pipe", linux.Errno.EDOM = "Numerical argument out of domain", linux.Errno.ERANGE = "Numerical result out of range", linux.Errno.EDEADLK = "Resource deadlock avoided", linux.Errno.ENAMETOOLONG = "File name too long", linux.Errno.ENOLCK = "No locks available", linux.Errno.ENOSYS = "Function not implemented", linux.Errno.ENOTEMPTY = "Directory not empty", linux.Errno.ELOOP = "Too many levels of symbolic links", 41 = "Unknown Error (41)", linux.Errno.ENOMSG = "No message of desired type", linux.Errno.EIDRM = "Identifier removed", linux.Errno.ECHRNG = "Channel number out of range", linux.Errno.EL2NSYNC = "Level 2 not synchronized", linux.Errno.EL3HLT = "Level 3 halted", linux.Errno.EL3RST = "Level 3 reset", linux.Errno.ELNRNG = "Link number out of range", linux.Errno.EUNATCH = "Protocol driver not attached", linux.Errno.ENOCSI = "No CSI structure available", linux.Errno.EL2HLT = "Level 2 halted", linux.Errno.EBADE = "Invalid exchange", linux.Errno.EBADR = "Invalid request descriptor", linux.Errno.EXFULL = "Exchange full", linux.Errno.ENOANO = "No anode", linux.Errno.EBADRQC = "Invalid request code", linux.Errno.EBADSLT = "Invalid slot", 58 = "Unknown Error (58)", linux.Errno.EBFONT = "Bad font file format", linux.Errno.ENOSTR = "Device not a stream", linux.Errno.ENODATA = "No data available", linux.Errno.ETIME = "Timer expired", linux.Errno.ENOSR = "Out of streams resources", linux.Errno.ENONET = "Machine is not on the network", linux.Errno.ENOPKG = "Package not installed", linux.Errno.EREMOTE = "Object is remote", linux.Errno.ENOLINK = "Link has been severed", linux.Errno.EADV = "Advertise error", linux.Errno.ESRMNT = "Srmount error", linux.Errno.ECOMM = "Communication error on send", linux.Errno.EPROTO = "Protocol error", linux.Errno.EMULTIHOP = "Multihop attempted", linux.Errno.EDOTDOT = "RFS specific error", linux.Errno.EBADMSG = "Bad message", linux.Errno.EOVERFLOW = "Value too large for defined data type", linux.Errno.ENOTUNIQ = "Name not unique on network", linux.Errno.EBADFD = "File descriptor in bad state", linux.Errno.EREMCHG = "Remote address changed", linux.Errno.ELIBACC = "Can not access a needed shared library", linux.Errno.ELIBBAD = "Accessing a corrupted shared library", linux.Errno.ELIBSCN = ".lib section in a.out corrupted", linux.Errno.ELIBMAX = "Attempting to link in too many shared libraries", linux.Errno.ELIBEXEC = "Cannot exec a shared library directly", linux.Errno.EILSEQ = "Invalid or incomplete multibyte or wide character", linux.Errno.ERESTART = "Interrupted system call should be restarted", linux.Errno.ESTRPIPE = "Streams pipe error", linux.Errno.EUSERS = "Too many users", linux.Errno.ENOTSOCK = "Socket operation on non-socket", linux.Errno.EDESTADDRREQ = "Destination address required", linux.Errno.EMSGSIZE = "Message too long", linux.Errno.EPROTOTYPE = "Protocol wrong type for socket", linux.Errno.ENOPROTOOPT = "Protocol not available", linux.Errno.EPROTONOSUPPORT = "Protocol not supported", linux.Errno.ESOCKTNOSUPPORT = "Socket type not supported", linux.Errno.EOPNOTSUPP = "Operation not supported", linux.Errno.EPFNOSUPPORT = "Protocol family not supported", linux.Errno.EAFNOSUPPORT = "Address family not supported by protocol", linux.Errno.EADDRINUSE = "Address already in use", linux.Errno.EADDRNOTAVAIL = "Cannot assign requested address", linux.Errno.ENETDOWN = "Network is down", linux.Errno.ENETUNREACH = "Network is unreachable", linux.Errno.ENETRESET = "Network dropped connection on reset", linux.Errno.ECONNABORTED = "Software caused connection abort", linux.Errno.ECONNRESET = "Connection reset by peer", linux.Errno.ENOBUFS = "No buffer space available", linux.Errno.EISCONN = "Transport endpoint is already connected", linux.Errno.ENOTCONN = "Transport endpoint is not connected", linux.Errno.ESHUTDOWN = "Cannot send after transport endpoint shutdown", linux.Errno.ETOOMANYREFS = "Too many references: cannot splice", linux.Errno.ETIMEDOUT = "Connection timed out", linux.Errno.ECONNREFUSED = "Connection refused", linux.Errno.EHOSTDOWN = "Host is down", linux.Errno.EHOSTUNREACH = "No route to host", linux.Errno.EALREADY = "Operation already in progress", linux.Errno.EINPROGRESS = "Operation now in progress", linux.Errno.ESTALE = "Stale file handle", linux.Errno.EUCLEAN = "Structure needs cleaning", linux.Errno.ENOTNAM = "Not a XENIX named type file", linux.Errno.ENAVAIL = "No XENIX semaphores available", linux.Errno.EISNAM = "Is a named type file", linux.Errno.EREMOTEIO = "Remote I/O error", linux.Errno.EDQUOT = "Disk quota exceeded", linux.Errno.ENOMEDIUM = "No medium found", linux.Errno.EMEDIUMTYPE = "Wrong medium type", linux.Errno.ECANCELED = "Operation canceled", linux.Errno.ENOKEY = "Required key not available", linux.Errno.EKEYEXPIRED = "Key has expired", linux.Errno.EKEYREVOKED = "Key has been revoked", linux.Errno.EKEYREJECTED = "Key was rejected by service", linux.Errno.EOWNERDEAD = "Owner died", linux.Errno.ENOTRECOVERABLE = "State not recoverable", linux.Errno.ERFKILL = "Operation not possible due to RF-kill", linux.Errno.EHWPOISON = "Memory page has hardware error", } _get_platform_error :: proc(errno: linux.Errno) -> Error { #partial switch errno { case .NONE: return nil case .EPERM: return .Permission_Denied case .EEXIST: return .Exist case .ENOENT: return .Not_Exist } return Platform_Error(i32(errno)) } _error_string :: proc(errno: i32) -> string { if errno >= 0 && errno <= i32(max(linux.Errno)) { return _errno_strings[errno] } return "Unknown Error" }