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. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" @(#)write.2 8.5 (Berkeley) 4/2/94
45 .Fn write "int fd" "const void *buf" "size_t nbytes"
47 .Fn pwrite "int fd" "const void *buf" "size_t nbytes" "off_t offset"
50 .Fn writev "int fd" "const struct iovec *iov" "int iovcnt"
52 .Fn pwritev "int fd" "const struct iovec *iov" "int iovcnt" "off_t offset"
59 of data to the object referenced by the descriptor
61 from the buffer pointed to by
66 performs the same action, but gathers the output data
69 buffers specified by the members of the
71 array: iov[0], iov[1], ..., iov[iovcnt\|-\|1].
77 perform the same functions, but write to the specified position in
78 the file without modifying the file pointer.
86 structure is defined as:
88 .Bd -literal -offset indent -compact
90 void *iov_base; /* Base address. */
91 size_t iov_len; /* Length. */
97 entry specifies the base address and length of an area
98 in memory from which data should be written.
102 will always write a complete area before proceeding
105 On objects capable of seeking, the
108 given by the pointer associated with
114 the pointer is incremented by the number of bytes which were written.
116 Objects that are not capable of seeking always write from the current
118 The value of the pointer associated with such an object
121 If the real user is not the super-user, then
123 clears the set-user-id bit on a file.
124 This prevents penetration of system security
127 a writable set-user-id file
128 owned by the super-user.
130 When using non-blocking I/O on objects such as sockets that are subject
135 may write fewer bytes than requested;
136 the return value must be noted,
137 and the remainder of the operation should be retried when possible.
139 Upon successful completion the number of bytes which were written
141 Otherwise a -1 is returned and the global variable
143 is set to indicate the error.
152 will fail and the file pointer will remain unchanged if:
158 is not a valid descriptor open for writing.
160 An attempt is made to write to a pipe that is not open
161 for reading by any process.
163 An attempt is made to write to a socket of type
165 that is not connected to a peer socket.
167 An attempt was made to write a file that exceeds the process's
168 file size limit or the maximum file size.
172 or data to be written to the file
173 points outside the process's allocated address space.
175 The pointer associated with
179 There is no free space remaining on the file system
182 The user's quota of disk blocks on the file system
183 containing the file has been exhausted.
185 An I/O error occurred while reading from or writing to the file system.
187 A signal interrupted the write before it could be completed.
189 The file was marked for non-blocking I/O,
190 and no data could be written immediately.
192 An attempt was made to write over a disk label area at the beginning
197 to enable writing on the disk label area.
206 .Va debug.iosize_max_clamp
209 The backing store for
211 detected corrupted data while reading.
212 (For example, writing a partial filesystem block may require first reading
213 the existing block which may trigger this error.)
220 may return one of the following errors:
222 .It Bq Er EDESTADDRREQ
223 The destination is no longer available when writing to a
225 domain datagram socket on which
227 had been used to set a destination address.
232 was less than or equal to 0, or greater than
243 values is greater than
248 .Va debug.iosize_max_clamp
251 The mbuf pool has been completely exhausted when writing to a socket.
258 system calls may also return the following errors:
265 The file descriptor is associated with a pipe, socket, or FIFO.
276 system call is expected to conform to
282 system calls are expected to conform to
287 system call appeared in
295 system call appeared in