]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/aio_write.3
aio_cancel.3, aio_error.3, aio_fsync.3, aio_read.3, aio_return.3, aio_suspend.3,...
[thirdparty/man-pages.git] / man3 / aio_write.3
1 .\" Copyright (c) 2003 Andries Brouwer (aeb@cwi.nl)
2 .\"
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
7 .\"
8 .\" The GNU General Public License's references to "object code"
9 .\" and "executables" are to be interpreted as the output of any
10 .\" document formatting or typesetting system, including
11 .\" intermediate and printed output.
12 .\"
13 .\" This manual is distributed in the hope that it will be useful,
14 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
15 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 .\" GNU General Public License for more details.
17 .\"
18 .\" You should have received a copy of the GNU General Public
19 .\" License along with this manual; if not, write to the Free
20 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
21 .\" USA.
22 .\"
23 .TH AIO_WRITE 3 2010-10-02 "" "Linux Programmer's Manual"
24 .SH NAME
25 aio_write \- asynchronous write
26 .SH SYNOPSIS
27 .B "#include <aio.h>"
28 .sp
29 .BI "int aio_write(struct aiocb *" aiocbp );
30 .sp
31 Link with \fI\-lrt\fP.
32 .SH DESCRIPTION
33 The
34 .BR aio_write ()
35 function requests an asynchronous "n = write(fd, buf, count)"
36 with fd, buf, count given by
37 .IR aiocbp\->aio_fildes ,
38 .IR aiocbp\->aio_buf ,
39 .IR aiocbp\->aio_nbytes ,
40 respectively.
41 The return status n can be retrieved upon completion using
42 .BR aio_return (3).
43 (See
44 .BR aio (7)
45 for a description of the
46 .I aiocb
47 structure.)
48 .LP
49 If
50 .B O_APPEND
51 is not set, the data is written starting at the
52 absolute file offset
53 .IR aiocbp\->aio_offset ,
54 regardless of the current file position.
55 If
56 .B O_APPEND
57 is set, the data is written at the end of the file.
58 After this request, the value of the current file position is unspecified.
59 .LP
60 The "asynchronous" means that this call returns as soon as the
61 request has been enqueued; the write may or may not have completed
62 when the call returns.
63 One tests for completion using
64 .BR aio_error (3).
65 .LP
66 If
67 .B _POSIX_PRIORITIZED_IO
68 is defined, and this file supports it,
69 then the asynchronous operation is submitted at a priority equal
70 to that of the calling process minus
71 .IR aiocbp\->aio_reqprio .
72 .LP
73 The field
74 .I aiocbp\->aio_lio_opcode
75 is ignored.
76 .LP
77 No data is written to a regular file beyond its maximum offset.
78 .SH "RETURN VALUE"
79 On success, 0 is returned.
80 On error the request is not enqueued, \-1
81 is returned, and
82 .I errno
83 is set appropriately.
84 If an error is first detected later, it will
85 be reported via
86 .BR aio_return (3)
87 (returns status \-1) and
88 .BR aio_error (3)
89 (error status whatever one would have gotten in
90 .IR errno ,
91 such as
92 .BR EBADF ).
93 .SH ERRORS
94 .TP
95 .B EAGAIN
96 Out of resources.
97 .TP
98 .B EBADF
99 .I aio_fildes
100 is not a valid file descriptor open for writing.
101 .TP
102 .B EFBIG
103 The file is a regular file, we want to write at least one byte,
104 but the starting position is at or beyond the maximum offset for this file.
105 .TP
106 .B EINVAL
107 One or more of
108 .IR aio_offset ,
109 .IR aio_reqprio ,
110 .I aio_nbytes
111 are invalid.
112 .TP
113 .B ENOSYS
114 This function is not supported.
115 .SH VERSIONS
116 The
117 .BR aio_write ()
118 function is available since glibc 2.1.
119 .SH "CONFORMING TO"
120 POSIX.1-2001, POSIX.1-2008.
121 .SH NOTES
122 It is a good idea to zero out the control block before use.
123 This control block must not be changed while the write operation
124 is in progress.
125 The buffer area being written out
126 .\" or the control block of the operation
127 must not be accessed during the operation or undefined results may
128 occur.
129 The memory areas involved must remain valid.
130 .SH "SEE ALSO"
131 .BR aio_cancel (3),
132 .BR aio_error (3),
133 .BR aio_fsync (3),
134 .BR aio_read (3),
135 .BR aio_return (3),
136 .BR aio_suspend (3),
137 .BR aio (7)