1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
|
.TH aio_write 3 2002-09-12 "Linux 2.4" Linux AIO"
.SH NAME
aio_write \- Initiate an asynchronous write operation
.SH SYNOPSYS
.nf
.B #include <errno.h>
.sp
.br
.B #include <aio.h>
.sp
.br
.BI "int aio_write (struct aiocb * aiocbp);"
.fi
.SH DESCRIPTION
This function initiates an asynchronous write operation. The function
call immediately returns after the operation was enqueued or if before
this happens an error was encountered.
The first
.IR "aiocbp->aio_nbytes"
bytes from the buffer starting at
.IR "aiocbp->aio_buf"
are written to the file for which
.IR "aiocbp->aio_fildes"
is an descriptor, starting at the absolute
position
.IR "aiocbp->aio_offset"
in the file.
If prioritized I/O is supported by the platform, the
.IR "aiocbp->aio_reqprio "
value is used to adjust the priority before
the request is actually enqueued.
The calling process is notified about the termination of the read
request according to the
.IR "aiocbp->aio_sigevent"
value.
When
.IR "aio_write"
returns, the return value is zero if no error
occurred that can be found before the process is enqueued. If such an
early error is found the function returns
.IR -1
and sets
.IR "errno"
to one of the following values.
.TP
.B EAGAIN
The request was not enqueued due to (temporarily) exceeded resource
limitations.
.TP
.B ENOSYS
The
.IR "aio_write"
function is not implemented.
.TP
.B EBADF
The
.IR "aiocbp->aio_fildes"
descriptor is not valid. This condition
may not be recognized before enqueueing the request, and so this error
might also be signaled asynchronously.
.TP
.B EINVAL
The
.IR "aiocbp->aio_offset"
or
.IR "aiocbp->aio_reqprio"
value is
invalid. This condition may not be recognized before enqueueing the
request and so this error might also be signaled asynchronously.
.PP
In the case
.IR "aio_write"
returns zero, the current status of the
request can be queried using
.IR "aio_error"
and
.IR "aio_return"
functions. As long as the value returned by
.IR "aio_error"
is
.IR "EINPROGRESS"
the operation has not yet completed. If
.IR "aio_error"
returns zero, the operation successfully terminated,
otherwise the value is to be interpreted as an error code. If the
function terminated, the result of the operation can be get using a call
to
.IR "aio_return"
. The returned value is the same as an equivalent
call to
.IR "read"
would have returned. Possible error codes returned
by
.IR "aio_error"
are:
.TP
.B EBADF
The
.IR "aiocbp->aio_fildes"
descriptor is not valid.
.TP
.B ECANCELED
The operation was canceled before the operation was finished.
.TP
.B EINVAL
The
.IR "aiocbp->aio_offset"
value is invalid.
.PP
When the sources are compiled with
.IR "_FILE_OFFSET_BITS == 64"
, this
function is in fact
.IR "aio_write64"
since the LFS interface transparently
replaces the normal implementation.
.SH "RETURN VALUES"
When
.IR "aio_write"
returns, the return value is zero if no error
occurred that can be found before the process is enqueued. If such an
early error is found the function returns
.IR -1
and sets
.IR "errno"
to one of the following values.
.SH ERRORS
.TP
.B EAGAIN
The request was not enqueued due to (temporarily) exceeded resource
limitations.
.TP
.B ENOSYS
The
.IR "aio_write"
function is not implemented.
.TP
.B EBADF
The
.IR "aiocbp->aio_fildes"
descriptor is not valid. This condition
may not be recognized before enqueueing the request, and so this error
might also be signaled asynchronously.
.TP
.B EINVAL
The
.IR "aiocbp->aio_offset"
or
.IR "aiocbp->aio_reqprio"
value is
invalid. This condition may not be recognized before enqueueing the
request and so this error might also be signaled asynchronously.
.SH "SEE ALSO"
.BR aio(3),
.BR aio_cancel(3),
.BR aio_cancel64(3),
.BR aio_error(3),
.BR aio_error64(3),
.BR aio_fsync(3),
.BR aio_fsync64(3),
.BR aio_init(3),
.BR aio_read(3),
.BR aio_read64(3),
.BR aio_return(3),
.BR aio_return64(3),
.BR aio_suspend(3),
.BR aio_suspend64(3),
.BR aio_write64(3),
.BR errno(3),
|