From 710e9b2b5c16f74f66420c66d12455ad518d42c7 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 2 Oct 2022 19:25:17 +0200 Subject: syscall/open: add the full suite of READ/WRITE flags --- src/user/lib/unistd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/user/lib/unistd.c') 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 #include #include #include @@ -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; -- cgit v1.2.3