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
29 .\" $FreeBSD: src/lib/libc/sys/write.2,v 1.12.2.8 2002/10/13 17:42:14 schweikh Exp $
49 .Fn write "int d" "const void *buf" "size_t nbytes"
51 .Fn writev "int d" "const struct iovec *iov" "int iovcnt"
53 .Fn pwrite "int d" "const void *buf" "size_t nbytes" "off_t offset"
55 .Fn pwritev "int d" "const struct iovec *iov" "int iovcnt" "off_t offset"
57 .Fn extpwrite "int d" "const void *buf" "size_t nbytes" "int flags" "off_t offset"
59 .Fn extpwritev "int d" "const struct iovec *iov" "int iovcnt" "int flags" "off_t offset"
64 of data to the object referenced by the descriptor
66 from the buffer pointed to by
71 perform the same action, but gather the output data
74 buffers specified by the members of the
76 array: iov[0], iov[1], ..., iov[iovcnt\|-\|1].
80 perform the same function, but write to the specified position in
81 the file without modifying the file pointer.
89 structure is defined as:
91 .Bd -literal -offset indent -compact
93 char *iov_base; /* Base address. */
94 size_t iov_len; /* Length. */
100 entry specifies the base address and length of an area
101 in memory from which data should be written.
105 will always write a complete area before proceeding
115 to also be passed in, controlling blocking/non-blocking and other features
116 on a call-by-call basis, ignoring the related default for the descriptor.
118 .Bl -tag -width ".Dv O_FNONBLOCKING"
120 Force the system call to operate in a blocking fashion.
121 .It Dv O_FNONBLOCKING
122 Force the system call to operate in a non-blocking fashion.
124 Force append mode for the operation.
126 Force offset mode for the operation.
128 Force the system call to issue the write synchronously.
130 Force the system call to issue the write asynchronously.
133 On objects capable of seeking, the
136 given by the pointer associated with
142 the pointer is incremented by the number of bytes which were written.
144 Objects that are not capable of seeking always write from the current
145 position. The value of the pointer associated with such an object
148 If the real user is not the super-user, then
150 clears the set-user-id bit on a file.
151 This prevents penetration of system security
154 a writable set-user-id file
155 owned by the super-user.
157 When using non-blocking I/O on objects such as sockets that are subject
162 may write fewer bytes than requested;
163 the return value must be noted,
164 and the remainder of the operation should be retried when possible.
166 Upon successful completion the number of bytes which were written
167 is returned. Otherwise a -1 is returned and the global variable
169 is set to indicate the error.
178 will fail and the file pointer will remain unchanged if:
182 is not a valid descriptor open for writing.
184 An attempt is made to write to a pipe that is not open
185 for reading by any process.
187 An attempt is made to write to a socket of type
189 that is not connected to a peer socket.
191 An attempt was made to write a file that exceeds the process's
192 file size limit or the maximum file size.
196 or data to be written to the file
197 points outside the process's allocated address space.
199 The pointer associated with
203 There is no free space remaining on the file system
206 The user's quota of disk blocks on the file system
207 containing the file has been exhausted.
209 An I/O error occurred while reading from or writing to the file system.
211 A signal interrupted the write before it could be completed.
213 The file was marked for non-blocking I/O,
214 and no data could be written immediately.
216 An attempt was made to write over a disk label area at the beginning
221 to enable writing on the disk label area.
229 may return one of the following errors:
231 .It Bq Er EDESTADDRREQ
232 The destination is no longer available when writing to a
234 domain datagram socket on which
236 had been used to set a destination address.
239 was less than or equal to 0, or greater than
252 array overflowed a 32-bit integer.
254 The mbuf pool has been completely exhausted when writing to a socket.
263 calls may also return the following errors:
266 The specified file offset is invalid.
268 The file descriptor is associated with a pipe, socket, or FIFO.
279 function call is expected to conform to
285 functions are expected to conform to
298 function call was added in
312 function call appeared in