You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/04/14 14:21:32 UTC

[incubator-nuttx] 01/02: fs/fcntl: add O_APPEND flag judge in fcntl

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

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

commit 05cc6fb610de679d78079f38037e131103ca2db8
Author: liuhaitao <li...@xiaomi.com>
AuthorDate: Fri Dec 31 17:48:00 2021 +0800

    fs/fcntl: add O_APPEND flag judge in fcntl
    
    Signed-off-by: liuhaitao <li...@xiaomi.com>
---
 fs/vfs/fs_fcntl.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/vfs/fs_fcntl.c b/fs/vfs/fs_fcntl.c
index 1f6f425eed..f796fa5b23 100644
--- a/fs/vfs/fs_fcntl.c
+++ b/fs/vfs/fs_fcntl.c
@@ -150,6 +150,11 @@ static int file_vfcntl(FAR struct file *filep, int cmd, va_list ap)
               oflags          &=  (FFCNTL & ~O_NONBLOCK);
               filep->f_oflags &= ~(FFCNTL & ~O_NONBLOCK);
               filep->f_oflags |=  oflags;
+
+              if (filep->f_oflags & O_APPEND)
+                {
+                  file_seek(filep, 0, SEEK_END);
+                }
             }
         }
         break;