summaryrefslogtreecommitdiff
path: root/userland
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-11-23 15:55:21 +0100
committerAnton Kling <anton@kling.gg>2024-11-23 16:31:25 +0100
commit23968c9f1116ab35d2f7c45be40ae18896517b79 (patch)
treef3955046c6d1abc7a79633982a647324a3d868bf /userland
parent02194a2557b50bf850ff2a26d6e1eb6e7b67bb7c (diff)
vfs: Support O_TRUNC
Diffstat (limited to 'userland')
-rw-r--r--userland/libc/stdio/fopen.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/userland/libc/stdio/fopen.c b/userland/libc/stdio/fopen.c
index fe0b5cf..38ccbf1 100644
--- a/userland/libc/stdio/fopen.c
+++ b/userland/libc/stdio/fopen.c
@@ -18,7 +18,7 @@ FILE *fopen(const char *pathname, const char *mode) {
flag |= O_READ;
break;
case 'w':
- flag |= O_WRITE;
+ flag |= O_WRITE | O_TRUNC;
break;
case 'a':
flag |= O_APPEND;
@@ -36,9 +36,6 @@ FILE *fopen(const char *pathname, const char *mode) {
close(fd);
return NULL;
}
- if(flag & O_WRITE) {
- ftruncate(fd, 0);
- }
r->has_control_over_the_fd = 1;
return r;
}