mount_setattr.2: Further tweaks after feedback from Christian Brauner
[man-pages.git] / man3 / aio_write.3
blobc712adc70fc276c50dd0b74640482831b6781234
1 .\" Copyright (c) 2003 Andries Brouwer (aeb@cwi.nl)
2 .\"
3 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
4 .\" This is free documentation; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
8 .\"
9 .\" The GNU General Public License's references to "object code"
10 .\" and "executables" are to be interpreted as the output of any
11 .\" document formatting or typesetting system, including
12 .\" intermediate and printed output.
13 .\"
14 .\" This manual is distributed in the hope that it will be useful,
15 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 .\" GNU General Public License for more details.
18 .\"
19 .\" You should have received a copy of the GNU General Public
20 .\" License along with this manual; if not, see
21 .\" <http://www.gnu.org/licenses/>.
22 .\" %%%LICENSE_END
23 .\"
24 .TH AIO_WRITE 3 2021-03-22  "" "Linux Programmer's Manual"
25 .SH NAME
26 aio_write \- asynchronous write
27 .SH SYNOPSIS
28 .nf
29 .B "#include <aio.h>"
30 .PP
31 .BI "int aio_write(struct aiocb *" aiocbp );
32 .PP
33 Link with \fI\-lrt\fP.
34 .fi
35 .SH DESCRIPTION
36 The
37 .BR aio_write ()
38 function queues the I/O request described by the buffer pointed to by
39 .IR aiocbp .
40 This function is the asynchronous analog of
41 .BR write (2).
42 The arguments of the call
43 .PP
44     write(fd, buf, count)
45 .PP
46 correspond (in order) to the fields
47 .IR aio_fildes ,
48 .IR aio_buf ,
49 and
50 .IR aio_nbytes
51 of the structure pointed to by
52 .IR aiocbp .
53 (See
54 .BR aio (7)
55 for a description of the
56 .I aiocb
57 structure.)
58 .PP
60 .B O_APPEND
61 is not set, the data is written starting at the
62 absolute position
63 .IR aiocbp\->aio_offset ,
64 regardless of the file offset.
66 .B O_APPEND
67 is set, data is written at the end of the file in the same order as
68 .BR aio_write ()
69 calls are made.
70 After the call, the value of the file offset is unspecified.
71 .PP
72 The "asynchronous" means that this call returns as soon as the
73 request has been enqueued; the write may or may not have completed
74 when the call returns.
75 One tests for completion using
76 .BR aio_error (3).
77 The return status of a completed I/O operation can be obtained
78 .BR aio_return (3).
79 Asynchronous notification of I/O completion can be obtained by setting
80 .IR aiocbp\->aio_sigevent
81 appropriately; see
82 .BR sigevent (7)
83 for details.
84 .PP
86 .B _POSIX_PRIORITIZED_IO
87 is defined, and this file supports it,
88 then the asynchronous operation is submitted at a priority equal
89 to that of the calling process minus
90 .IR aiocbp\->aio_reqprio .
91 .PP
92 The field
93 .I aiocbp\->aio_lio_opcode
94 is ignored.
95 .PP
96 No data is written to a regular file beyond its maximum offset.
97 .SH RETURN VALUE
98 On success, 0 is returned.
99 On error, the request is not enqueued, \-1
100 is returned, and
101 .I errno
102 is set to indicate the error.
103 If an error is detected only later, it will
104 be reported via
105 .BR aio_return (3)
106 (returns status \-1) and
107 .BR aio_error (3)
108 (error status\(emwhatever one would have gotten in
109 .IR errno ,
110 such as
111 .BR EBADF ).
112 .SH ERRORS
114 .B EAGAIN
115 Out of resources.
117 .B EBADF
118 .I aio_fildes
119 is not a valid file descriptor open for writing.
121 .B EFBIG
122 The file is a regular file, we want to write at least one byte,
123 but the starting position is at or beyond the maximum offset for this file.
125 .B EINVAL
126 One or more of
127 .IR aio_offset ,
128 .IR aio_reqprio ,
129 .I aio_nbytes
130 are invalid.
132 .B ENOSYS
133 .BR aio_write ()
134 is not implemented.
135 .SH VERSIONS
137 .BR aio_write ()
138 function is available since glibc 2.1.
139 .SH ATTRIBUTES
140 For an explanation of the terms used in this section, see
141 .BR attributes (7).
142 .ad l
145 allbox;
146 lbx lb lb
147 l l l.
148 Interface       Attribute       Value
150 .BR aio_write ()
151 T}      Thread safety   MT-Safe
155 .sp 1
156 .SH CONFORMING TO
157 POSIX.1-2001, POSIX.1-2008.
158 .SH NOTES
159 It is a good idea to zero out the control block before use.
160 The control block must not be changed while the write operation
161 is in progress.
162 The buffer area being written out
163 .\" or the control block of the operation
164 must not be accessed during the operation or undefined results may occur.
165 The memory areas involved must remain valid.
167 Simultaneous I/O operations specifying the same
168 .I aiocb
169 structure produce undefined results.
170 .SH SEE ALSO
171 .BR aio_cancel (3),
172 .BR aio_error (3),
173 .BR aio_fsync (3),
174 .BR aio_read (3),
175 .BR aio_return (3),
176 .BR aio_suspend (3),
177 .BR lio_listio (3),
178 .BR aio (7)