aio_fsync(3)

NAME
aio_fsync - Synchronize a file's complete in-core state with that on disk

SYNOPSYS
#include <errno.h>

#include <aio.h>

int aio_fsync (int op, struct aiocb aiocbp)

DESCRIPTION

When dealing with asynchronous operations it is sometimes necessary to get into a consistent state. This would mean for AIO that one wants to know whether a certain request or a group of request were processed. This could be done by waiting for the notification sent by the system after the operation terminated, but this sometimes would mean wasting resources (mainly computation time). Instead POSIX.1b defines two functions which will help with most kinds of consistency.

The aio_fsync and aio_fsync64 functions are only available if the symbol _POSIX_SYNCHRONIZED_IO is defined in unistd.h Calling this function forces all I/O operations operating queued at the time of the function call operating on the file descriptor aiocbp->aio_fildes into the synchronized I/O completion state . The aio_fsync function returns immediately but the notification through the method described in aiocbp->aio_sigevent will happen only after all requests for this file descriptor have terminated and the file is synchronized. This also means that requests for this very same file descriptor which are queued after the synchronization request are not affected. If op is O_DSYNC the synchronization happens as with a call to fdatasync op should be O_SYNC and the synchronization happens as with fsync As long as the synchronization has not happened, a call to aio_error with the reference to the object pointed to by aiocbp returns EINPROGRESS done aio_error return 0 if the synchronization was not successful. Otherwise the value returned is the value to which the fsync or fdatasync function would have set the errno variable. In this case nothing can be assumed about the consistency for the data written to this file descriptor.

RETURN VALUES
The return value of this function is 0 if the request was successfully enqueued. Otherwise the return value is -1 and errno.

ERRORS

EAGAIN
    The request could not be enqueued due to temporary lack of resources.

EBADF
    The file descriptor aiocbp->aio_fildes is not valid or not open for writing.

EINVAL
    The implementation does not support I/O synchronization or the op parameter is other than O_DSYNC and O_SYNC

ENOSYS
    This function is not implemented.

When the sources are compiled with _FILE_OFFSET_BITS == 64
 this function is in fact aio_return64 since the LFS interface transparently replaces the normal implementation.

SEE ALSO
aio(3), aio_cancel(3), aio_cancel64(3), aio_error(3), aio_error64(3), aio_fsync64(3), aio_init(3), aio_read(3), aio_read64(3), aio_return(3), aio_return64(3), aio_suspend(3), aio_suspend64(3), aio_write(3), aio_write64(3), errno(3),