From 23968c9f1116ab35d2f7c45be40ae18896517b79 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Sat, 23 Nov 2024 15:55:21 +0100 Subject: vfs: Support O_TRUNC --- userland/libc/stdio/fopen.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'userland') 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; } -- cgit v1.2.3