mirror of
https://github.com/GnoConsortium/gno.git
synced 2024-12-22 14:30:29 +00:00
140 lines
3.9 KiB
Groff
140 lines
3.9 KiB
Groff
|
.\" Copyright (c) 1980, 1991, 1993
|
||
|
.\" The Regents of the University of California. All rights reserved.
|
||
|
.\"
|
||
|
.\" Redistribution and use in source and binary forms, with or without
|
||
|
.\" modification, are permitted provided that the following conditions
|
||
|
.\" are met:
|
||
|
.\" 1. Redistributions of source code must retain the above copyright
|
||
|
.\" notice, this list of conditions and the following disclaimer.
|
||
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||
|
.\" notice, this list of conditions and the following disclaimer in the
|
||
|
.\" documentation and/or other materials provided with the distribution.
|
||
|
.\" 3. All advertising materials mentioning features or use of this software
|
||
|
.\" must display the following acknowledgement:
|
||
|
.\" This product includes software developed by the University of
|
||
|
.\" California, Berkeley and its contributors.
|
||
|
.\" 4. Neither the name of the University nor the names of its contributors
|
||
|
.\" may be used to endorse or promote products derived from this software
|
||
|
.\" without specific prior written permission.
|
||
|
.\"
|
||
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||
|
.\" SUCH DAMAGE.
|
||
|
.\"
|
||
|
.\" @(#)lseek.2 8.3 (Berkeley) 4/19/94
|
||
|
.\"
|
||
|
.TH LSEEK 2 "22 January 1997" GNO "System Calls"
|
||
|
.SH NAME
|
||
|
.BR lseek
|
||
|
\- reposition read/write file offset
|
||
|
.SH SYNOPSIS
|
||
|
.br
|
||
|
#include <unistd.h>
|
||
|
.sp 1
|
||
|
off_t
|
||
|
\fBlseek\fR (int \fIfildes\fR, off_t \fIoffset\fR, int \fIwhence\fR);
|
||
|
.SH DESCRIPTION
|
||
|
The
|
||
|
.BR lseek
|
||
|
function repositions the offset of the file descriptor
|
||
|
.I fildes
|
||
|
to the
|
||
|
argument
|
||
|
.I offset
|
||
|
according to the directive
|
||
|
.I whence.
|
||
|
The argument
|
||
|
.I fildes
|
||
|
must be an open
|
||
|
file descriptor.
|
||
|
.BR Lseek
|
||
|
repositions the file pointer
|
||
|
.I fildes
|
||
|
as follows:
|
||
|
.RS
|
||
|
.It
|
||
|
If
|
||
|
.I whence
|
||
|
is
|
||
|
.BR SEEK_SET ,
|
||
|
the offset is set to
|
||
|
.I offset
|
||
|
bytes.
|
||
|
.It
|
||
|
If
|
||
|
.I whence
|
||
|
is
|
||
|
.BR SEEK_CUR ,
|
||
|
the offset is set to its current location plus
|
||
|
.I offset
|
||
|
bytes.
|
||
|
.It
|
||
|
If
|
||
|
.I whence
|
||
|
is
|
||
|
.BR SEEK_END ,
|
||
|
the offset is set to the size of the
|
||
|
file plus
|
||
|
.I offset
|
||
|
bytes.
|
||
|
.RE
|
||
|
.LP
|
||
|
The
|
||
|
.BR lseek
|
||
|
function allows the file offset to be set beyond the end
|
||
|
of the existing end-of-file of the file. If data is later written
|
||
|
at this point, subsequent reads of the data in the gap return
|
||
|
bytes of zeros (until data is actually written into the gap).
|
||
|
.LP
|
||
|
Some devices are incapable of seeking. The value of the pointer
|
||
|
associated with such a device is undefined.
|
||
|
.SH RETURN VALUES
|
||
|
Upon successful completion,
|
||
|
.BR lseek
|
||
|
returns the resulting offset location as measured in bytes from the
|
||
|
beginning of the file.
|
||
|
Otherwise,
|
||
|
a value of -1 is returned and
|
||
|
.IR errno
|
||
|
is set to indicate
|
||
|
the error.
|
||
|
.SH ERRORS
|
||
|
.BR Lseek
|
||
|
will fail and the file pointer will remain unchanged if:
|
||
|
.RS
|
||
|
.IP \fBEBADF\fR
|
||
|
.IR Fildes
|
||
|
is not an open file descriptor.
|
||
|
.IP \fBESPIPE\fR
|
||
|
.IR Fildes
|
||
|
is associated with a pipe, socket, or FIFO.
|
||
|
.IP \fBEINVAL\fR
|
||
|
.I Whence
|
||
|
is not a proper value.
|
||
|
.RE
|
||
|
.SH SEE ALSO
|
||
|
.BR dup (2),
|
||
|
.BR open (2)
|
||
|
.SH BUGS
|
||
|
In the GNO implementation, doing an
|
||
|
.BR lseek
|
||
|
past the end of file is permitted, but the created gap (as mentioned
|
||
|
above) is not gauranteed to contain bytes of zeros.
|
||
|
.LP
|
||
|
This document's use of
|
||
|
.I whence
|
||
|
is incorrect English, but is maintained for historical reasons.
|
||
|
.SH STANDARDS
|
||
|
The
|
||
|
.BR lseek
|
||
|
function
|
||
|
conforms to IEEE Std 1003.1-1988 (POSIX).
|