Moves the read-write file pointer.
Standard C Library (libc.a)
off_t lseek ( FileDescriptor, Offset, Whence)
int FileDescriptor, Whence;
off_t Offset;
offset_t llseek (FileDescriptor, Offset, Whence)
int FileDescriptor, Whence;
offset_t Offset;
off64_t lseek64 (FileDescriptor, Offset, Whence)
int FileDescriptor, Whence;
off64_t Offset;
The lseek, llseek, and lseek64 subroutines set the read-write file pointer for the open file specified by the FileDescriptor parameter. The lseek subroutine limits the Offset to OFF_MAX.
In the large file enabled programming environment, lseek subroutine is redefined to lseek64.
If the FileDescriptor parameter refers to a shared memory object, the lseek subroutine fails with EINVAL.
Item | Description |
---|---|
FileDescriptor | Specifies a file descriptor obtained from a successful open or fcntl subroutine. |
Offset | Specifies a value, in bytes, that is used in conjunction with the Whence parameter to set the file pointer. A negative value causes seeking in the reverse direction. |
Whence | Specifies how to interpret the Offset parameter by setting
the file pointer associated with the FileDescriptor parameter
to one of the following variables:
|
Upon successful completion, the resulting pointer location, measured in bytes from the beginning of the file, is returned. If either the lseek or llseek subroutines are unsuccessful, a value of -1 is returned and the errno global variable is set to indicate the error.
The lseek or llseek subroutines are unsuccessful and the file pointer remains unchanged if any of the following are true:
Item | Description |
---|---|
EBADF | The FileDescriptor parameter is not an open file descriptor. |
EINVAL | The resulting offset would be greater than the maximum offset allowed for the file or device associated with FileDescriptor. The lseek subroutine was used with a file descriptor obtained from a call to the shm_open subroutine. |
EINVAL | Whence is not one of the supported values. |
EOVERFLOW | The resulting offset is larger than can be returned properly. |
ESPIPE | The FileDescriptor parameter is associated with a pipe (FIFO) or a socket. |
Item | Description |
---|---|
/usr/include/unistd.h | Defines standard macros, data types and subroutines. |