Don't call ReadArgs() if started from WB.
[tangerine.git] / compiler / clib / fsync.c
blobd41f1b17619c51b81df88ed20e8944488ba80af7
1 /*
2 Copyright © 2004, The AROS Development Team. All rights reserved.
3 $Id$
5 POSIX function fsync().
6 */
8 #include <exec/types.h>
9 #include <dos/dosextens.h>
10 #include <proto/exec.h>
11 #include <proto/dos.h>
12 #include "__errno.h"
13 #include "__open.h"
15 #include <fcntl.h>
16 #include <unistd.h>
18 int fsync(int fd)
19 /* FIXME: documentation */
21 AROS_GET_SYSBASE_OK
22 AROS_GET_DOSBASE
24 fdesc *fdesc = __getfdesc(fd);
26 if (!fdesc || !(fdesc->flags & O_WRITE))
28 errno = EBADF;
29 return -1;
32 if (!Flush((BPTR) fdesc->fh))
34 errno = IoErr2errno(IoErr());
35 return -1;
38 return 0;
39 } /* fsync */