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 $
64 .Fa "const struct iovec *iov"
71 of data to the object referenced by the descriptor
73 from the buffer pointed to by
76 performs the same action, but gathers the output data
79 buffers specified by the members of the
81 array: iov[0], iov[1], ..., iov[iovcnt\|-\|1].
83 performs the same function, but writes to the specified position in
84 the file without modifying the file pointer.
90 structure is defined as:
92 .Bd -literal -offset indent -compact
94 char *iov_base; /* Base address. */
95 size_t iov_len; /* Length. */
101 entry specifies the base address and length of an area
102 in memory from which data should be written.
104 will always write a complete area before proceeding
107 On objects capable of seeking, the
110 given by the pointer associated with
116 the pointer is incremented by the number of bytes which were written.
118 Objects that are not capable of seeking always write from the current
119 position. The value of the pointer associated with such an object
122 If the real user is not the super-user, then
124 clears the set-user-id bit on a file.
125 This prevents penetration of system security
128 a writable set-user-id file
129 owned by the super-user.
131 When using non-blocking I/O on objects, such as sockets,
132 that are subject to flow control,
136 may write fewer bytes than requested;
137 the return value must be noted,
138 and the remainder of the operation should be retried when possible.
140 Upon successful completion the number of bytes
141 which were written is returned.
142 Otherwise, a -1 is returned and the global variable
144 is set to indicate the error.
151 system calls will fail and the file pointer will remain unchanged if:
155 The user's quota of disk blocks on the file system
156 containing the file is exhausted.
161 or data to be written to the file
162 points outside the process's allocated address space.
165 The pointer associated with
174 system calls will fail and the file pointer will remain unchanged if:
178 The file is marked for non-blocking I/O,
179 and no data could be written immediately.
183 is not a valid file descriptor open for writing.
186 A write is attempted on a socket that is not connected.
189 An attempt is made to write a file that exceeds the process's
190 file size limit or the maximum file size.
193 The file is a regular file,
196 and the starting position is greater than or equal
197 to the offset maximum established in the open file description
202 A signal interrupts the write before it could be completed.
205 An I/O error occurs while reading from or writing to the file system.
208 A write is attempted on a socket
209 and the local network interface used to reach the destination is down.
211 .It Bq Er ENETUNREACH
212 A write is attempted on a socket and no route to the network is present.
215 There is no free space remaining on the file system containing the file.
218 A request is made of a nonexistent device,
219 or the request is outside the capabilities of the device.
222 An attempt is made to write to a pipe that is not open
223 for reading by any process.
226 An attempt is made to write to a socket of type
228 that is not connected to a peer socket.
235 calls may also return the following errors:
239 See EWOULDBLOCK, below.
241 .It Bq Er EWOULDBLOCK
242 The file descriptor is for a socket, is marked O_NONBLOCK,
243 and write would block.
244 The exact error code depends on the protocol,
245 but EWOULDBLOCK is more common.
250 may return one of the following errors:
253 .It Bq Er EDESTADDRREQ
254 The destination is no longer available when writing to a
256 domain datagram socket on which
260 had been used to set a destination address.
264 is less than or equal to 0, or greater than
279 array overflows a 32-bit integer.
282 The mbuf pool has been completely exhausted when writing to a socket.
287 call may also return the following errors:
291 The specified file offset is invalid.
294 The file descriptor is associated with a pipe, socket, or FIFO.
297 .Fd #include <sys/types.h>
298 .Fd #include <sys/uio.h>
299 .Fd #include <unistd.h>
301 These include files are needed for all three functions.
312 function call is expected to conform to
318 functions are expected to conform to
333 function call appeared in