1 .\" Copyright (c) 1980, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)write.2 8.5 (Berkeley) 4/2/94
33 .\" $FreeBSD: src/lib/libc/sys/write.2,v 1.12.2.7 2001/12/14 18:34:02 ru Exp $
65 .Fa "const struct iovec *iov"
71 .Fa "const struct iovec *iov"
79 of data to the object referenced by the descriptor
81 from the buffer pointed to by
84 performs the same action, but gathers the output data
87 buffers specified by the members of the
89 array: iov[0], iov[1], ..., iov[iovcnt\|-\|1].
93 perform the same functions, but write to the specified position in
94 the file without modifying the file pointer.
102 structure is defined as:
104 .Bd -literal -offset indent -compact
106 char *iov_base; /* Base address. */
107 size_t iov_len; /* Length. */
113 entry specifies the base address and length of an area
114 in memory from which data should be written.
118 will always write a complete area before proceeding
121 On objects capable of seeking, the
124 given by the pointer associated with
130 the pointer is incremented by the number of bytes which were written.
132 Objects that are not capable of seeking always write from the current
133 position. The value of the pointer associated with such an object
136 If the real user is not the super-user, then
138 clears the set-user-id bit on a file.
139 This prevents penetration of system security
142 a writable set-user-id file
143 owned by the super-user.
145 When using non-blocking I/O on objects, such as sockets,
146 that are subject to flow control,
150 may write fewer bytes than requested;
151 the return value must be noted,
152 and the remainder of the operation should be retried when possible.
154 Upon successful completion the number of bytes
155 which were written is returned.
156 Otherwise, a -1 is returned and the global variable
158 is set to indicate the error.
166 system calls will fail and the file pointer will remain unchanged if:
170 The user's quota of disk blocks on the file system
171 containing the file is exhausted.
176 or data to be written to the file
177 points outside the process's allocated address space.
180 The pointer associated with
189 system calls will fail and the file pointer will remain unchanged if:
193 The file is marked for non-blocking I/O,
194 and no data could be written immediately.
198 is not a valid file descriptor open for writing.
201 A write is attempted on a socket that is not connected.
204 An attempt is made to write a file that exceeds the process's
205 file size limit or the maximum file size.
208 The file is a regular file,
211 and the starting position is greater than or equal
212 to the offset maximum established in the open file description
217 A signal interrupts the write before it could be completed.
220 An I/O error occurs while reading from or writing to the file system.
223 A write is attempted on a socket
224 and the local network interface used to reach the destination is down.
226 .It Bq Er ENETUNREACH
227 A write is attempted on a socket and no route to the network is present.
230 There is no free space remaining on the file system containing the file.
233 A request is made of a nonexistent device,
234 or the request is outside the capabilities of the device.
237 An attempt is made to write to a pipe that is not open
238 for reading by any process.
241 An attempt is made to write to a socket of type
243 that is not connected to a peer socket.
250 calls may also return the following errors:
254 See EWOULDBLOCK, below.
256 .It Bq Er EWOULDBLOCK
257 The file descriptor is for a socket, is marked O_NONBLOCK,
258 and write would block.
259 The exact error code depends on the protocol,
260 but EWOULDBLOCK is more common.
265 may return one of the following errors:
268 .It Bq Er EDESTADDRREQ
269 The destination is no longer available when writing to a
271 domain datagram socket on which
275 had been used to set a destination address.
278 The mbuf pool has been completely exhausted when writing to a socket.
285 calls may also return the following errors:
290 is less than or equal to 0, or greater than
305 array overflows a 32-bit integer.
312 calls may also return the following errors:
316 The specified file offset is invalid.
319 The file descriptor is associated with a pipe, socket, or FIFO.
322 .Fd #include <sys/types.h>
323 .Fd #include <sys/uio.h>
324 .Fd #include <unistd.h>
326 These include files are needed for all three functions.
337 function call is expected to conform to
343 functions are expected to conform to
360 function call appeared in