Fixed handling of CFS_WRITE and CFS_APPEND
This commit is contained in:
parent
c55f320bd5
commit
bac526c5f1
5 changed files with 60 additions and 15 deletions
|
@ -30,7 +30,7 @@
|
|||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: cfs-posix.c,v 1.8 2007/12/23 14:12:44 oliverschmidt Exp $
|
||||
* $Id: cfs-posix.c,v 1.9 2008/01/08 14:27:06 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -43,7 +43,23 @@
|
|||
int
|
||||
cfs_open(const char *n, int f)
|
||||
{
|
||||
return open(n, f == CFS_READ? O_RDONLY: O_CREAT|O_TRUNC|O_RDWR);
|
||||
int s = 0;
|
||||
if(f == CFS_READ) {
|
||||
s = O_RDONLY;
|
||||
} else if(f & CFS_WRITE) {
|
||||
s = O_CREAT;
|
||||
if(f & CFS_READ) {
|
||||
s |= O_RDWR;
|
||||
} else {
|
||||
s |= O_WRONLY;
|
||||
}
|
||||
if(f & CFS_APPEND) {
|
||||
s |= O_APPEND;
|
||||
} else {
|
||||
s |= O_TRUNC;
|
||||
}
|
||||
}
|
||||
return open(n, s);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue