Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ lseek(2) — GL2 W3.6

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

creat(2)

dup(2)

fcntl(2)

open(2)

LSEEK(2)  —  Silicon Graphics

NAME

lseek − move read/write file pointer

SYNOPSIS

long lseek (fildes, offset, whence)
int fildes;
long 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 0, the pointer is set to offset bytes. 

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

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

Upon successful completion, the resulting pointer location as measured in bytes from the beginning of the file is returned. 

Lseek will fail and the file pointer will remain unchanged if one or more of the following are true:

Fildes is not an open file descriptor.  ­[EBADF]

Fildes is associated with a pipe or fifo.  ­[ESPIPE]

Whence is not 0, 1 or 2.  ­[EINVAL and SIGSYS ­signal]

The resulting file pointer would be negative.  ­[EINVAL]

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

RETURN VALUE

Upon successful completion, a non-negative integer indicating the file pointer value is returned.  Otherwise, a value of −1 is returned and errno is set to indicate the error. 

SEE ALSO

creat(2), dup(2), fcntl(2), open(2). 

ASSEMBLER

moveq#19,D0
movlfildes,A0
movloffset,D1
movlwhence,A1
trap#0

Carry bit set on failure and cleared on success. 

File offset returned in D0. 

Version 3.6  —  December 20, 1987

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