From a45e501813f1a3f81212d2705da05ed41776e52c Mon Sep 17 00:00:00 2001 From: Ralf Corsepius Date: Fri, 20 Aug 2010 09:08:05 +0000 Subject: 2010-08-16 Alin Rus * 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. --- cpukit/posix/src/aio_fsync.c | 59 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 13 deletions(-) (limited to 'cpukit/posix/src/aio_fsync.c') 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 + * + * 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 #include - +#include +#include #include #include +/* + * 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); + } -- cgit v1.2.3