SEEK(2)

NAME
seek, tell, lseek, llseek - manipulate read/write pointer

SYNOPSIS
int seek(fildes, offset, whence)
long offset

long tell(fildes)

long lseek(fildes, offset, whence) long offset;

Long llseek(fildes, offset, whence)
Long offset;

DESCRIPTION
Seek sets the file pointer for the file associated with fildes as follows:

    If whence is 0, the pointer is set to offset bytes.

    If whence is 1, the pointer is set to its current location plus offset.

    If whence is 2, the pointer is set to the size of the file plus offset.

Tell returns the value of the file pointer associated with fildes.

Lseek is equivalent to seek followed by tell.

Llseek is like lseek, but handles i.e. 64-bit, file pointers.

Seeking far beyond the end of a file, then writing, creates a gap or `hole,' which occupies no physical space and reads as zeros.

File pointers have security labels separate from files. For security-label calculations, seek is understood to `write' the pointer, tell to `read' it. If whence is 0 on seek, the new value of the file pointer does not depend on the old value.

SEE ALSO
open(2), fseek(3)

DIAGNOSTICS
EBADF, ESPIPE

BUGS
Lseek doesn't affect some special files.