Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ lseek(3spp) — UMIPS/BSD System Programmer's Package 2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

open(3spp)

LSEEK(3spp)

NAME

lseek − move read/write pointer

SYNOPSIS

#include <sys/file.h>

#define L_SET0/* set the seek pointer */
#define L_INCR1/* increment the seek pointer */

pos = lseek(d, offset, whence)
off_t pos;
int d;
off_t offset;
int whence;

DESCRIPTION

The descriptor d refers to a file or device open for reading and/or writing.  Lseek sets the file pointer of d 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.

Upon successful completion, the resulting pointer location as measured in bytes from beginning of the file is returned.  Some devices are incapable of seeking.  The value of the pointer associated with such a device is undefined. 

RETURN VALUE

Upon successful completion, the current file pointer value 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] Fildes is not an open file descriptor. 

[EINVAL] Whence is not a proper value. 

SEE ALSO

open(3spp)

BUGS

This document’s use of whence is incorrect English, but maintained for historical reasons. 

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