From cd8e0b0f4ab8a64495e05b31cf235d40887bf29b Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 18 Jun 2023 15:48:27 +0200 Subject: [PATCH] wutdevoptab: Add support for opening files with (O_EXCL | O_CREAT | O_RDWR) and (O_EXCL | O_CREAT | O_WRONLY) --- libraries/wutdevoptab/devoptab_fsa_open.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/wutdevoptab/devoptab_fsa_open.cpp b/libraries/wutdevoptab/devoptab_fsa_open.cpp index b8dc41614..2ee491dbd 100644 --- a/libraries/wutdevoptab/devoptab_fsa_open.cpp +++ b/libraries/wutdevoptab/devoptab_fsa_open.cpp @@ -35,6 +35,12 @@ __wut_fsa_open(struct _reent *r, fsMode = "w"; } else if (((flags & O_ACCMODE) == O_RDWR) && ((flags & commonFlagMask) == (O_CREAT | O_TRUNC))) { fsMode = "w+"; + } else if (((flags & O_ACCMODE) == O_WRONLY) && ((flags & commonFlagMask) == O_CREAT) && (flags & O_EXCL) == O_EXCL) { + // if O_EXCL is set, we don't need O_TRUNC + fsMode = "w"; + } else if (((flags & O_ACCMODE) == O_RDWR) && ((flags & commonFlagMask) == O_CREAT) && (flags & O_EXCL) == O_EXCL) { + // if O_EXCL is set, we don't need O_TRUNC + fsMode = "w+"; } else if (((flags & O_ACCMODE) == O_WRONLY) && ((flags & commonFlagMask) == (O_CREAT | O_APPEND))) { fsMode = "a"; } else if (((flags & O_ACCMODE) == O_RDWR) && ((flags & commonFlagMask) == (O_CREAT | O_APPEND))) {