From f300338a57736927da5212250814f5b0b39be2b8 Mon Sep 17 00:00:00 2001 From: Lephe Date: Sat, 19 Mar 2022 19:26:23 +0000 Subject: [PATCH] fs: fix tracking of initial position with O_APPEND (*) (*) O_APPEND is *not* functional yet, this is just a hack for write-only streams. Currently O_APPEND does not reposition the cursor at the end of the file before every write. --- src/fs/fugue/fugue_open.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/fs/fugue/fugue_open.c b/src/fs/fugue/fugue_open.c index 7c48ebd..8ecafea 100644 --- a/src/fs/fugue/fugue_open.c +++ b/src/fs/fugue/fugue_open.c @@ -109,8 +109,11 @@ int fugue_open(char const *path, int flags, GUNUSED mode_t mode) /* If O_APPEND is set, move to the end of the file */ // TODO: O_APPEND should move the cursor before *each* write - if((flags & O_APPEND)) - BFile_Seek(fugue_fd, BFile_Size(fugue_fd)); + int pos = 0; + if((flags & O_APPEND)) { + pos = BFile_Size(fugue_fd); + BFile_Seek(fugue_fd, pos); + } /* Return the now-open file descriptor */ fugue_fd_t *data = malloc(sizeof *data); @@ -119,7 +122,7 @@ int fugue_open(char const *path, int flags, GUNUSED mode_t mode) goto end; } data->fd = fugue_fd; - data->pos = 0; + data->pos = pos; fs_descriptor_t fd_data = { .type = &fugue_descriptor_type,