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