summaryrefslogtreecommitdiff
path: root/src/user/lib/stdio
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/lib/stdio')
-rw-r--r--src/user/lib/stdio/file.c12
1 files changed, 10 insertions, 2 deletions
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);