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/stdio/file.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/user/lib/stdio') diff --git a/src/user/lib/stdio/file.c b/src/user/lib/stdio/file.c index 8c0fc57..f3120d7 100644 --- a/src/user/lib/stdio/file.c +++ b/src/user/lib/stdio/file.c @@ -42,8 +42,16 @@ FILE *fopen(const char *path, const char *mode) { path = tmppath; } - if (mode[0] == 'w' || mode[0] == 'a') - flags |= OPEN_CREATE; + if (strchr(mode, 'e')) { + /* camellia extension: open as executable */ + flags |= OPEN_EXEC; + } else if (strchr(mode, 'r')) { + flags |= OPEN_READ; + if (strchr(mode, '+')) + flags |= OPEN_WRITE; + } else { + flags |= OPEN_WRITE | OPEN_CREATE; + } h = _syscall_open(path, strlen(path), flags); if (tmppath) free(tmppath); -- cgit v1.2.3