1
0

readv 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. .TH READV 2
  2. .SH NAME
  3. readv, writev, preadv, pwritev \- scatter/gather read and write
  4. .SH SYNOPSIS
  5. .B #include <u.h>
  6. .br
  7. .B #include <libc.h>
  8. .PP
  9. .nf
  10. .ft L
  11. typedef
  12. struct IOchunk
  13. {
  14. void *addr;
  15. ulong len;
  16. } IOchunk;
  17. .fi
  18. .PP
  19. .B
  20. long readv(int fd, IOchunk *io, int nio)
  21. .PP
  22. .B
  23. long preadv(int fd, IOchunk *io, int nio, vlong off)
  24. .PP
  25. .B
  26. long writev(int fd, IOchunk *io, int nio)
  27. .PP
  28. .B
  29. long pwritev(int fd, IOchunk *io, int nio, vlong off)
  30. .SH DESCRIPTION
  31. These functions supplement the standard read and write operations of
  32. .IR read (2)
  33. with facilities for scatter/gather I/O.
  34. The set of I/O buffers is collected into an array of
  35. .B IOchunk
  36. structures passed as an argument.
  37. .PP
  38. .I Readv
  39. reads data from
  40. .I fd
  41. and returns the total number of bytes received.
  42. The received data is stored in the successive
  43. .I nio
  44. elements of the
  45. .B IOchunk
  46. array, storing
  47. .IB io [0].len
  48. bytes at
  49. .IB io [0].addr\f1,
  50. the next
  51. .IB io [1].len
  52. at
  53. .IB io [1].addr\f1,
  54. and so on.
  55. .I Preadv
  56. does the same, but implicitly seeks to I/O offset
  57. .I off
  58. by analogy with
  59. .IR readv .
  60. .PP
  61. .I Writev
  62. and
  63. .I pwritev
  64. are the analogous write routines.
  65. .SH SOURCE
  66. .B /sys/src/libc/9sys/readv.c
  67. .br
  68. .B /sys/src/libc/9sys/writev.c
  69. .SH SEE ALSO
  70. .IR intro (2),
  71. .IR read (2)
  72. .SH DIAGNOSTICS
  73. These functions set
  74. .IR errstr .
  75. .SH BUGS
  76. The implementations use
  77. .IR malloc (2)
  78. to build a single buffer for a standard call to
  79. .B read
  80. or
  81. .BR write .
  82. They are placeholders for possible future system calls.