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.
5 .\" @(#)lseek.2 6.3 (Berkeley) 2/24/86
7 .TH LSEEK 2 "February 24, 1986"
10 lseek \- move read/write pointer
14 #include <sys/types.h>
18 #define SEEK_SET 0 /* offset is absolute */
19 #define SEEK_CUR 1 /* relative to current position */
20 #define SEEK_END 2 /* relative to end of file */
22 off_t lseek(int d, off_t offset, int whence)
28 refers to a file or device open for reading and/or writing.
30 sets the file pointer of
36 is SEEK_SET, the pointer is set to
42 is SEEK_CUR, the pointer is set to its current location plus
47 is SEEK_END, the pointer is set to the size of the
51 Upon successful completion, the resulting pointer location
52 as measured in bytes from beginning of the file is returned.
53 Some devices are incapable of seeking. The value of the pointer
54 associated with such a device is undefined.
56 Seeking far beyond the end of a file, then writing,
57 creates a gap or \*(lqhole\*(rq, which occupies no
58 physical space and reads as zeros.
60 Upon successful completion,
61 the current file pointer value is returned.
63 a value of \-1 is returned and \fBerrno\fP is set to indicate
67 will fail and the file pointer will remain unchanged if:
71 is not an open file descriptor.
75 is associated with a pipe or a socket.
79 is not a proper value.
84 This document's use of
86 is incorrect English, but maintained for historical reasons.