Commit | Line | Data |
---|---|---|
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 | |
10 | lseek, 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 | |
19 | The file | |
20 | descriptor refers to a file open for reading or writing. | |
21 | The read (resp. write) pointer for the file is set as follows: | |
22 | .IP | |
23 | If | |
24 | .I whence | |
25 | is 0, the pointer is set to | |
26 | .I offset | |
27 | bytes. | |
28 | .IP | |
29 | If | |
30 | .I whence | |
31 | is 1, the pointer is set to its current location plus | |
32 | .IR offset . | |
33 | .IP | |
34 | If | |
35 | .I whence | |
36 | is 2, the pointer is set to the size of the | |
37 | file plus | |
38 | .IR offset . | |
39 | .PP | |
40 | The returned value is the resulting pointer location. | |
41 | .PP | |
42 | The obsolete function | |
43 | .IR tell ( fildes ) | |
44 | is identical to | |
45 | .IR lseek ( "fildes, 0L, 1" ). | |
46 | .PP | |
47 | Seeking far beyond the end of a file, then writing, | |
48 | creates a gap or `hole', which occupies no | |
49 | physical space and reads as zeros. | |
50 | .SH "SEE ALSO" | |
51 | open(2), creat(2), fseek(3) | |
52 | .SH DIAGNOSTICS | |
53 | \-1 | |
54 | is returned for | |
55 | an undefined file descriptor, | |
56 | seek on a pipe, | |
57 | or seek to a position before the beginning of file. | |
58 | .SH BUGS | |
59 | .I Lseek | |
60 | is 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 | |
69 | and | |
70 | .I offset2 | |
71 | are the high and low words of | |
72 | .IR offset ; | |
73 | r0 and r1 contain | |
74 | the pointer upon return. |