manual page distributed with 4.1BSD
[unix-history] / usr / src / lib / libc / sys / lseek.2
CommitLineData
ec7838a8
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
5.\" @(#)lseek.2 4.1 (Berkeley) %G%
6.\"
7.TH LSEEK 2
8.UC 4
9.SH NAME
10lseek, tell \- move read/write pointer
11.SH SYNOPSIS
12.nf
13.B long lseek(fildes, offset, whence)
14.B long offset;
15.PP
16.B long tell(fildes)
17.fi
18.SH DESCRIPTION
19The file
20descriptor refers to a file open for reading or writing.
21The read (resp. write) pointer for the file is set as follows:
22.IP
23If
24.I whence
25is 0, the pointer is set to
26.I offset
27bytes.
28.IP
29If
30.I whence
31is 1, the pointer is set to its current location plus
32.IR offset .
33.IP
34If
35.I whence
36is 2, the pointer is set to the size of the
37file plus
38.IR offset .
39.PP
40The returned value is the resulting pointer location.
41.PP
42The obsolete function
43.IR tell ( fildes )
44is identical to
45.IR lseek ( "fildes, 0L, 1" ).
46.PP
47Seeking far beyond the end of a file, then writing,
48creates a gap or `hole', which occupies no
49physical space and reads as zeros.
50.SH "SEE ALSO"
51open(2), creat(2), fseek(3)
52.SH DIAGNOSTICS
53\-1
54is returned for
55an undefined file descriptor,
56seek on a pipe,
57or seek to a position before the beginning of file.
58.SH BUGS
59.I Lseek
60is a no-op on character special files.
61.SH "ASSEMBLER (PDP-11)"
62(lseek = 19.)
63.br
64(file descriptor in r0)
65.br
66.B sys lseek; offset1; offset2; whence
67.PP
68.I Offset1
69and
70.I offset2
71are the high and low words of
72.IR offset ;
73r0 and r1 contain
74the pointer upon return.