This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 46a7d4af1 fs/fatfs: Fix open for write
46a7d4af1 is described below

commit 46a7d4af1446eebb1ac094d3c4ea3f69dba929f7
Author: Jerzy Kasenberg <jerzy.kasenb...@codecoup.pl>
AuthorDate: Sun Jun 22 11:08:39 2025 +0200

    fs/fatfs: Fix open for write
    
    When fatfs_open() was called to open file
    for writing it set FA_WRITE flag to fat driver.
    It is enough if file already exists but if
    it first call to open file to write it always
    failed.
    
    Now additional flag FA_OPEN_ALWAYS is added
    to make sure file will be created if it's not
    present yet.
    
    For FS_ACCESS_READ only flag file still must
    exists before.
    
    Signed-off-by: Jerzy Kasenberg <je...@apache.org>
---
 fs/fatfs/src/mynewt_glue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/fatfs/src/mynewt_glue.c b/fs/fatfs/src/mynewt_glue.c
index 47008c293..715475ea1 100644
--- a/fs/fatfs/src/mynewt_glue.c
+++ b/fs/fatfs/src/mynewt_glue.c
@@ -281,7 +281,7 @@ fatfs_open(const char *path, uint8_t access_flags, struct 
fs_file **out_fs_file)
         mode |= FA_READ;
     }
     if (access_flags & FS_ACCESS_WRITE) {
-        mode |= FA_WRITE;
+        mode |= FA_WRITE | FA_OPEN_ALWAYS;
     }
     if (access_flags & FS_ACCESS_APPEND) {
         mode |= FA_OPEN_APPEND;

Reply via email to