Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ lseek(2) — SunOS 4.0.2

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

dup(2)

open(2V)

LSEEK(2)  —  SYSTEM CALLS

NAME

lseek, tell − move read/write pointer

SYNOPSIS

#include <sys/types.h>
#include <sys/file.h>

off_t lseek(des, offset, whence)
int des;
off_t offset;
int whence;

DESCRIPTION

The descriptor des refers to a file or device open for reading and/or writing.  lseek() sets the file pointer associated with des as follows:

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

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

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

Some devices are incapable of seeking.  The value of the pointer associated with such a device is undefined. 

The obsolete function tell(fildes) is identical to lseek(fildes, 0L, L_INCR). 

NOTES

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

RETURN VALUE

Upon successful completion, the resulting pointer location, as measured in bytes from beginning of the file, is returned.  Otherwise, a value of −1 is returned and errno is set to indicate the error. 

ERRORS

lseek() will fail and the file pointer will remain unchanged if:

EBADF des is not an open file descriptor. 

ESPIPE des is associated with a pipe or a socket. 

EINVAL whence is not a proper value. 

SEE ALSO

dup(2), open(2V)

Sun Release 4.0  —  Last change: 21 November 1987

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026