1.\" $NetBSD: aio_fsync.3,v 1.4 2009/03/10 13:23:39 joerg Exp $ 2.\" 3.\" Copyright (c) 2007 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25.\" POSSIBILITY OF SUCH DAMAGE. 26.\" 27.Dd June 17, 2007 28.Dt AIO_FSYNC 3 29.Os 30.Sh NAME 31.Nm aio_fsync 32.Nd asynchronous data synchronization of file (REALTIME) 33.Sh LIBRARY 34.Lb librt 35.Sh SYNOPSIS 36.In aio.h 37.Ft int 38.Fn aio_fsync "int op" "struct aiocb *aiocbp" 39.Sh DESCRIPTION 40The 41.Fn aio_fsync 42system call allows the calling process to force all modified data 43associated with the file descriptor 44.Fa aiocbp-\*[Gt]aio_fildes 45to be flushed to the stable storage device. 46The call returns immediately after the synchronization request has been 47enqueued to the descriptor; the synchronization may or may not have 48completed at the time the call returns. 49If the request could not be enqueued, generally due to invalid arguments, 50the call returns without having enqueued the request. 51.Pp 52The 53.Fa op 54argument could be set only to 55.Dv O_DSYNC 56or 57.Dv O_SYNC . 58If 59.Fa op 60is 61.Dv O_DSYNC , 62then 63.Fn aio_fsync 64does the same as a 65.Fn fdatasync 66call, if 67.Dv O_SYNC , 68then the same as 69.Fn fsync . 70.Pp 71If 72.Dv _POSIX_PRIORITIZED_IO 73is defined, and the descriptor supports it, then the enqueued 74operation is submitted at a priority equal to that of the calling 75process minus 76.Fa aiocbp-\*[Gt]aio_reqprio . 77.Pp 78The 79.Fa aiocbp 80pointer may be subsequently used as an argument to 81.Fn aio_return 82and 83.Fn aio_error 84in order to determine return or error status for the enqueued operation 85while it is in progress. 86.Sh RESTRICTIONS 87The asynchronous I/O control buffer 88.Fa aiocbp 89should be zeroed before the 90.Fn aio_fsync 91system call to avoid passing bogus context information to the kernel. 92.Pp 93Modifications of the Asynchronous I/O Control Block structure after 94the request has been enqueued, but before the request has completed, 95are not allowed. 96.Sh RETURN VALUES 97.Rv -std aio_fsync 98.Sh ERRORS 99The 100.Fn aio_fsync 101system call will fail if: 102.Bl -tag -width Er 103.It Bq Er EAGAIN 104The request was not queued because of system resource limitations. 105.El 106.Pp 107The following conditions may be synchronously detected when the 108.Fn aio_fsync 109system call is made, or asynchronously, at any time thereafter. 110If they are detected at call time, 111.Fn aio_fsync 112returns \-1 and sets 113.Va errno 114appropriately; otherwise the 115.Fn aio_return 116system call must be called, and will return \-1, and 117.Fn aio_error 118must be called to determine the actual value that would have been 119returned in 120.Va errno . 121.Bl -tag -width Er 122.It Bq Er EBADF 123The 124.Fa aiocbp-\*[Gt]aio_fildes 125is invalid for writing. 126.It Bq Er EINVAL 127This implementation does not support synchronized I/O for this file. 128.It Bq Er EINVAL 129The 130.Fa op 131argument is neither set to 132.Dv O_DSYNC 133nor 134.Dv O_SYNC . 135.El 136.Sh SEE ALSO 137.Xr fcntl 2 , 138.Xr fdatasync 2 , 139.Xr fsync 2 , 140.Xr aio_error 3 , 141.Xr aio_read 3 , 142.Xr aio_write 3 143.Sh STANDARDS 144The 145.Fn aio_fsync 146system call is expected to conform to the 147.St -p1003.1-2001 148standard. 149.Sh HISTORY 150The 151.Fn aio_fsync 152system call first appeared in 153.Nx 5.0 . 154