source: trunk/minix/man/man2/lseek.2@ 11

Last change on this file since 11 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 1.9 KB
RevLine 
[9]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.3 (Berkeley) 2/24/86
6.\"
7.TH LSEEK 2 "February 24, 1986"
8.UC 4
9.SH NAME
10lseek \- move read/write pointer
11.SH SYNOPSIS
12.nf
13.ft B
14#include <sys/types.h>
15#include <unistd.h>
16
17.ta +1.8i +0.6i
18#define SEEK_SET 0 /* offset is absolute */
19#define SEEK_CUR 1 /* relative to current position */
20#define SEEK_END 2 /* relative to end of file */
21
22off_t lseek(int d, off_t offset, int whence)
23.fi
24.ft R
25.SH DESCRIPTION
26The descriptor
27.I d
28refers to a file or device open for reading and/or writing.
29.B Lseek
30sets the file pointer of
31.I d
32as follows:
33.IP
34If
35.I whence
36is SEEK_SET, the pointer is set to
37.I offset
38bytes.
39.IP
40If
41.I whence
42is SEEK_CUR, the pointer is set to its current location plus
43.IR offset .
44.IP
45If
46.I whence
47is SEEK_END, the pointer is set to the size of the
48file plus
49.IR offset .
50.PP
51Upon successful completion, the resulting pointer location
52as measured in bytes from beginning of the file is returned.
53Some devices are incapable of seeking. The value of the pointer
54associated with such a device is undefined.
55.SH NOTES
56Seeking far beyond the end of a file, then writing,
57creates a gap or \*(lqhole\*(rq, which occupies no
58physical space and reads as zeros.
59.SH "RETURN VALUE
60Upon successful completion,
61the current file pointer value is returned.
62Otherwise,
63a value of \-1 is returned and \fBerrno\fP is set to indicate
64the error.
65.SH "ERRORS
66.B Lseek
67will fail and the file pointer will remain unchanged if:
68.TP 15
69[EBADF]
70.I Fildes
71is not an open file descriptor.
72.TP 15
73[ESPIPE]
74.I Fildes
75is associated with a pipe or a socket.
76.TP 15
77[EINVAL]
78.I Whence
79is not a proper value.
80.SH "SEE ALSO"
81.BR fcntl (2),
82.BR open (2).
83.SH BUGS
84This document's use of
85.I whence
86is incorrect English, but maintained for historical reasons.
Note: See TracBrowser for help on using the repository browser.