summaryrefslogtreecommitdiff
path: root/userland/libc/stdio/fwrite.c
diff options
context:
space:
mode:
Diffstat (limited to 'userland/libc/stdio/fwrite.c')
-rw-r--r--userland/libc/stdio/fwrite.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/userland/libc/stdio/fwrite.c b/userland/libc/stdio/fwrite.c
index 6499529..d2086cb 100644
--- a/userland/libc/stdio/fwrite.c
+++ b/userland/libc/stdio/fwrite.c
@@ -2,6 +2,11 @@
#include <sys/types.h>
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) {
+ if (!stream->has_control_over_the_fd) {
+ if (stream->append) {
+ fseek(stream, 0, SEEK_END);
+ }
+ }
// FIXME: Check for overflow
size_t bytes_to_write = nmemb * size;
size_t rc = stream->write(stream, ptr, bytes_to_write);