errno.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* The <errno.h> header defines the numbers of the various errors that can
  2. * occur during program execution. They are visible to user programs and
  3. * should be small positive integers. However, they are also used within
  4. * MINIX, where they must be negative. For example, the READ system call is
  5. * executed internally by calling do_read(). This function returns either a
  6. * (negative) error number or a (positive) number of bytes actually read.
  7. *
  8. * To solve the problem of having the error numbers be negative inside the
  9. * the system and positive outside, the following mechanism is used. All the
  10. * definitions are are the form:
  11. *
  12. * #define EPERM (_SIGN 1)
  13. *
  14. * If the macro _SYSTEM is defined, then _SIGN is set to "-", otherwise it is
  15. * set to "". Thus when compiling the operating system, the macro _SYSTEM
  16. * will be defined, setting EPERM to (- 1), whereas when when this
  17. * file is included in an ordinary user program, EPERM has the value ( 1).
  18. */
  19. #ifndef _ERRNO_H /* check if <errno.h> is already included */
  20. #define _ERRNO_H /* it is not included; note that fact */
  21. /* Now define _SIGN as "" or "-" depending on _SYSTEM. */
  22. #ifdef _SYSTEM
  23. # define _SIGN -
  24. # define OK 0
  25. #else
  26. # define _SIGN
  27. #endif
  28. extern int errno; /* place where the error numbers go */
  29. /* Here are the numerical values of the error numbers. */
  30. #define _NERROR 39 /* number of errors */
  31. #define ERROR (_SIGN 99) /* generic error */
  32. #define EPERM (_SIGN 1) /* operation not permitted */
  33. #define ENOENT (_SIGN 2) /* no such file or directory */
  34. #define ESRCH (_SIGN 3) /* no such process */
  35. #define EINTR (_SIGN 4) /* interrupted function call */
  36. #define EIO (_SIGN 5) /* input/output error */
  37. #define ENXIO (_SIGN 6) /* no such device or address */
  38. #define E2BIG (_SIGN 7) /* arg list too long */
  39. #define ENOEXEC (_SIGN 8) /* exec format error */
  40. #define EBADF (_SIGN 9) /* bad file descriptor */
  41. #define ECHILD (_SIGN 10) /* no child process */
  42. #define EAGAIN (_SIGN 11) /* resource temporarily unavailable */
  43. #define ENOMEM (_SIGN 12) /* not enough space */
  44. #define EACCES (_SIGN 13) /* permission denied */
  45. #define EFAULT (_SIGN 14) /* bad address */
  46. #define ENOTBLK (_SIGN 15) /* Extension: not a block special file */
  47. #define EBUSY (_SIGN 16) /* resource busy */
  48. #define EEXIST (_SIGN 17) /* file exists */
  49. #define EXDEV (_SIGN 18) /* improper link */
  50. #define ENODEV (_SIGN 19) /* no such device */
  51. #define ENOTDIR (_SIGN 20) /* not a directory */
  52. #define EISDIR (_SIGN 21) /* is a directory */
  53. #define EINVAL (_SIGN 22) /* invalid argument */
  54. #define ENFILE (_SIGN 23) /* too many open files in system */
  55. #define EMFILE (_SIGN 24) /* too many open files */
  56. #define ENOTTY (_SIGN 25) /* inappropriate I/O control operation */
  57. #define ETXTBSY (_SIGN 26) /* no longer used */
  58. #define EFBIG (_SIGN 27) /* file too large */
  59. #define ENOSPC (_SIGN 28) /* no space left on device */
  60. #define ESPIPE (_SIGN 29) /* invalid seek */
  61. #define EROFS (_SIGN 30) /* read-only file system */
  62. #define EMLINK (_SIGN 31) /* too many links */
  63. #define EPIPE (_SIGN 32) /* broken pipe */
  64. #define EDOM (_SIGN 33) /* domain error (from ANSI C std) */
  65. #define ERANGE (_SIGN 34) /* result too large (from ANSI C std) */
  66. #define EDEADLK (_SIGN 35) /* resource deadlock avoided */
  67. #define ENAMETOOLONG (_SIGN 36) /* file name too long */
  68. #define ENOLCK (_SIGN 37) /* no locks available */
  69. #define ENOSYS (_SIGN 38) /* function not implemented */
  70. #define ENOTEMPTY (_SIGN 39) /* directory not empty */
  71. /* The following are not POSIX errors, but they can still happen. */
  72. #define ELOCKED (_SIGN 101) /* can't send message */
  73. #define EBADCALL (_SIGN 102) /* error on send/receive */
  74. /* The following error codes are generated by the kernel itself. */
  75. #ifdef _SYSTEM
  76. #define E_BAD_DEST -1 /* destination address illegal */
  77. #define E_BAD_SRC -2 /* source address illegal */
  78. #define E_TRY_AGAIN -3 /* can't send-- tables full */
  79. #define E_OVERRUN -4 /* interrupt for task that is not waiting */
  80. #define E_BAD_BUF -5 /* message buf outside caller's addr space */
  81. #define E_TASK -6 /* can't send to task */
  82. #define E_NO_MESSAGE -7 /* RECEIVE failed: no message present */
  83. #define E_NO_PERM -8 /* ordinary users can't send to tasks */
  84. #define E_BAD_FCN -9 /* only valid fcns are SEND, RECEIVE, BOTH */
  85. #define E_BAD_ADDR -10 /* bad address given to utility routine */
  86. #define E_BAD_PROC -11 /* bad proc number given to utility */
  87. #endif /* _SYSTEM */
  88. #endif /* _ERRNO_H */