errors_linux.odin 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. //+private
  2. package os2
  3. import "core:sys/linux"
  4. @(rodata)
  5. _errno_strings : [linux.Errno]string = {
  6. .NONE = "Success",
  7. .EPERM = "Operation not permitted",
  8. .ENOENT = "No such file or directory",
  9. .ESRCH = "No such process",
  10. .EINTR = "Interrupted system call",
  11. .EIO = "Input/output error",
  12. .ENXIO = "No such device or address",
  13. .E2BIG = "Argument list too long",
  14. .ENOEXEC = "Exec format error",
  15. .EBADF = "Bad file descriptor",
  16. .ECHILD = "No child processes",
  17. .EAGAIN = "Resource temporarily unavailable",
  18. .ENOMEM = "Cannot allocate memory",
  19. .EACCES = "Permission denied",
  20. .EFAULT = "Bad address",
  21. .ENOTBLK = "Block device required",
  22. .EBUSY = "Device or resource busy",
  23. .EEXIST = "File exists",
  24. .EXDEV = "Invalid cross-device link",
  25. .ENODEV = "No such device",
  26. .ENOTDIR = "Not a directory",
  27. .EISDIR = "Is a directory",
  28. .EINVAL = "Invalid argument",
  29. .ENFILE = "Too many open files in system",
  30. .EMFILE = "Too many open files",
  31. .ENOTTY = "Inappropriate ioctl for device",
  32. .ETXTBSY = "Text file busy",
  33. .EFBIG = "File too large",
  34. .ENOSPC = "No space left on device",
  35. .ESPIPE = "Illegal seek",
  36. .EROFS = "Read-only file system",
  37. .EMLINK = "Too many links",
  38. .EPIPE = "Broken pipe",
  39. .EDOM = "Numerical argument out of domain",
  40. .ERANGE = "Numerical result out of range",
  41. .EDEADLK = "Resource deadlock avoided",
  42. .ENAMETOOLONG = "File name too long",
  43. .ENOLCK = "No locks available",
  44. .ENOSYS = "Function not implemented",
  45. .ENOTEMPTY = "Directory not empty",
  46. .ELOOP = "Too many levels of symbolic links",
  47. .EUNKNOWN_41 = "Unknown Error (41)",
  48. .ENOMSG = "No message of desired type",
  49. .EIDRM = "Identifier removed",
  50. .ECHRNG = "Channel number out of range",
  51. .EL2NSYNC = "Level 2 not synchronized",
  52. .EL3HLT = "Level 3 halted",
  53. .EL3RST = "Level 3 reset",
  54. .ELNRNG = "Link number out of range",
  55. .EUNATCH = "Protocol driver not attached",
  56. .ENOCSI = "No CSI structure available",
  57. .EL2HLT = "Level 2 halted",
  58. .EBADE = "Invalid exchange",
  59. .EBADR = "Invalid request descriptor",
  60. .EXFULL = "Exchange full",
  61. .ENOANO = "No anode",
  62. .EBADRQC = "Invalid request code",
  63. .EBADSLT = "Invalid slot",
  64. .EUNKNOWN_58 = "Unknown Error (58)",
  65. .EBFONT = "Bad font file format",
  66. .ENOSTR = "Device not a stream",
  67. .ENODATA = "No data available",
  68. .ETIME = "Timer expired",
  69. .ENOSR = "Out of streams resources",
  70. .ENONET = "Machine is not on the network",
  71. .ENOPKG = "Package not installed",
  72. .EREMOTE = "Object is remote",
  73. .ENOLINK = "Link has been severed",
  74. .EADV = "Advertise error",
  75. .ESRMNT = "Srmount error",
  76. .ECOMM = "Communication error on send",
  77. .EPROTO = "Protocol error",
  78. .EMULTIHOP = "Multihop attempted",
  79. .EDOTDOT = "RFS specific error",
  80. .EBADMSG = "Bad message",
  81. .EOVERFLOW = "Value too large for defined data type",
  82. .ENOTUNIQ = "Name not unique on network",
  83. .EBADFD = "File descriptor in bad state",
  84. .EREMCHG = "Remote address changed",
  85. .ELIBACC = "Can not access a needed shared library",
  86. .ELIBBAD = "Accessing a corrupted shared library",
  87. .ELIBSCN = ".lib section in a.out corrupted",
  88. .ELIBMAX = "Attempting to link in too many shared libraries",
  89. .ELIBEXEC = "Cannot exec a shared library directly",
  90. .EILSEQ = "Invalid or incomplete multibyte or wide character",
  91. .ERESTART = "Interrupted system call should be restarted",
  92. .ESTRPIPE = "Streams pipe error",
  93. .EUSERS = "Too many users",
  94. .ENOTSOCK = "Socket operation on non-socket",
  95. .EDESTADDRREQ = "Destination address required",
  96. .EMSGSIZE = "Message too long",
  97. .EPROTOTYPE = "Protocol wrong type for socket",
  98. .ENOPROTOOPT = "Protocol not available",
  99. .EPROTONOSUPPORT = "Protocol not supported",
  100. .ESOCKTNOSUPPORT = "Socket type not supported",
  101. .EOPNOTSUPP = "Operation not supported",
  102. .EPFNOSUPPORT = "Protocol family not supported",
  103. .EAFNOSUPPORT = "Address family not supported by protocol",
  104. .EADDRINUSE = "Address already in use",
  105. .EADDRNOTAVAIL = "Cannot assign requested address",
  106. .ENETDOWN = "Network is down",
  107. .ENETUNREACH = "Network is unreachable",
  108. .ENETRESET = "Network dropped connection on reset",
  109. .ECONNABORTED = "Software caused connection abort",
  110. .ECONNRESET = "Connection reset by peer",
  111. .ENOBUFS = "No buffer space available",
  112. .EISCONN = "Transport endpoint is already connected",
  113. .ENOTCONN = "Transport endpoint is not connected",
  114. .ESHUTDOWN = "Cannot send after transport endpoint shutdown",
  115. .ETOOMANYREFS = "Too many references: cannot splice",
  116. .ETIMEDOUT = "Connection timed out",
  117. .ECONNREFUSED = "Connection refused",
  118. .EHOSTDOWN = "Host is down",
  119. .EHOSTUNREACH = "No route to host",
  120. .EALREADY = "Operation already in progress",
  121. .EINPROGRESS = "Operation now in progress",
  122. .ESTALE = "Stale file handle",
  123. .EUCLEAN = "Structure needs cleaning",
  124. .ENOTNAM = "Not a XENIX named type file",
  125. .ENAVAIL = "No XENIX semaphores available",
  126. .EISNAM = "Is a named type file",
  127. .EREMOTEIO = "Remote I/O error",
  128. .EDQUOT = "Disk quota exceeded",
  129. .ENOMEDIUM = "No medium found",
  130. .EMEDIUMTYPE = "Wrong medium type",
  131. .ECANCELED = "Operation canceled",
  132. .ENOKEY = "Required key not available",
  133. .EKEYEXPIRED = "Key has expired",
  134. .EKEYREVOKED = "Key has been revoked",
  135. .EKEYREJECTED = "Key was rejected by service",
  136. .EOWNERDEAD = "Owner died",
  137. .ENOTRECOVERABLE = "State not recoverable",
  138. .ERFKILL = "Operation not possible due to RF-kill",
  139. .EHWPOISON = "Memory page has hardware error",
  140. }
  141. _get_platform_error :: proc(errno: linux.Errno) -> Error {
  142. #partial switch errno {
  143. case .NONE:
  144. return nil
  145. case .EPERM:
  146. return .Permission_Denied
  147. case .EEXIST:
  148. return .Exist
  149. case .ENOENT:
  150. return .Not_Exist
  151. }
  152. return Platform_Error(i32(errno))
  153. }
  154. _error_string :: proc(errno: i32) -> string {
  155. if errno >= 0 && errno <= i32(max(linux.Errno)) {
  156. return _errno_strings[linux.Errno(errno)]
  157. }
  158. return "Unknown Error"
  159. }