read.html 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <html>
  2. <head>
  3. <title>read</title>
  4. <body bgcolor=#ffffff>
  5. <h2 align=center>read</h2>
  6. <h4 align=center>OS/161 Reference Manual</h4>
  7. <h3>Name</h3>
  8. read - read data from file
  9. <h3>Library</h3>
  10. Standard C Library (libc, -lc)
  11. <h3>Synopsis</h3>
  12. #include &lt;unistd.h&gt;<br>
  13. <br>
  14. int<br>
  15. read(int <em>fd</em>, void *<em>buf</em>, size_t <em>buflen</em>);
  16. <h3>Description</h3>
  17. read reads up to <em>buflen</em> bytes from the file specified by
  18. <em>fd</em>, at the location in the file specified by the current
  19. seek position of the file, and stores them in the space pointed to
  20. by <em>buf</em>. The file must be open for reading.
  21. <p>
  22. The current seek position of the file is advanced by the number of
  23. bytes read.
  24. <p>
  25. Each read (or <A HREF=write.html>write</A>) operation is atomic
  26. relative to other I/O to the same file.
  27. <p>
  28. <h3>Return Values</h3>
  29. The count of bytes read is returned. This count should be
  30. positive. A return value of 0 should be construed as signifying
  31. end-of-file. On error, read returns -1 and sets
  32. <A HREF=errno.html>errno</A> to a suitable error code for the error
  33. condition encountered.
  34. <p>
  35. Note that in some cases, particularly on devices, fewer than
  36. <em>buflen</em> (but greater than zero) bytes may be returned. This
  37. depends on circumstances and does not necessarily signify
  38. end-of-file.
  39. <p>
  40. <h3>Errors</h3>
  41. The following error codes should be returned under the conditions
  42. given. Other error codes may be returned for other errors not
  43. mentioned here.
  44. <blockquote><table width=90%>
  45. <td width=10%>&nbsp;</td><td>&nbsp;</td></tr>
  46. <tr><td>EBADF</td> <td><em>fd</em> is not a valid file descriptor, or was
  47. not opened for reading.</td></tr>
  48. <tr><td>EFAULT</td> <td>Part or all of the address space pointed to by
  49. <em>buf</em> is invalid.</td></tr>
  50. <tr><td>EIO</td> <td>A hardware I/O error occurred reading the data.</td></tr>
  51. </table></blockquote>
  52. </body>
  53. </html>