lseek.html 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <html>
  2. <head>
  3. <title>lseek</title>
  4. <body bgcolor=#ffffff>
  5. <h2 align=center>lseek</h2>
  6. <h4 align=center>OS/161 Reference Manual</h4>
  7. <h3>Name</h3>
  8. lseek - change current position in 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. off_t<br>
  15. lseek(int <em>fd</em>, off_t <em>pos</em>, int <em>whence</em>);
  16. <h3>Description</h3>
  17. lseek alters the current seek position of the file handle
  18. <em>filehandle</em>, seeking to a new position based on <em>pos</em>
  19. and <em>whence</em>.
  20. <p>
  21. If <em>whence</em> is
  22. <ul>
  23. <li> SEEK_SET, the new position is <em>pos</em>.
  24. <li> SEEK_CUR, the new position is the current position plus <em>pos</em>.
  25. <li> SEEK_END, the new position is the position of end-of-file
  26. plus <em>pos</em>.
  27. <li> anything else, lseek fails.
  28. </ul>
  29. Note that <em>pos</em> is a signed quantity.
  30. <p>
  31. It is not meaningful to seek on certain objects (such as the console
  32. device). All seeks on these objects fail.
  33. <p>
  34. Seek positions less than zero are invalid. Seek positions beyond EOF
  35. are legal.
  36. <p>
  37. Note that each distinct open of a file should have an independent seek
  38. pointer.
  39. <p>
  40. <h3>Return Values</h3>
  41. On success, lseek returns the new position. On error, -1 is returned,
  42. and <A HREF=errno.html>errno</A> is set according to the error
  43. encountered.
  44. <h3>Errors</h3>
  45. The following error codes should be returned under the conditions
  46. given. Other error codes may be returned for other errors not
  47. mentioned here.
  48. <blockquote><table width=90%>
  49. <td width=10%>&nbsp;</td><td>&nbsp;</td></tr>
  50. <tr><td>EBADF</td> <td><em>fd</em> is not a valid file handle.</td></tr>
  51. <tr><td>ESPIPE</td> <td><em>fd</em> refers to an object which does
  52. not support seeking.</td></tr>
  53. <tr><td>EINVAL</td> <td><em>whence</em> is invalid.</td></tr>
  54. <tr><td>EINVAL</td> <td>The resulting seek position would be negative.</td></tr>
  55. </table></blockquote>
  56. </body>
  57. </html>