diff options
author | johannst <johannes.stoelp@gmail.com> | 2021-04-17 23:41:17 +0200 |
---|---|---|
committer | johannst <johannes.stoelp@gmail.com> | 2021-04-17 23:41:17 +0200 |
commit | 26088bf37ef85681cf2158fdff82233b1b0c9bfd (patch) | |
tree | f0e9e3ac1f123b3fd5446e1fafe01e491da9ebbb /lib/include/syscalls.h | |
parent | 9b4b10a31954c00813a7cbf9411d30bc84eccea8 (diff) | |
download | dynld-26088bf37ef85681cf2158fdff82233b1b0c9bfd.tar.gz dynld-26088bf37ef85681cf2158fdff82233b1b0c9bfd.zip |
added close,access,write,pread,mmap,munmap syscalls + syscall ret handler
Diffstat (limited to 'lib/include/syscalls.h')
-rw-r--r-- | lib/include/syscalls.h | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/include/syscalls.h b/lib/include/syscalls.h index 34b6b37..7808e98 100644 --- a/lib/include/syscalls.h +++ b/lib/include/syscalls.h @@ -5,6 +5,8 @@ #include <stddef.h> // size_t #include <sys/types.h> // ssize_t, off_t, ... +extern int dynld_errno; + // Syscall definitions taken from corresponding man pages, eg // open(2) // read(2) @@ -12,12 +14,27 @@ #define O_RDONLY 00 int open(const char* path, int flags); +int close(int fd); + +#define F_OK 0 +#define R_OK 4 +int access(const char* path, int mode); +ssize_t write(int fd, const void* buf, size_t count); ssize_t read(int fd, void* buf, size_t count); +ssize_t pread(int fd, void* buf, size_t count, off_t offset); -#define SEEK_SET 0 -#define SEEK_CUR 1 -#define SEEK_END 2 -off_t lseek(int fd, off_t offset, int whence); +// mmap - prot: +#define PROT_READ 0x1 +#define PROT_WRITE 0x2 +#define PROT_EXEC 0x4 +// mmap - flags: +#define MAP_PRIVATE 0x2 +#define MAP_ANONYMOUS 0x20 +#define MAP_FIXED 0x10 +// mmap - ret: +#define MAP_FAILED ((void*)-1) +void* mmap(void* addr, size_t length, int prot, int flags, int fd, off_t offset); +int munmap(void* addr, size_t length); void _exit(int status); |