diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-02-12 14:05:30 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-02-12 14:05:30 +0000 |
commit | af1de0e25af56158bdd259a4999c5abfde57bf14 (patch) | |
tree | c35d2a7e50ab59b127068cedc7b349dad6c1da4e /nuttx/fs | |
parent | 5e92f8bf9f902ac2866d70180b448dc0b4228318 (diff) | |
download | px4-nuttx-af1de0e25af56158bdd259a4999c5abfde57bf14.tar.gz px4-nuttx-af1de0e25af56158bdd259a4999c5abfde57bf14.tar.bz2 px4-nuttx-af1de0e25af56158bdd259a4999c5abfde57bf14.zip |
Preserve access and creation flags with fcntl(F_SETFL)
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5643 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/fs')
-rw-r--r-- | nuttx/fs/fs_fcntl.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/nuttx/fs/fs_fcntl.c b/nuttx/fs/fs_fcntl.c index ff53b0f20..b4d095705 100644 --- a/nuttx/fs/fs_fcntl.c +++ b/nuttx/fs/fs_fcntl.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fs_fcntl.c * - * Copyright (C) 2009, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -50,6 +50,13 @@ #include "fs_internal.h" /**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define ACCESS_MODES (O_RDONLY | O_WRONLY | O_RDWR) +#define CREATION_MODES (O_CREAT | O_EXCL | O_APPEND | O_TRUNC) + +/**************************************************************************** * Private Functions ****************************************************************************/ @@ -143,7 +150,11 @@ static inline int file_vfcntl(int fildes, int cmd, va_list ap) */ { - this_file->f_oflags = va_arg(ap, int); + int oflags = va_arg(ap, int); + + oflags &= ~(ACCESS_MODES | CREATION_MODES); + this_file->f_oflags &= (ACCESS_MODES | CREATION_MODES); + this_file->f_oflags |= oflags; } break; |