write.html 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <html>
  2. <head>
  3. <title>write</title>
  4. <body bgcolor=#ffffff>
  5. <h2 align=center>write</h2>
  6. <h4 align=center>OS/161 Reference Manual</h4>
  7. <h3>Name</h3>
  8. write - write data to 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. write(int <em>fd</em>, const void *<em>buf</em>, size_t <em>nbytes></em>);
  16. <h3>Description</h3>
  17. write writes up to <em>buflen</em> bytes to the file specified by
  18. <em>fd</em>, at the location in the file specified by the current
  19. seek position of the file, taking the data from the space pointed
  20. to by <em>buf</em>. The file must be open for writing.
  21. <p>
  22. The current seek position of the file is advanced by the number of
  23. bytes written.
  24. <p>
  25. Each write (or <A HREF=read.html>read</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 written is returned. This count should be
  30. positive. A return value of 0 means that nothing could be written,
  31. but that no error occurred; this only occurs at end-of-file on
  32. fixed-size objects. On error, write returns -1 and sets
  33. <A HREF=errno.html>errno</A> to a suitable error code for the error
  34. condition encountered.
  35. <p>
  36. Note that in some cases, particularly on devices, fewer than
  37. <em>buflen</em> (but greater than zero) bytes may be written. This
  38. depends on circumstances and does not necessarily signify
  39. end-of-file. In most cases, one should loop to make sure that all
  40. output has actually been written.
  41. <p>
  42. <h3>Errors</h3>
  43. The following error codes should be returned under the conditions
  44. given. Other error codes may be returned for other errors not
  45. mentioned here.
  46. <blockquote><table width=90%>
  47. <td width=10%>&nbsp;</td><td>&nbsp;</td></tr>
  48. <tr><td>EBADF</td> <td><em>fd</em> is not a valid file descriptor, or was
  49. not opened for writing.</td></tr>
  50. <tr><td>EFAULT</td> <td>Part or all of the address space pointed to by
  51. <em>buf</em> is invalid.</td></tr>
  52. <tr><td>ENOSPC</td> <td>There is no free space remaining on the filesystem
  53. containing the file.</td></tr>
  54. <tr><td>EIO</td> <td>A hardware I/O error occurred writing
  55. the data.</td></tr>
  56. </table></blockquote>
  57. </body>
  58. </html>