spelling fix, outblock to oublock
[unix-history] / usr / src / lib / libc / sys / lseek.2
CommitLineData
ec7838a8
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
d1c0365c 5.\" @(#)lseek.2 6.3 (Berkeley) %G%
ec7838a8 6.\"
ed86ee10 7.TH LSEEK 2 ""
ec7838a8
KM
8.UC 4
9.SH NAME
84648ee2 10lseek \- move read/write pointer
ec7838a8
KM
11.SH SYNOPSIS
12.nf
84648ee2 13.ft B
ed86ee10
KM
14#include <sys/file.h>
15.PP
16.nf
17.ft B
18.ta 1.25i 1.6i 1.8i
84648ee2
KM
19#define L_SET 0 /* set the seek pointer */
20#define L_INCR 1 /* increment the seek pointer */
21#define L_XTND 2 /* extend the file size */
ec7838a8 22.PP
84648ee2
KM
23.ft B
24pos = lseek(d, offset, whence)
ed86ee10
KM
25off_t pos;
26int d;
27off_t offset;
28int whence;
ec7838a8 29.fi
84648ee2 30.ft R
ec7838a8 31.SH DESCRIPTION
84648ee2
KM
32The descriptor
33.I d
34refers to a file or device open for reading and/or writing.
35.I Lseek
36sets the file pointer of
37.I d
38as follows:
ec7838a8
KM
39.IP
40If
41.I whence
84648ee2 42is L_SET, the pointer is set to
ec7838a8
KM
43.I offset
44bytes.
45.IP
46If
47.I whence
84648ee2 48is L_INCR, the pointer is set to its current location plus
ec7838a8
KM
49.IR offset .
50.IP
51If
52.I whence
84648ee2 53is L_XTND, the pointer is set to the size of the
ec7838a8
KM
54file plus
55.IR offset .
56.PP
84648ee2
KM
57Upon successful completion, the resulting pointer location
58as measured in bytes from beginning of the file is returned.
59Some devices are incapable of seeking. The value of the pointer
60associated with such a device is undefined.
61.SH NOTES
ec7838a8 62Seeking far beyond the end of a file, then writing,
84648ee2 63creates a gap or \*(lqhole\*(rq, which occupies no
ec7838a8 64physical space and reads as zeros.
84648ee2 65.SH "RETURN VALUE
594f4c31
KM
66Upon successful completion,
67the current file pointer value is returned.
68Otherwise,
84648ee2
KM
69a value of \-1 is returned and \fIerrno\fP is set to indicate
70the error.
71.SH "ERRORS
72.I Lseek
73will fail and the file pointer will remain unchanged if:
74.TP 15
75[EBADF]
76.I Fildes
77is not an open file descriptor.
78.TP 15
79[ESPIPE]
80.I Fildes
81is associated with a pipe or a socket.
82.TP 15
83[EINVAL]
84.I Whence
85is not a proper value.
ec7838a8 86.SH "SEE ALSO"
84648ee2 87dup(2), open(2)
ec7838a8 88.SH BUGS
84648ee2
KM
89This document's use of
90.I whence
91is incorrect English, but maintained for historical reasons.