Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Errors

An error is a positive number in usr/vex/errno.h. A system call returns its negative in the result register, and the C library turns that into -1 with the number in errno.

The numbers are Vex numbers. They are not the Linux numbers. A program that compares an error against a literal from Linux is wrong on Vex. A C library defines each POSIX name from the __k_ name in this header. It may add numbers of its own above the kernel ones for errors that the kernel never returns. The bootstrap C library, mlibc, does so from 2001.

ISO C takes the range 101 to 103. POSIX takes 201 and up. The kernel also has -ERESTART (4095), which never reaches a program: the return path of a system call turns it into a restart or into -EINTR. The C library has its own ERESTART (2032) in the range that the kernel never returns, so the two do not clash. The mechanism is in System calls.

The string of an error comes from strerror_r() in kernel/libk/string.c. It reads the absolute value of its argument, so a caller may pass the positive number or the negated one from a system call. A number that it does not know gives unknown errnum (N), and 0 gives no error.

The values

ErrorValue
__k_EDOM101
__k_EILSEQ102
__k_ERANGE103
__k_E2BIG201
__k_EACCES202
__k_EADDRINUSE203
__k_EADDRNOTAVAIL204
__k_EAFNOSUPPORT205
__k_EAGAIN206
__k_EALREADY207
__k_EBADF208
__k_EBADMSG209
__k_EBUSY210
__k_ECANCELED211
__k_ECHILD212
__k_ECONNABORTED213
__k_ECONNREFUSED214
__k_ECONNRESET215
__k_EDEADLK216
__k_EDESTADDRREQ217
__k_EDQUOT218
__k_EEXIST219
__k_EFAULT220
__k_EFBIG221
__k_EHOSTUNREACH222
__k_EIDRM223
__k_EINPROGRESS224
__k_EINTR225
__k_EINVAL226
__k_EIO227
__k_EISCONN228
__k_EISDIR229
__k_ELOOP230
__k_EMFILE231
__k_EMLINK232
__k_EMSGSIZE233
__k_EMULTIHOP234
__k_ENAMETOOLONG235
__k_ENETDOWN236
__k_ENETRESET237
__k_ENETUNREACH238
__k_ENFILE239
__k_ENOBUFS240
__k_ENODATA241
__k_ENODEV242
__k_ENOENT243
__k_ENOEXEC244
__k_ENOLCK245
__k_ENOLINK246
__k_ENOMEM247
__k_ENOMSG248
__k_ENOPROTOOPT249
__k_ENOSPC250
__k_ENOSR251
__k_ENOSTR252
__k_ENOSYS253
__k_ENOTCONN254
__k_ENOTDIR255
__k_ENOTEMPTY256
__k_ENOTSOCK257
__k_ENOTSUP258
__k_ENOTTY259
__k_ENXIO260
__k_EOPNOTSUPP261
__k_EOVERFLOW262
__k_EPERM263
__k_EPIPE264
__k_EPROTO265
__k_EPROTONOSUPPORT266
__k_EPROTOTYPE267
__k_EROFS268
__k_ESPIPE269
__k_ESRCH270
__k_ESTALE271
__k_ETIME272
__k_ETIMEDOUT273
__k_ETXTBSY274
__k_EXDEV276
__k_ENOTRECOVERABLE277
__k_EOWNERDEAD278

A new error takes the next free number above the current ones. A number that a program can see must not change.

Source