V7/usr/man/man2/lseek.2
.TH LSEEK 2
.SH NAME
lseek, tell \- move read/write pointer
.SH SYNOPSIS
.B long lseek(fildes, offset, whence)
.br
.B long offset;
.PP
.B long tell(fildes)
.SH DESCRIPTION
The file
descriptor refers to a file open for reading or writing.
The read (resp. write) pointer for the file is set as follows:
.IP
If
.I whence
is 0, the pointer is set to
.I offset
bytes.
.IP
If
.I whence
is 1, the pointer is set to its current location plus
.IR offset .
.IP
If
.I whence
is 2, the pointer is set to the size of the
file plus
.IR offset .
.PP
The returned value is the resulting pointer location.
.PP
The obsolete function
.IR tell ( fildes )
is identical to
.IR lseek ( "fildes, 0L, 1" ).
.PP
Seeking far beyond the end of a file, then writing,
creates a gap or `hole', which occupies no
physical space and reads as zeros.
.SH "SEE ALSO"
open(2), creat(2), fseek(3)
.SH DIAGNOSTICS
\-1
is returned for
an undefined file descriptor,
seek on a pipe,
or seek to a position before the beginning of file.
.SH BUGS
.I Lseek
is a no-op on character special files.
.SH ASSEMBLER
(lseek = 19.)
.br
(file descriptor in r0)
.br
.B sys lseek; offset1; offset2; whence
.PP
.I Offset1
and
.I offset2
are the high and low words of
.IR offset ;
r0 and r1 contain
the pointer upon return.