aio_fsync(2)aio_fsync(2)NAMEaio_fsync() - force outstanding asynchronous operations on a file to
the synchronized state
The function asynchronously forces all I/O operations that are enqueued
at the time of the call for the file or device referenced by to the
synchronized I/O state. The function call returns when the synchro‐
nization request has been enqueued to the file or device (even when the
data cannot be synchronized immediately).
Successful completion of the request indicates that all modified data
for has been moved to a permanent storage device. The function affects
only those asynchronous I/O operations enqueued at the time of the
call. Subsequently enqueued operations are not included in the syn‐
The function supports synchronized I/O for regular files, block special
files, and character special files.
If the is all currently enqueued asynchronous I/O operations for are
completed as if by a call to 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 is all currently enqueued asynchro‐
nous I/O operations for are completed as if by a call to All data is
forced to permanent storage and the file descriptor metadata is
If an request is issued for a file when there is already a pending
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
The function returns when the fsync request has been enqueued for the
referenced file or device. The and functions must be used to retrieve
the status of the synchronization operation via the referenced by The
status returned will be until the last operation addressed by the ini‐
tial 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
If 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 on the
compiler or linker command line.
If the function fails, is returned and is set to indicate the error.
If detects one of the following error conditions, is set to the indi‐
[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
[EBADF] The is not a valid file descriptor open for writ‐
[EINVAL] Synchronized I/O is not supported for the file
[EINVAL] The is not a valid address in the process virtual
[EINVAL] The parameters of the indicated in are invalid.
SEE ALSOaio_cancel(2), aio_error(2), aio_read(2), aio_return(2), aio_sus‐
pend(2), aio_write(2), fdatasync(2), fsync(2), lio_listio(2), read(2),