# aio_fsync

## PROLOG



           This manual page is part of the POSIX Programmer's Manual.  The
           Linux implementation of this interface may differ (consult the
           corresponding Linux manual page for details of Linux behavior), or
           the interface may not be implemented on Linux.
    


## NAME



           aio_fsync — asynchronous file synchronization
    


## SYNOPSIS



           #include <aio.h>
    
           int aio_fsync(int _op_ , struct aiocb *_aiocbp_);
    


## DESCRIPTION



           The _aio_fsync_() function shall asynchronously perform a file
           synchronization operation, as specified by the _op_ argument, for
           I/O operations associated with the file indicated by the file
           descriptor _aio_fildes_ member of the **aiocb** structure referenced by
           the _aiocbp_ argument and queued at the time of the call to
           _aio_fsync_().  The function call shall return when the
           synchronization request has been initiated or queued to the file
           or device (even when the data cannot be synchronized immediately).
    
           If _op_ is O_DSYNC, all currently queued I/O operations shall be
           completed as if by a call to _fdatasync_(); that is, as defined for
           synchronized I/O data integrity completion.
    
           If _op_ is O_SYNC, all currently queued I/O operations shall be
           completed as if by a call to _fsync_(); that is, as defined for
           synchronized I/O file integrity completion.  If the _aio_fsync_()
           function fails, or if the operation queued by _aio_fsync_() fails,
           then outstanding I/O operations are not guaranteed to have been
           completed.
    
           If _aio_fsync_() succeeds, then it is only the I/O that was queued
           at the time of the call to _aio_fsync_() that is guaranteed to be
           forced to the relevant completion state. The completion of
           subsequent I/O on the file descriptor is not guaranteed to be
           completed in a synchronized fashion.
    
           The _aiocbp_ argument refers to an asynchronous I/O control block.
           The _aiocbp_ value may be used as an argument to _aio_error_() and
           _aio_return_() in order to determine the error status and return
           status, respectively, of the asynchronous operation while it is
           proceeding. When the request is queued, the error status for the
           operation is **[EINPROGRESS]**.  When all data has been successfully
           transferred, the error status shall be reset to reflect the
           success or failure of the operation. If the operation does not
           complete successfully, the error status for the operation shall be
           set to indicate the error. The _aio_sigevent_ member determines the
           asynchronous notification to occur as specified in _Section 2.4.1_ ,
           _Signal Generation and Delivery_ when all operations have achieved
           synchronized I/O completion. All other members of the structure
           referenced by _aiocbp_ are ignored. If the control block referenced
           by _aiocbp_ becomes an illegal address prior to asynchronous I/O
           completion, then the behavior is undefined.
    
           If the _aio_fsync_() function fails or _aiocbp_ indicates an error
           condition, data is not guaranteed to have been successfully
           transferred.
    


## RETURN VALUE



           The _aio_fsync_() function shall return the value 0 if the I/O
           operation is successfully queued; otherwise, the function shall
           return the value -1 and set _errno_ to indicate the error.
    


## ERRORS



           The _aio_fsync_() function shall fail if:
    
           **EAGAIN** The requested asynchronous operation was not queued due to
                  temporary resource limitations.
    
           **EBADF** The _aio_fildes_ member of the **aiocb** structure referenced by
                  the _aiocbp_ argument is not a valid file descriptor.
    
           **EINVAL** This implementation does not support synchronized I/O for
                  this file.
    
           **EINVAL** The _aio_fildes_ member of the **aiocb** structure refers to a
                  file on which an _fsync_() operation is not possible.
    
           **EINVAL** A value of _op_ other than O_DSYNC or O_SYNC was specified,
                  or O_DSYNC was specified and the implementation does not
                  provide runtime support for the Synchronized Input and
                  Output option, or O_SYNC was specified and the
                  implementation does not provide runtime support for the
                  File Synchronization option.
    
           In the event that any of the queued I/O operations fail,
           _aio_fsync_() shall return the error condition defined for _read_()
           and _write_().  The error is returned in the error status for the
           asynchronous operation, which can be retrieved using _aio_error_().
    
           _The following sections are informative._
    


## EXAMPLES



           None.
    


## APPLICATION USAGE



           Note that even if the file descriptor is not open for writing, if
           there are any pending write requests on the underlying file, then
           that I/O will be completed prior to the return of a call to
           _aio_error_() or _aio_return_() indicating that the operation has
           completed.
    


## RATIONALE



           None.
    


## FUTURE DIRECTIONS



           None.
    


* * *