12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <html>
- <head>
- <title>lseek</title>
- <body bgcolor=#ffffff>
- <h2 align=center>lseek</h2>
- <h4 align=center>OS/161 Reference Manual</h4>
- <h3>Name</h3>
- lseek - change current position in file
- <h3>Library</h3>
- Standard C Library (libc, -lc)
- <h3>Synopsis</h3>
- #include <unistd.h><br>
- <br>
- off_t<br>
- lseek(int <em>fd</em>, off_t <em>pos</em>, int <em>whence</em>);
- <h3>Description</h3>
- lseek alters the current seek position of the file handle
- <em>filehandle</em>, seeking to a new position based on <em>pos</em>
- and <em>whence</em>.
- <p>
- If <em>whence</em> is
- <ul>
- <li> SEEK_SET, the new position is <em>pos</em>.
- <li> SEEK_CUR, the new position is the current position plus <em>pos</em>.
- <li> SEEK_END, the new position is the position of end-of-file
- plus <em>pos</em>.
- <li> anything else, lseek fails.
- </ul>
- Note that <em>pos</em> is a signed quantity.
- <p>
- It is not meaningful to seek on certain objects (such as the console
- device). All seeks on these objects fail.
- <p>
- Seek positions less than zero are invalid. Seek positions beyond EOF
- are legal.
- <p>
- Note that each distinct open of a file should have an independent seek
- pointer.
- <p>
- <h3>Return Values</h3>
- On success, lseek returns the new position. On error, -1 is returned,
- and <A HREF=errno.html>errno</A> is set according to the error
- encountered.
- <h3>Errors</h3>
- The following error codes should be returned under the conditions
- given. Other error codes may be returned for other errors not
- mentioned here.
- <blockquote><table width=90%>
- <td width=10%> </td><td> </td></tr>
- <tr><td>EBADF</td> <td><em>fd</em> is not a valid file handle.</td></tr>
- <tr><td>ESPIPE</td> <td><em>fd</em> refers to an object which does
- not support seeking.</td></tr>
- <tr><td>EINVAL</td> <td><em>whence</em> is invalid.</td></tr>
- <tr><td>EINVAL</td> <td>The resulting seek position would be negative.</td></tr>
- </table></blockquote>
- </body>
- </html>
|