NAME
aio_fsync() — force outstanding asynchronous operations on a file to the synchronized state
SYNOPSIS
#include <aio.h>
int aio_fsync(int op, struct aiocb *aiocbp);
DESCRIPTION
The
aio_fsync()
function asynchronously forces all I/O operations
that are enqueued at the time of the call
for the file or device referenced by
aiocbp->aio_fildes
to the synchronized I/O state.
The function call
returns when the synchronization request has been enqueued to the
file or device (even when the data cannot be synchronized immediately).
Successful completion of the
aio_fsync()
request indicates that all
modified data for
aiocbp->fildes
has been moved to a permanent storage device.
The
aio_fsync()
function affects only those asynchronous I/O
operations enqueued at the time of the call.
Subsequently enqueued operations are not included
in the synchronizing operation.
The
aio_fsync()
function supports synchronized I/O for regular files,
block special files, and character special files.
If the
op
is
O_DSYNC,
all currently enqueued asynchronous I/O operations for
aiocbp->fildes
are completed as if by a call to
fdatasync().
All data is forced to permanent storage but
the meta-data (such as modification times)
for the file descriptor is not necessarily updated.
If the
op
is
O_SYNC,
all currently enqueued asynchronous I/O operations
for
aiocbp->fildes
are completed as if
by a call to
fsync().
All data is forced to permanent storage
and the file descriptor metadata is updated.
If an
aio_fsync()
request is issued for a file when
there is already a pending
aio_fsync()
request, the first request is treated as though it were
part of the second, and the second request
will not complete until the first has completed.
The
aio_fsync()
function returns when the
fsync
request has been
enqueued for the referenced file or device.
The
aio_error()
and
aio_return()
functions must be used to retrieve the status of
the synchronization operation via the
aiocb
referenced by
aiocbp.
The status returned will be
EINPROGRESS
until the last operation addressed by the
initial request completes.
If all operations complete successfully,
the error status will be 0 (zero).
Otherwise, the error status will be the
error status that will be returned for
the read or write operation that failed.
If
aiocbp->aio_sigevent
is a valid signal event structure,
then the designated signal will be delivered
when the requested synchronization operation completes,
either when all subject requests have completed successfully or
when any one of the requests has failed.
To use this function, link in the realtime library by specifying
-lrt
on the compiler or linker command line.
RETURN VALUE
If the
aio_fsync()
function fails,
-1
is returned and
errno
is set to indicate the error.
ERRORS
If
aio_fsync()
detects one of the following error conditions,
errno
is set to the indicated value:
- [EAGAIN]
The request could not be queued
because a per-process or
system-wide limit on asynchronous I/O operations or asynchronous
threads would have been exceeded.
- [EBADF]
The
aiocbp->aio_fildes
is not a valid file descriptor open for writing.
- [EINVAL]
Synchronized I/O is not supported for the
file specified by
aiocbp->aio_fildes.
- [EINVAL]
The
aiocb->aio_sigevent
is not a valid address in the process virtual address space.
- [EINVAL]
The parameters of the indicated
sigevent
in
aiocb->aio_sigevent
are invalid.
SEE ALSO
aio_cancel(2),
aio_error(2),
aio_read(2),
aio_return(2),
aio_suspend(2),
aio_write(2),
fdatasync(2),
fsync(2),
lio_listio(2),
read(2),
write(2),
aio(5).
STANDARDS CONFORMANCE
aio_fsync(): POSIX Realtime Extensions, IEEE Std 1003.1b