]>
Commit | Line | Data |
---|---|---|
a1eaacb1 | 1 | '\" t |
fea681da MK |
2 | .\" Copyright (c) 2003 Andries Brouwer (aeb@cwi.nl) |
3 | .\" | |
e4a74ca8 | 4 | .\" SPDX-License-Identifier: GPL-2.0-or-later |
fea681da | 5 | .\" |
4c1c5274 | 6 | .TH aio_write 3 (date) "Linux man-pages (unreleased)" |
fea681da MK |
7 | .SH NAME |
8 | aio_write \- asynchronous write | |
a42212d0 AC |
9 | .SH LIBRARY |
10 | Real-time library | |
8fc3b2cf | 11 | .RI ( librt ", " \-lrt ) |
fea681da | 12 | .SH SYNOPSIS |
c7db92b9 | 13 | .nf |
fea681da | 14 | .B "#include <aio.h>" |
68e4db0a | 15 | .PP |
fea681da | 16 | .BI "int aio_write(struct aiocb *" aiocbp ); |
c7db92b9 | 17 | .fi |
fea681da MK |
18 | .SH DESCRIPTION |
19 | The | |
e511ffb6 | 20 | .BR aio_write () |
c8cedd7e | 21 | function queues the I/O request described by the buffer pointed to by |
c0a2871b | 22 | .IR aiocbp . |
c8cedd7e MK |
23 | This function is the asynchronous analog of |
24 | .BR write (2). | |
25 | The arguments of the call | |
847e0d88 | 26 | .PP |
1ae6b2c7 AC |
27 | .in +4n |
28 | .EX | |
29 | write(fd, buf, count) | |
30 | .EE | |
31 | .in | |
847e0d88 | 32 | .PP |
c8cedd7e MK |
33 | correspond (in order) to the fields |
34 | .IR aio_fildes , | |
35 | .IR aio_buf , | |
36 | and | |
1ae6b2c7 | 37 | .I aio_nbytes |
c8cedd7e MK |
38 | of the structure pointed to by |
39 | .IR aiocbp . | |
2b014d76 MK |
40 | (See |
41 | .BR aio (7) | |
42 | for a description of the | |
43 | .I aiocb | |
44 | structure.) | |
dd3568a1 | 45 | .PP |
1274071a MK |
46 | If |
47 | .B O_APPEND | |
48 | is not set, the data is written starting at the | |
c72249c5 | 49 | absolute position |
94e9d9fe | 50 | .IR aiocbp\->aio_offset , |
c72249c5 | 51 | regardless of the file offset. |
1274071a MK |
52 | If |
53 | .B O_APPEND | |
c8cedd7e MK |
54 | is set, data is written at the end of the file in the same order as |
55 | .BR aio_write () | |
56 | calls are made. | |
c72249c5 | 57 | After the call, the value of the file offset is unspecified. |
dd3568a1 | 58 | .PP |
fea681da MK |
59 | The "asynchronous" means that this call returns as soon as the |
60 | request has been enqueued; the write may or may not have completed | |
c13182ef MK |
61 | when the call returns. |
62 | One tests for completion using | |
fea681da | 63 | .BR aio_error (3). |
c8cedd7e MK |
64 | The return status of a completed I/O operation can be obtained |
65 | .BR aio_return (3). | |
2c1c3c95 | 66 | Asynchronous notification of I/O completion can be obtained by setting |
1ae6b2c7 | 67 | .I aiocbp\->aio_sigevent |
2c1c3c95 MK |
68 | appropriately; see |
69 | .BR sigevent (7) | |
70 | for details. | |
dd3568a1 | 71 | .PP |
2f0af33b MK |
72 | If |
73 | .B _POSIX_PRIORITIZED_IO | |
74 | is defined, and this file supports it, | |
fea681da MK |
75 | then the asynchronous operation is submitted at a priority equal |
76 | to that of the calling process minus | |
94e9d9fe | 77 | .IR aiocbp\->aio_reqprio . |
dd3568a1 | 78 | .PP |
fea681da | 79 | The field |
94e9d9fe | 80 | .I aiocbp\->aio_lio_opcode |
fea681da | 81 | is ignored. |
dd3568a1 | 82 | .PP |
fea681da | 83 | No data is written to a regular file beyond its maximum offset. |
47297adb | 84 | .SH RETURN VALUE |
c13182ef | 85 | On success, 0 is returned. |
dec985f9 | 86 | On error, the request is not enqueued, \-1 |
fea681da MK |
87 | is returned, and |
88 | .I errno | |
f6a4078b | 89 | is set to indicate the error. |
33a0ccb2 | 90 | If an error is detected only later, it will |
fea681da MK |
91 | be reported via |
92 | .BR aio_return (3) | |
93 | (returns status \-1) and | |
94 | .BR aio_error (3) | |
36546c38 | 95 | (error status\[em]whatever one would have gotten in |
fea681da | 96 | .IR errno , |
2f0af33b MK |
97 | such as |
98 | .BR EBADF ). | |
fea681da MK |
99 | .SH ERRORS |
100 | .TP | |
101 | .B EAGAIN | |
102 | Out of resources. | |
103 | .TP | |
104 | .B EBADF | |
105 | .I aio_fildes | |
106 | is not a valid file descriptor open for writing. | |
107 | .TP | |
108 | .B EFBIG | |
109 | The file is a regular file, we want to write at least one byte, | |
110 | but the starting position is at or beyond the maximum offset for this file. | |
111 | .TP | |
112 | .B EINVAL | |
113 | One or more of | |
114 | .IR aio_offset , | |
115 | .IR aio_reqprio , | |
0daa9e92 | 116 | .I aio_nbytes |
fea681da MK |
117 | are invalid. |
118 | .TP | |
119 | .B ENOSYS | |
aea038d6 MK |
120 | .BR aio_write () |
121 | is not implemented. | |
7eab2fad MS |
122 | .SH ATTRIBUTES |
123 | For an explanation of the terms used in this section, see | |
124 | .BR attributes (7). | |
125 | .TS | |
126 | allbox; | |
c466875e | 127 | lbx lb lb |
7eab2fad MS |
128 | l l l. |
129 | Interface Attribute Value | |
130 | T{ | |
9e54434e BR |
131 | .na |
132 | .nh | |
7eab2fad MS |
133 | .BR aio_write () |
134 | T} Thread safety MT-Safe | |
135 | .TE | |
c466875e | 136 | .sp 1 |
3113c7f3 | 137 | .SH STANDARDS |
4131356c AC |
138 | POSIX.1-2008. |
139 | .SH HISTORY | |
140 | glibc 2.1. | |
141 | POSIX.1-2001. | |
fea681da MK |
142 | .SH NOTES |
143 | It is a good idea to zero out the control block before use. | |
c8cedd7e | 144 | The control block must not be changed while the write operation |
fea681da MK |
145 | is in progress. |
146 | The buffer area being written out | |
147 | .\" or the control block of the operation | |
c8cedd7e | 148 | must not be accessed during the operation or undefined results may occur. |
c13182ef | 149 | The memory areas involved must remain valid. |
847e0d88 | 150 | .PP |
c8cedd7e MK |
151 | Simultaneous I/O operations specifying the same |
152 | .I aiocb | |
153 | structure produce undefined results. | |
47297adb | 154 | .SH SEE ALSO |
fea681da MK |
155 | .BR aio_cancel (3), |
156 | .BR aio_error (3), | |
157 | .BR aio_fsync (3), | |
158 | .BR aio_read (3), | |
159 | .BR aio_return (3), | |
25fa6c3d | 160 | .BR aio_suspend (3), |
cd587df6 | 161 | .BR lio_listio (3), |
25fa6c3d | 162 | .BR aio (7) |