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

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 9cd96340e16 fs/vfs: do not keep open-time flags in f_oflags
9cd96340e16 is described below

commit 9cd96340e1611690165f1f9f60e618d0b7de205f
Author: guohao15 <[email protected]>
AuthorDate: Wed Nov 11 16:17:56 2026 +0800

    fs/vfs: do not keep open-time flags in f_oflags
    
    O_CREAT, O_EXCL, O_NOCTTY and O_TRUNC only affect the open() call
    itself, but file_vopen() keeps them in f_oflags, so fcntl(F_GETFL)
    reports them.  POSIX defines F_GETFL to return the file status flags
    and access mode, which do not include these flags.
    
    Clear them once the open has succeeded.
    
    Signed-off-by: guohao15 <[email protected]>
    Signed-off-by: jingfei <[email protected]>
---
 fs/vfs/fs_open.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/vfs/fs_open.c b/fs/vfs/fs_open.c
index 760a6351e06..e897d6b9b78 100644
--- a/fs/vfs/fs_open.c
+++ b/fs/vfs/fs_open.c
@@ -352,6 +352,8 @@ static int file_vopen(FAR struct file *filep, FAR const 
char *path,
 #ifdef CONFIG_FS_NOTIFY
   notify_open(path, filep->f_oflags);
 #endif
+
+  filep->f_oflags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
   return OK;
 
 errout_with_inode:

Reply via email to