diff --git a/fs/fs_fcntl.c b/fs/fs_fcntl.c index ff53b0f205a..b4d09570568 100644 --- a/fs/fs_fcntl.c +++ b/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 * * 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; diff --git a/include/fcntl.h b/include/fcntl.h index 382c5be16b9..0d423a5d064 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -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 */