LSEEK(2-SVR4) RISC/os Reference Manual LSEEK(2-SVR4)
NAME
lseek - move read/write file pointer
SYNOPSIS
#include <sys/types.h>
#include <unistd.h>
offt lseek (int fildes, offt offset, int whence);
DESCRIPTION
fildes is a file descriptor returned from a creat, open,
dup, or fcntl system call. lseek sets the file pointer
associated with fildes as follows:
If whence is SEEK_SET, the pointer is set to offset
bytes.
If whence is SEEK_CUR, the pointer is set to its
current location plus offset.
If whence is SEEK_END, the pointer is set to the size
of the file plus offset.
On success, lseek returns the resulting pointer location, as
measured in bytes from the beginning of the file. Note that
if fildes is a remote file descriptor and offset is nega-
tive, lseek returns the file pointer even if it is negative.
lseek allows the file pointer to be set beyond the existing
data in the file. If data are later written at this point,
subsequent reads in the gap between the previous end of data
and the newly written data will return bytes of value 0
until data are written into the gap.
lseek fails and the file pointer remains unchanged if one or
more of the following are true:
EBADF fildes is not an open file descriptor.
ESPIPE fildes is associated with a pipe or fifo.
EINVAL whence is not SEEK_SET, SEEK_CUR, or
SEEK_END. The process also gets a SIGSYS sig-
nal.
EINVAL fildes is not a remote file descriptor, and
the resulting file pointer would be negative.
Some devices are incapable of seeking. The value of the
file pointer associated with such a device is undefined.
Printed 11/19/92 Page 1
LSEEK(2-SVR4) RISC/os Reference Manual LSEEK(2-SVR4)
SEE ALSO
creat(2), dup(2), fcntl(2), open(2).
DIAGNOSTICS
Upon successful completion, a non-negative integer indicat-
ing the file pointer value is returned. Otherwise, a value
of -1 is returned and errno is set to indicate the error.
Page 2 Printed 11/19/92