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
This commit is contained in:
patacongo 2013-02-12 14:05:30 +00:00
parent d43f284715
commit 2d7e5ae7d8
2 changed files with 20 additions and 2 deletions

View File

@ -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
@ -49,6 +49,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;

View File

@ -79,6 +79,13 @@
#define _O_MAXBIT 8
/* Synonyms historically used as F_SETFL flags (BSD). Also FASYNC. */
#define FNDELAY O_NONBLOCK
#define FNONBLOCK O_NONBLOCK
#define FAPPEND O_APPEND
#define FSYNC O_SYNC
/* fcntl() commands */
#define F_DUPFD 0 /* Duplicate a file descriptor */