lseek, lseek64 --
move read/write file pointer
off_t lseek(int fildes, off_t offset, int whence);
off64_t lseek64(int fildes, off64_t offset, int whence);
lseek moves a read/write file pointer.
fildes is a file descriptor returned from a
lseek sets the file pointer associated with
If whence is SEEK_SET, the pointer is set to
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.
lseek allows the file pointer to be set beyond the existing data
in the file.
If data is later written at this point, subsequent reads
in the gap between the previous end of data and the newly written data
return bytes of value 0 until data is written into the gap.
On success, lseek and lseek64 return a
non-negative integer indicating the file pointer value.
On failure, lseek and lseek64 return -1,
set errno to identify the error,
and the file pointer remains unchanged.
Some devices are incapable of seeking.
The value of the file pointer associated with such a device
In the following conditions, lseek fails and sets errno to:
The resulting file offset would be a value which cannot be represented
correctly in an object of type off_t.
The file pointer is not moved.
In the following conditions, lseek and lseek64 fail
and set errno to:
is not an open file descriptor.
is associated with a pipe, fifo or socket.
The resulting file pointer would be negative.
fildes is a remote file descriptor accessed using NFS,
the Network File System,
and the resulting file pointer would be negative.
The device for fstype does not support lseek or
Considerations for threads programming
Open file descriptors are a process resource and available to any sibling thread;
if used concurrently, actions by one thread can interfere with
those of a sibling.
For example, the position of the file pointer is maintained per file descriptor,
not per thread.
system calls combine positioning
and I/O in a single operation.
Considerations for Large File Support
lseek64 supports large files, but is otherwise identical
For details on programming for large file capable applications, see
``Large File Support''
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004