diff options
author | Ralf Corsepius <ralf.corsepius@rtems.org> | 2010-08-20 09:08:05 +0000 |
---|---|---|
committer | Ralf Corsepius <ralf.corsepius@rtems.org> | 2010-08-20 09:08:05 +0000 |
commit | a45e501813f1a3f81212d2705da05ed41776e52c (patch) | |
tree | 17f9a023e6c463a504eeff76339575fcf33d37c4 /cpukit/posix/src/aio_fsync.c | |
parent | 2010-08-19 Joel Sherrill <joel.sherrilL@OARcorp.com> (diff) | |
download | rtems-a45e501813f1a3f81212d2705da05ed41776e52c.tar.bz2 |
2010-08-16 Alin Rus <alin.codejunkie@gmail.com>
* posix/include/aio.h: Add LIO_SYNC.
* posix/include/rtems/posix/aio_misc.h: Add aio_request_queue,
Cosmetics.
* posix/src/aio_cancel.c, posix/src/aio_fsync.c, posix/src/aio_misc.c:
Rework.
Diffstat (limited to 'cpukit/posix/src/aio_fsync.c')
-rw-r--r-- | cpukit/posix/src/aio_fsync.c | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/cpukit/posix/src/aio_fsync.c b/cpukit/posix/src/aio_fsync.c index 0aca7ad9bd..4a28b194b5 100644 --- a/cpukit/posix/src/aio_fsync.c +++ b/cpukit/posix/src/aio_fsync.c @@ -1,14 +1,11 @@ /* - * 6.7.9 Asynchronous File Synchronization, P1003.1b-1993, p. 166 + * Copyright 2010, Alin Rus <alin.codejunkie@gmail.com> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. * - * COPYRIGHT (c) 1989-2007. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.com/license/LICENSE. - * - * $Id$ + * $Id$ */ #if HAVE_CONFIG_H @@ -17,14 +14,50 @@ #include <aio.h> #include <errno.h> - +#include <stdlib.h> +#include <rtems/posix/aio_misc.h> #include <rtems/system.h> #include <rtems/seterr.h> +/* + * aio_fsync + * + * Asynchronous file synchronization + * + * Input parameters: + * op - O_SYNC + * aiocbp - asynchronous I/O control block + * + * Output parameters: + * -1 - request could not pe enqueued + * - FD not opened for write + * - not enough memory + * - op is not O_SYNC + * 0 - otherwise + */ + int aio_fsync( - int op __attribute__((unused)), - struct aiocb *aiocbp __attribute__((unused)) + int op, + struct aiocb *aiocbp ) { - rtems_set_errno_and_return_minus_one( ENOSYS ); + rtems_aio_request *req; + int mode; + + if (op != O_SYNC) + rtems_aio_set_errno_return_minus_one (EINVAL, aiocbp); + + mode = fcntl (aiocbp->aio_fildes, F_GETFL); + if (!(((mode & O_ACCMODE) == O_WRONLY) || ((mode & O_ACCMODE) == O_RDWR))) + rtems_aio_set_errno_return_minus_one (EBADF, aiocbp); + + req = malloc (sizeof (rtems_aio_request)); + if (req == NULL) + rtems_aio_set_errno_return_minus_one (EAGAIN, aiocbp); + + req->aiocbp = aiocbp; + req->aiocbp->aio_lio_opcode = LIO_SYNC; + + return rtems_aio_enqueue (req); + } |