1LSEEK(2)                      System Calls Manual                     LSEEK(2)
2
3
4

NAME

6       lseek - move read/write pointer
7

SYNOPSIS

9       #include <sys/file.h>
10
11       #define L_SET   0 /* set the seek pointer */
12       #define L_INCR  1 /* increment the seek pointer */
13       #define L_XTND  2 /* extend the file size */
14
15       pos = lseek(d, offset, whence)
16       off_t pos;
17       int d;
18       off_t offset;
19       int whence;
20

DESCRIPTION

22       The  descriptor  d  refers  to a file or device open for reading and/or
23       writing.  Lseek sets the file pointer of d as follows:
24
25              If whence is L_SET, the pointer is set to offset bytes.
26
27              If whence is L_INCR, the pointer is set to its current  location
28              plus offset.
29
30              If  whence is L_XTND, the pointer is set to the size of the file
31              plus offset.
32
33       Upon successful completion, the resulting pointer location as  measured
34       in  bytes  from  beginning  of  the file is returned.  Some devices are
35       incapable of seeking.  The value of the pointer associated with such  a
36       device is undefined.
37

NOTES

39       Seeking  far  beyond  the end of a file, then writing, creates a gap or
40       “hole”, which occupies no physical space and reads as zeros.
41

RETURN VALUE

43       Upon successful completion, the current file pointer value is returned.
44       Otherwise,  a  value of -1 is returned and errno is set to indicate the
45       error.
46

ERRORS

48       Lseek will fail and the file pointer will remain unchanged if:
49
50       [EBADF]        Fildes is not an open file descriptor.
51
52       [ESPIPE]       Fildes is associated with a pipe or a socket.
53
54       [EINVAL]       Whence is not a proper value.
55

SEE ALSO

57       dup(2), open(2)
58

BUGS

60       This document's use of whence is incorrect English, but maintained  for
61       historical reasons.
62
63
64
654th Berkeley Distribution      February 24, 1986                      LSEEK(2)
Impressum