OSDN Git Service

b4e4e722ebd991acadc8cde4cde421839cf0c334
[linuxjm/LDP_man-pages.git] / original / man3 / aio_write.3
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 2012-05-08  "" "Linux Programmer's Manual"
25 .SH NAME
26 aio_write \- asynchronous write
27 .SH SYNOPSIS
28 .B "#include <aio.h>"
29 .sp
30 .BI "int aio_write(struct aiocb *" aiocbp );
31 .sp
32 Link with \fI\-lrt\fP.
33 .SH DESCRIPTION
34 The
35 .BR aio_write ()
36 function queues the I/O request described by the buffer pointed to by
37 .IR aiocbp .
38 This function is the asynchronous analog of
39 .BR write (2).
40 The arguments of the call
41
42     write(fd, buf, count)
43
44 correspond (in order) to the fields
45 .IR aio_fildes ,
46 .IR aio_buf ,
47 and
48 .IR aio_nbytes
49 of the structure pointed to by
50 .IR aiocbp .
51 (See
52 .BR aio (7)
53 for a description of the
54 .I aiocb
55 structure.)
56 .LP
57 If
58 .B O_APPEND
59 is not set, the data is written starting at the
60 absolute file offset
61 .IR aiocbp\->aio_offset ,
62 regardless of the current file offset.
63 If
64 .B O_APPEND
65 is set, data is written at the end of the file in the same order as
66 .BR aio_write ()
67 calls are made.
68 After the call, the value of the current file offset is unspecified.
69 .LP
70 The "asynchronous" means that this call returns as soon as the
71 request has been enqueued; the write may or may not have completed
72 when the call returns.
73 One tests for completion using
74 .BR aio_error (3).
75 The return status of a completed I/O operation can be obtained
76 .BR aio_return (3).
77 Asynchronous notification of I/O completion can be obtained by setting
78 .IR aiocbp\->aio_sigevent
79 appropriately; see
80 .BR sigevent (7)
81 for details.
82 .LP
83 If
84 .B _POSIX_PRIORITIZED_IO
85 is defined, and this file supports it,
86 then the asynchronous operation is submitted at a priority equal
87 to that of the calling process minus
88 .IR aiocbp\->aio_reqprio .
89 .LP
90 The field
91 .I aiocbp\->aio_lio_opcode
92 is ignored.
93 .LP
94 No data is written to a regular file beyond its maximum offset.
95 .SH RETURN VALUE
96 On success, 0 is returned.
97 On error, the request is not enqueued, \-1
98 is returned, and
99 .I errno
100 is set appropriately.
101 If an error is detected only later, it will
102 be reported via
103 .BR aio_return (3)
104 (returns status \-1) and
105 .BR aio_error (3)
106 (error status\(emwhatever one would have gotten in
107 .IR errno ,
108 such as
109 .BR EBADF ).
110 .SH ERRORS
111 .TP
112 .B EAGAIN
113 Out of resources.
114 .TP
115 .B EBADF
116 .I aio_fildes
117 is not a valid file descriptor open for writing.
118 .TP
119 .B EFBIG
120 The file is a regular file, we want to write at least one byte,
121 but the starting position is at or beyond the maximum offset for this file.
122 .TP
123 .B EINVAL
124 One or more of
125 .IR aio_offset ,
126 .IR aio_reqprio ,
127 .I aio_nbytes
128 are invalid.
129 .TP
130 .B ENOSYS
131 .BR aio_write ()
132 is not implemented.
133 .SH VERSIONS
134 The
135 .BR aio_write ()
136 function is available since glibc 2.1.
137 .SH CONFORMING TO
138 POSIX.1-2001, POSIX.1-2008.
139 .SH NOTES
140 It is a good idea to zero out the control block before use.
141 The control block must not be changed while the write operation
142 is in progress.
143 The buffer area being written out
144 .\" or the control block of the operation
145 must not be accessed during the operation or undefined results may occur.
146 The memory areas involved must remain valid.
147
148 Simultaneous I/O operations specifying the same
149 .I aiocb
150 structure produce undefined results.
151 .SH SEE ALSO
152 .BR aio_cancel (3),
153 .BR aio_error (3),
154 .BR aio_fsync (3),
155 .BR aio_read (3),
156 .BR aio_return (3),
157 .BR aio_suspend (3),
158 .BR lio_listio (3),
159 .BR aio (7)
160 .SH COLOPHON
161 This page is part of release 3.67 of the Linux
162 .I man-pages
163 project.
164 A description of the project,
165 information about reporting bugs,
166 and the latest version of this page,
167 can be found at
168 \%http://www.kernel.org/doc/man\-pages/.