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