Files
oldlinux-files/Minix/2.0.0/wwwman/man2/lseek.2.html
2024-02-19 00:21:39 -05:00

128 lines
2.9 KiB
HTML

<HTML>
<HEAD>
<TITLE>lseek(2)</TITLE>
</HEAD>
<BODY>
<H1>lseek(2)</H1>
<HR>
<PRE>
</PRE>
<H2>NAME</H2><PRE>
lseek - move read/write pointer
</PRE>
<H2>SYNOPSIS</H2><PRE>
<STRONG>#include</STRONG> <STRONG>&lt;sys/types.h&gt;</STRONG>
<STRONG>#include</STRONG> <STRONG>&lt;unistd.h&gt;</STRONG>
<STRONG>#define</STRONG> <STRONG>SEEK_SET</STRONG> <STRONG>0</STRONG> <STRONG>/*</STRONG> <STRONG>offset</STRONG> <STRONG>is</STRONG> <STRONG>absolute</STRONG> <STRONG>*/</STRONG>
<STRONG>#define</STRONG> <STRONG>SEEK_CUR</STRONG> <STRONG>1</STRONG> <STRONG>/*</STRONG> <STRONG>relative</STRONG> <STRONG>to</STRONG> <STRONG>current</STRONG> <STRONG>position</STRONG> <STRONG>*/</STRONG>
<STRONG>#define</STRONG> <STRONG>SEEK_END</STRONG> <STRONG>2</STRONG> <STRONG>/*</STRONG> <STRONG>relative</STRONG> <STRONG>to</STRONG> <STRONG>end</STRONG> <STRONG>of</STRONG> <STRONG>file</STRONG> <STRONG>*/</STRONG>
<STRONG>off_t</STRONG> <STRONG>lseek(int</STRONG> <STRONG>d,</STRONG> <STRONG>off_t</STRONG> <STRONG>offset,</STRONG> <STRONG>int</STRONG> <STRONG>whence)</STRONG>
</PRE>
<H2>DESCRIPTION</H2><PRE>
The descriptor <EM>d</EM> refers to a file or device open for reading and/or
writing. <STRONG>Lseek</STRONG> sets the file pointer of <EM>d</EM> as follows:
If <EM>whence</EM> is SEEK_SET, the pointer is set to <EM>offset</EM> bytes.
If <EM>whence</EM> is SEEK_CUR, the pointer is set to its current location
plus <EM>offset</EM>.
If <EM>whence</EM> is SEEK_END, the pointer is set to the size of the file
plus <EM>offset</EM>.
Upon successful completion, the resulting pointer location as measured in
bytes from beginning of the file is returned. Some devices are incapable
of seeking. The value of the pointer associated with such a device is
undefined.
</PRE>
<H2>NOTES</H2><PRE>
Seeking far beyond the end of a file, then writing, creates a gap or
"hole", which occupies no physical space and reads as zeros.
</PRE>
<H2>RETURN VALUE</H2><PRE>
Upon successful completion, the current file pointer value is returned.
Otherwise, a value of -1 is returned and <STRONG>errno</STRONG> is set to indicate the
error.
</PRE>
<H2>ERRORS</H2><PRE>
<STRONG>Lseek</STRONG> will fail and the file pointer will remain unchanged if:
[EBADF] <EM>Fildes</EM> is not an open file descriptor.
[ESPIPE] <EM>Fildes</EM> is associated with a pipe or a socket.
[EINVAL] <EM>Whence</EM> is not a proper value.
</PRE>
<H2>SEE ALSO</H2><PRE>
<STRONG><A HREF="../man2/fcntl.2.html">fcntl(2)</A></STRONG>, <STRONG><A HREF="../man2/open.2.html">open(2)</A></STRONG>.
</PRE>
<H2>BUGS</H2><PRE>
This document's use of <EM>whence</EM> is incorrect English, but maintained for
historical reasons.
</PRE>
</BODY>
</HTML>