From 4469d8f0fb298de784119943900845d04702f69f Mon Sep 17 00:00:00 2001 From: Sven Herrmann Date: Fri, 29 May 2020 13:08:43 +0000 Subject: [PATCH] pkg/fatfs/fatfs_vfs: fix flag translation in _open --- pkg/fatfs/fatfs_vfs/fatfs_vfs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/fatfs/fatfs_vfs/fatfs_vfs.c b/pkg/fatfs/fatfs_vfs/fatfs_vfs.c index a41168d1a9..0892c8ab6b 100644 --- a/pkg/fatfs/fatfs_vfs/fatfs_vfs.c +++ b/pkg/fatfs/fatfs_vfs/fatfs_vfs.c @@ -151,7 +151,12 @@ static int _open(vfs_file_t *filp, const char *name, int flags, mode_t mode, fatfs_flags |= FA_CREATE_ALWAYS; } if ((flags & O_CREAT) == O_CREAT) { - fatfs_flags |= FA_CREATE_NEW; + if ((flags & O_EXCL) == O_EXCL) { + fatfs_flags |= FA_CREATE_NEW; + } + else { + fatfs_flags |= FA_OPEN_ALWAYS; + } } else { fatfs_flags |= FA_OPEN_EXISTING;