diff options
Diffstat (limited to 'lib/sys')
| -rw-r--r-- | lib/sys/errno.h | 77 | ||||
| -rw-r--r-- | lib/sys/io.h | 6 | ||||
| -rw-r--r-- | lib/sys/open.h | 11 |
3 files changed, 94 insertions, 0 deletions
diff --git a/lib/sys/errno.h b/lib/sys/errno.h new file mode 100644 index 0000000..86ae4bf --- /dev/null +++ b/lib/sys/errno.h @@ -0,0 +1,77 @@ +#ifndef ERRNO_H +#define ERRNO_H + +#define ERROR_PERM 1 /* Operation not permitted */ +#define ERROR_NOENT 2 /* No such file or directory */ +#define ERROR_SRCH 3 /* No such process */ +#define ERROR_INTR 4 /* Interrupted system call */ +#define ERROR_IO 5 /* I/O error */ +#define ERROR_NXIO 6 /* No such device or address */ +#define ERROR_2BIG 7 /* Argument list too long */ +#define ERROR_NOEXEC 8 /* Exec format error */ +#define ERROR_BADF 9 /* Bad file number */ +#define ERROR_CHILD 10 /* No child processes */ +#define ERROR_AGAIN 11 /* Try again */ +#define ERROR_NOMEM 12 /* Out of memory */ +#define ERROR_ACCES 13 /* Permission denied */ +#define ERROR_FAULT 14 /* Bad address */ +#define ERROR_NOTBLK 15 /* Block device required */ +#define ERROR_BUSY 16 /* Device or resource busy */ +#define ERROR_EXIST 17 /* File exists */ +#define ERROR_XDEV 18 /* Cross-device link */ +#define ERROR_NODEV 19 /* No such device */ +#define ERROR_NOTDIR 20 /* Not a directory */ +#define ERROR_ISDIR 21 /* Is a directory */ +#define ERROR_INVAL 22 /* Invalid argument */ +#define ERROR_NFILE 23 /* File table overflow */ +#define ERROR_MFILE 24 /* Too many open files */ +#define ERROR_NOTTY 25 /* Not a typewriter */ +#define ERROR_TXTBSY 26 /* Text file busy */ +#define ERROR_FBIG 27 /* File too large */ +#define ERROR_NOSPC 28 /* No space left on device */ +#define ERROR_SPIPE 29 /* Illegal seek */ +#define ERROR_ROFS 30 /* Read-only file system */ +#define ERROR_MLINK 31 /* Too many links */ +#define ERROR_PIPE 32 /* Broken pipe */ +#define ERROR_DOM 33 /* Math argument out of domain of func */ +#define ERROR_RANGE 34 /* Math result not representable */ + +static const char *errstr[] = { + "", + "Operation not permitted", + "No such file or directory", + "No such process", + "Interrupted system call", + "I/O error", + "No such device or address", + "Argument list too long", + "Exec format error", + "Bad file number", + "No child processes", + "Try again", + "Out of memory", + "Permission denied", + "Bad address", + "Block device required", + "Device or resource busy", + "File exists", + "Cross-device link", + "No such device", + "Not a directory", + "Is a directory", + "Invalid argument", + "File table overflow", + "Too many open files", + "Not a typewriter", + "Text file busy", + "File too large", + "No space left on device", + "Illegal seek", + "Read-only file system", + "Too many links", + "Broken pipe", + "Math argument out of domain of func", + "Math result not representable", +}; + +#endif diff --git a/lib/sys/io.h b/lib/sys/io.h index 8086869..4222c4d 100644 --- a/lib/sys/io.h +++ b/lib/sys/io.h @@ -3,9 +3,15 @@ #include "write.h" #include "read.h" +#include "open.h" +#include "close.h" #define STDIN_FD 0 #define STDOUT_FD 1 #define STDERR_FD 2 +#define FILE_READ_ONLY 0 +#define FILE_WRITE_ONLY 1 +#define FILE_READ_WRITE 2 + #endif diff --git a/lib/sys/open.h b/lib/sys/open.h new file mode 100644 index 0000000..5aeab6d --- /dev/null +++ b/lib/sys/open.h @@ -0,0 +1,11 @@ +#ifndef OPEN_H +#define OPEN_H + +#include "syscalls.h" + +static int open(const char *filename, int flags, int mode) +{ + return syscall(OPEN, filename, flags, mode); +} + +#endif |