|
|
1.1 root 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: .\"
5: .\" @(#)lseek.2 6.4 (Berkeley) 5/13/90
6: .\"
7: .TH LSEEK 2 "May 13, 1990"
8: .UC 4
9: .SH NAME
10: lseek \- move read/write pointer
11: .SH SYNOPSIS
12: .nf
13: .ft B
14: #include <unistd.h>
15:
16: pos = lseek(d, offset, whence)
17: off_t pos;
18: int d;
19: off_t offset;
20: int whence;
21: .fi
22: .ft R
23: .SH DESCRIPTION
24: The descriptor
25: .I d
26: refers to a file or device open for reading and/or writing.
27: .I Lseek
28: sets the file pointer of
29: .I d
30: as follows:
31: .IP
32: If
33: .I whence
34: is SEEK_SET, the pointer is set to
35: .I offset
36: bytes.
37: .IP
38: If
39: .I whence
40: is SEEK_CUR, the pointer is set to its current location plus
41: .IR offset .
42: .IP
43: If
44: .I whence
45: is SEEK_END, the pointer is set to the size of the
46: file plus
47: .IR offset .
48: .PP
49: Upon successful completion, the resulting pointer location
50: as measured in bytes from beginning of the file is returned.
51: Some devices are incapable of seeking. The value of the pointer
52: associated with such a device is undefined.
53: .SH NOTES
54: Seeking far beyond the end of a file, then writing,
55: creates a gap or \*(lqhole\*(rq, which occupies no
56: physical space and reads as zeros.
57: .SH "RETURN VALUE
58: Upon successful completion,
59: the current file pointer value is returned.
60: Otherwise,
61: a value of \-1 is returned and \fIerrno\fP is set to indicate
62: the error.
63: .SH "ERRORS
64: .I Lseek
65: will fail and the file pointer will remain unchanged if:
66: .TP 15
67: [EBADF]
68: .I Fildes
69: is not an open file descriptor.
70: .TP 15
71: [ESPIPE]
72: .I Fildes
73: is associated with a pipe or a socket.
74: .TP 15
75: [EINVAL]
76: .I Whence
77: is not a proper value.
78: .SH "SEE ALSO"
79: dup(2), open(2)
80: .SH BUGS
81: This document's use of
82: .I whence
83: is incorrect English, but maintained for historical reasons.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.