diff options
author | dzwdz | 2022-10-02 19:25:17 +0200 |
---|---|---|
committer | dzwdz | 2022-10-02 19:25:17 +0200 |
commit | 710e9b2b5c16f74f66420c66d12455ad518d42c7 (patch) | |
tree | 82b88cc07ef3f122512354d649af68584bd4da4d /src/user/lib/unistd.c | |
parent | 503d9ff758f8b83295830bdfc8c2ea56837d25e5 (diff) |
syscall/open: add the full suite of READ/WRITE flags
Diffstat (limited to 'src/user/lib/unistd.c')
-rw-r--r-- | src/user/lib/unistd.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/user/lib/unistd.c b/src/user/lib/unistd.c index ed8d77f..04a060d 100644 --- a/src/user/lib/unistd.c +++ b/src/user/lib/unistd.c @@ -1,3 +1,4 @@ +#include <camellia/flags.h> #include <camellia/path.h> #include <camellia/syscalls.h> #include <errno.h> @@ -30,7 +31,8 @@ int unlink(const char *path) { size_t abslen = absolutepath(abspath, path, len); if (abslen == 0) { errno = EINVAL; goto err; } - handle_t h = _syscall_open(abspath, abslen - 1, 0); + // TODO take cwd into account + handle_t h = _syscall_open(abspath, abslen - 1, OPEN_WRITE); if (h < 0) { errno = -h; goto err; } long ret = _syscall_remove(h); @@ -49,7 +51,7 @@ int isatty(int fd) { int execv(const char *path, char *const argv[]) { - FILE *file = fopen(path, "r"); + FILE *file = fopen(path, "e"); char hdr[4] = {0}; if (!file) return -1; @@ -114,7 +116,8 @@ int chdir(const char *path) { cwd2[len + 1] = '\0'; } - h = _syscall_open(cwd2, strlen(cwd2), 0); + /* check if exists */ + h = _syscall_open(cwd2, strlen(cwd2), OPEN_READ); if (h < 0) { errno = ENOENT; return -1; |