xref: /386bsd/usr/share/man/cat2/write.0 (revision a2142627)
1WRITE(2)                  386BSD Programmer's Manual                  WRITE(2)
2
3NNAAMMEE
4     wwrriittee, wwrriitteevv - write output
5
6SSYYNNOOPPSSIISS
7     ##iinncclluuddee <<uunniissttdd..hh>>
8     ##iinncclluuddee <<ssyyss//ttyyppeess..hh>>
9     ##iinncclluuddee <<ssyyss//uuiioo..hh>>
10
11     _s_s_i_z_e__t
12     wwrriittee(_i_n_t _d, _c_o_n_s_t _c_h_a_r *_b_u_f, _s_i_z_e__t _n_b_y_t_e_s)
13
14     _i_n_t
15     wwrriitteevv(_i_n_t _d, _s_t_r_u_c_t _i_o_v_e_c *_i_o_v, _i_n_t _i_o_v_c_n_t)
16
17DDEESSCCRRIIPPTTIIOONN
18     WWrriittee() attempts to write _n_b_y_t_e_s of data to the object referenced by the
19     descriptor _d from the buffer pointed to by _b_u_f. WWrriitteevv() performs the
20     same action, but gathers the output data from the _i_o_v_c_n_t buffers
21     specified by the members of the _i_o_v array: iov[0], iov[1], ...,
22     iov[iovcnt-1].
23
24     For wwrriitteevv(), the _i_o_v_e_c structure is defined as:
25           struct iovec {
26                   caddr_t iov_base;
27                   int     iov_len;
28           };
29
30     Each _i_o_v_e_c entry specifies the base address and length of an area in
31     memory from which data should be written.  WWrriitteevv() will always write a
32     complete area before proceeding to the next.
33
34     On objects capable of seeking, the wwrriittee() starts at a position given by
35     the pointer associated with _d, see lseek(2).  Upon return from wwrriittee(),
36     the pointer is incremented by the number of bytes which were written.
37
38     Objects that are not capable of seeking always write from the current
39     position.  The value of the pointer associated with such an object is
40     undefined.
41
42     If the real user is not the super-user, then wwrriittee() clears the set-user-
43     id bit on a file.  This prevents penetration of system security by a user
44     who ``captures'' a writable set-user-id file owned by the super-user.
45
46     When using non-blocking I/O on objects such as sockets that are subject
47     to flow control, wwrriittee() and wwrriitteevv() may write fewer bytes than
48     requested; the return value must be noted, and the remainder of the
49     operation should be retried when possible.
50
51RREETTUURRNN VVAALLUUEESS
52     Upon successful completion the number of bytes which were written is
53     returned.  Otherwise a -1 is returned and the global variable _e_r_r_n_o is
54     set to indicate the error.
55
56EERRRROORRSS
57     WWrriittee() and wwrriitteevv() will fail and the file pointer will remain unchanged
58     if:
59
60     [EBADF]       _D is not a valid descriptor open for writing.
61
62     [EPIPE]       An attempt is made to write to a pipe that is not open for
63                   reading by any process.
64
65     [EPIPE]       An attempt is made to write to a socket of type that is not
66
67                   connected to a peer socket.
68
69     [EFBIG]       An attempt was made to write a file that exceeds the
70                   process's file size limit or the maximum file size.
71
72     [EFAULT]      Part of _i_o_v or data to be written to the file points
73                   outside the process's allocated address space.
74
75     [EINVAL]      The pointer associated with _d was negative.
76
77     [ENOSPC]      There is no free space remaining on the file system
78                   containing the file.
79
80     [EDQUOT]      The user's quota of disk blocks on the file system
81                   containing the file has been exhausted.
82
83     [EIO]         An I/O error occurred while reading from or writing to the
84                   file system.
85
86     [EWOULDBLOCK]
87                   The file was marked for non-blocking I/O, and no data could
88                   be written immediately.
89
90     In addition, wwrriitteevv() may return one of the following errors:
91
92     [EINVAL]      _I_o_v_c_n_t was less than or equal to 0, or greater than 16.
93
94     [EINVAL]      One of the _i_o_v__l_e_n values in the _i_o_v array was negative.
95
96     [EINVAL]      The sum of the _i_o_v__l_e_n values in the _i_o_v array overflowed a
97                   32-bit integer.
98
99SSEEEE AALLSSOO
100     fcntl(2),  lseek(2),  open(2),  pipe(2),  select(2)
101
102SSTTAANNDDAARRDDSS
103     WWrriittee() is expected to conform to IEEE Std 1003.1-1988 (``POSIX'').
104
105HHIISSTTOORRYY
106     The wwrriitteevv() function call appeared in 4.2BSD. A wwrriittee function call
107     appeared in Version 6 AT&T UNIX.
108
1094th Berkeley Distribution       March 10, 1991                               2
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133