source: rtems/cpukit/posix/src/aio_fsync.c @ 1d572eba

5
Last change on this file since 1d572eba was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/**
2 * @file
3 *
4 * @brief Syncing of all Outstanding Asynchronous I/O Operations
5 * @ingroup POSIXAPI
6 */
7
8/*
9 * Copyright 2010, Alin Rus <alin.codejunkie@gmail.com>
10 *
11 * The license and distribution terms for this file may be
12 * found in the file LICENSE in this distribution or at
13 * http://www.rtems.org/license/LICENSE.
14 */
15
16#if HAVE_CONFIG_H
17#include "config.h"
18#endif
19
20#include <aio.h>
21#include <errno.h>
22#include <stdlib.h>
23#include <rtems/posix/aio_misc.h>
24#include <rtems/system.h>
25#include <rtems/seterr.h>
26
27/*
28 *  aio_fsync
29 *
30 * Asynchronous file synchronization
31 *
32 *  Input parameters:
33 *        op     - O_SYNC
34 *        aiocbp - asynchronous I/O control block
35 *
36 *  Output parameters:
37 *        -1 - request could not pe enqueued
38 *           - FD not opened for write
39 *           - not enough memory
40 *           - op is not O_SYNC
41 *         0 - otherwise
42 */
43
44int aio_fsync(
45  int            op,
46  struct aiocb  *aiocbp
47)
48{
49  rtems_aio_request *req;
50  int mode;
51
52  if (op != O_SYNC)
53    rtems_aio_set_errno_return_minus_one (EINVAL, aiocbp);
54 
55  mode = fcntl (aiocbp->aio_fildes, F_GETFL);
56  if (!(((mode & O_ACCMODE) == O_WRONLY) || ((mode & O_ACCMODE) == O_RDWR)))
57    rtems_aio_set_errno_return_minus_one (EBADF, aiocbp);
58
59  req = malloc (sizeof (rtems_aio_request));
60  if (req == NULL)
61    rtems_aio_set_errno_return_minus_one (EAGAIN, aiocbp);
62
63  req->aiocbp = aiocbp;
64  req->aiocbp->aio_lio_opcode = LIO_SYNC;
65 
66  return rtems_aio_enqueue (req);
67   
68}
Note: See TracBrowser for help on using the repository browser.