r4548@vps: verhaegs | 2007-04-23 10:55:24 -0400
[AROS.git] / compiler / clib / fsync.c
blobae01a2581cf0477015913141d78db98dfe4b3f92
1 /*
2 Copyright © 2004-2007, 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 fdesc *fdesc = __getfdesc(fd);
23 if (!fdesc || !(fdesc->flags & O_WRITE))
25 errno = EBADF;
26 return -1;
29 if (!Flush((BPTR) fdesc->fh))
31 errno = IoErr2errno(IoErr());
32 return -1;
35 return 0;
36 } /* fsync */