logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

writev.3p (4068B)


  1. '\" et
  2. .TH WRITEV "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. writev
  12. \(em write a vector
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <sys/uio.h>
  17. .P
  18. ssize_t writev(int \fIfildes\fP, const struct iovec *\fIiov\fP, int \fIiovcnt\fP);
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. \fIwritev\fR()
  23. function shall be equivalent to
  24. \fIwrite\fR(),
  25. except as described below. The
  26. \fIwritev\fR()
  27. function shall gather output data from the
  28. .IR iovcnt
  29. buffers specified by the members of the
  30. .IR iov
  31. array:
  32. .IR iov [0],
  33. .IR iov [1],
  34. \&.\|.\|., \fIiov\fR[\fIiovcnt\fR\-1].
  35. The
  36. .IR iovcnt
  37. argument is valid if greater than 0 and less than or equal to
  38. {IOV_MAX},
  39. as defined in
  40. .IR <limits.h> .
  41. .P
  42. Each
  43. .IR iovec
  44. entry specifies the base address and length of an area in memory from
  45. which data should be written. The
  46. \fIwritev\fR()
  47. function shall always write a complete area before proceeding to the
  48. next.
  49. .P
  50. If
  51. .IR fildes
  52. refers to a regular file and all of the
  53. .IR iov_len
  54. members in the array pointed to by
  55. .IR iov
  56. are 0,
  57. \fIwritev\fR()
  58. shall return 0 and have no other effect. For other file types, the
  59. behavior is unspecified.
  60. .P
  61. If the sum of the
  62. .IR iov_len
  63. values is greater than
  64. {SSIZE_MAX},
  65. the operation shall fail and no data shall be transferred.
  66. .SH "RETURN VALUE"
  67. Upon successful completion,
  68. \fIwritev\fR()
  69. shall return the number of bytes actually written. Otherwise, it shall
  70. return a value of \-1, the file-pointer shall remain unchanged, and
  71. .IR errno
  72. shall be set to indicate an error.
  73. .SH ERRORS
  74. Refer to
  75. .IR "\fIwrite\fR\^(\|)".
  76. .P
  77. In addition, the
  78. \fIwritev\fR()
  79. function shall fail if:
  80. .TP
  81. .BR EINVAL
  82. The sum of the
  83. .IR iov_len
  84. values in the
  85. .IR iov
  86. array would overflow an
  87. .BR ssize_t .
  88. .P
  89. The
  90. \fIwritev\fR()
  91. function may fail and set
  92. .IR errno
  93. to:
  94. .TP
  95. .BR EINVAL
  96. The
  97. .IR iovcnt
  98. argument was less than or equal to 0, or greater than
  99. {IOV_MAX}.
  100. .LP
  101. .IR "The following sections are informative."
  102. .SH EXAMPLES
  103. .SS "Writing Data from an Array"
  104. .P
  105. The following example writes data from the buffers specified by members
  106. of the
  107. .IR iov
  108. array to the file associated with the file descriptor
  109. .IR fd .
  110. .sp
  111. .RS 4
  112. .nf
  113. #include <sys/types.h>
  114. #include <sys/uio.h>
  115. #include <unistd.h>
  116. \&...
  117. ssize_t bytes_written;
  118. int fd;
  119. char *buf0 = "short string\en";
  120. char *buf1 = "This is a longer string\en";
  121. char *buf2 = "This is the longest string in this example\en";
  122. int iovcnt;
  123. struct iovec iov[3];
  124. .P
  125. iov[0].iov_base = buf0;
  126. iov[0].iov_len = strlen(buf0);
  127. iov[1].iov_base = buf1;
  128. iov[1].iov_len = strlen(buf1);
  129. iov[2].iov_base = buf2;
  130. iov[2].iov_len = strlen(buf2);
  131. \&...
  132. iovcnt = sizeof(iov) / sizeof(struct iovec);
  133. .P
  134. bytes_written = writev(fd, iov, iovcnt);
  135. \&...
  136. .fi
  137. .P
  138. .RE
  139. .SH "APPLICATION USAGE"
  140. None.
  141. .SH RATIONALE
  142. Refer to
  143. .IR "\fIwrite\fR\^(\|)".
  144. .SH "FUTURE DIRECTIONS"
  145. None.
  146. .SH "SEE ALSO"
  147. .IR "\fIreadv\fR\^(\|)",
  148. .IR "\fIwrite\fR\^(\|)"
  149. .P
  150. The Base Definitions volume of POSIX.1\(hy2017,
  151. .IR "\fB<limits.h>\fP",
  152. .IR "\fB<sys_uio.h>\fP"
  153. .\"
  154. .SH COPYRIGHT
  155. Portions of this text are reprinted and reproduced in electronic form
  156. from IEEE Std 1003.1-2017, Standard for Information Technology
  157. -- Portable Operating System Interface (POSIX), The Open Group Base
  158. Specifications Issue 7, 2018 Edition,
  159. Copyright (C) 2018 by the Institute of
  160. Electrical and Electronics Engineers, Inc and The Open Group.
  161. In the event of any discrepancy between this version and the original IEEE and
  162. The Open Group Standard, the original IEEE and The Open Group Standard
  163. is the referee document. The original Standard can be obtained online at
  164. http://www.opengroup.org/unix/online.html .
  165. .PP
  166. Any typographical or formatting errors that appear
  167. in this page are most likely
  168. to have been introduced during the conversion of the source files to
  169. man page format. To report such errors, see
  170. https://www.kernel.org/doc/man-pages/reporting_bugs.html .