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.8 2002/10/13 17:42:14 schweikh Exp $
34 .\" $DragonFly: src/lib/libc/sys/write.2,v 1.2 2003/06/17 04:26:47 dillon Exp $
51 .Fn write "int d" "const void *buf" "size_t nbytes"
53 .Fn writev "int d" "const struct iovec *iov" "int iovcnt"
55 .Fn pwrite "int d" "const void *buf" "size_t nbytes" "off_t offset"
60 of data to the object referenced by the descriptor
62 from the buffer pointed to by
65 performs the same action, but gathers the output data
68 buffers specified by the members of the
70 array: iov[0], iov[1], ..., iov[iovcnt\|-\|1].
72 performs the same function, but writes to the specified position in
73 the file without modifying the file pointer.
79 structure is defined as:
81 .Bd -literal -offset indent -compact
83 char *iov_base; /* Base address. */
84 size_t iov_len; /* Length. */
90 entry specifies the base address and length of an area
91 in memory from which data should be written.
93 will always write a complete area before proceeding
96 On objects capable of seeking, the
99 given by the pointer associated with
105 the pointer is incremented by the number of bytes which were written.
107 Objects that are not capable of seeking always write from the current
108 position. The value of the pointer associated with such an object
111 If the real user is not the super-user, then
113 clears the set-user-id bit on a file.
114 This prevents penetration of system security
117 a writable set-user-id file
118 owned by the super-user.
120 When using non-blocking I/O on objects such as sockets that are subject
125 may write fewer bytes than requested;
126 the return value must be noted,
127 and the remainder of the operation should be retried when possible.
129 Upon successful completion the number of bytes which were written
130 is returned. Otherwise a -1 is returned and the global variable
132 is set to indicate the error.
138 will fail and the file pointer will remain unchanged if:
142 is not a valid descriptor open for writing.
144 An attempt is made to write to a pipe that is not open
145 for reading by any process.
147 An attempt is made to write to a socket of type
149 that is not connected to a peer socket.
151 An attempt was made to write a file that exceeds the process's
152 file size limit or the maximum file size.
156 or data to be written to the file
157 points outside the process's allocated address space.
159 The pointer associated with
163 There is no free space remaining on the file system
166 The user's quota of disk blocks on the file system
167 containing the file has been exhausted.
169 An I/O error occurred while reading from or writing to the file system.
171 A signal interrupted the write before it could be completed.
173 The file was marked for non-blocking I/O,
174 and no data could be written immediately.
176 An attempt was made to write over a disk label area at the beginning
181 to enable writing on the disk label area.
186 may return one of the following errors:
188 .It Bq Er EDESTADDRREQ
189 The destination is no longer available when writing to a
191 domain datagram socket on which
193 had been used to set a destination address.
196 was less than or equal to 0, or greater than
209 array overflowed a 32-bit integer.
211 The mbuf pool has been completely exhausted when writing to a socket.
216 call may also return the following errors:
219 The specified file offset is invalid.
221 The file descriptor is associated with a pipe, socket, or FIFO.
232 function call is expected to conform to
238 functions are expected to conform to
253 function call appeared in