Penguin
Annotated edit history of lseek(2) version 4, including all changes. View license author blame.
Rev Author # Line
1 perry 1 !!NAME
2 PerryLorier 2 lseek - reposition read/write file offset
1 perry 3
4 !!SYNOPSIS
5
2 PerryLorier 6 #include <sys/types.h>
7 #include <unistd.h>
1 perry 8
2 PerryLorier 9 __off_t lseek(int__ ''fildes''__, off_t__ ''offset''__, int__ ''whence''__);__
1 perry 10
11 !!DESCRIPTION
2 PerryLorier 12 The lseek(2) function repositions the offset of the file descriptor ''fildes'' to the argument ''offset'' according to the directive ''whence'' as follows:
1 perry 13
2 PerryLorier 14 ;[SEEK_SET]: The offset is set to ''offset'' bytes.
15 ;[SEEK_CUR]: The offset is set to its current location plus ''offset'' bytes.
16 ;[SEEK_END]: The offset is set to the size of the file plus ''offset'' bytes.
1 perry 17
2 PerryLorier 18 The lseek(2) 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).
1 perry 19
20 !!RETURN VALUE
2 PerryLorier 21 Upon successful completion, __lseek__ returns the resulting offset location as measured in bytes from the beginning of the file. Otherwise, a value of (off_t)-1 is
22 returned and ''errno'' is set to indicate the error.
1 perry 23 !!ERRORS
2 PerryLorier 24 ;[EBADF]: ''Fildes'' is not an open file descriptor.
25 ;[ESPIPE]: ''Fildes'' is associated with a pipe, socket, or FIFO.
26 ;[EINVAL]: ''Whence'' is not a proper value.
3 PerryLorier 27 ;[EOVERFLOW]: file is larger than can fit in off_t
1 perry 28
29 !!CONFORMING TO
4 JohnMcPherson 30 SVr4, [POSIX], [BSD] 4.3
1 perry 31
32 !!RESTRICTIONS
4 JohnMcPherson 33 Some devices are incapable of seeking and [POSIX] does not specify which devices must support it.
1 perry 34
2 PerryLorier 35 Linux specific restrictions: using lseek(2) on a tty device returns [ESPIPE]. Other systems return the number of written characters, using SEEK_SET to set the
36 counter. Some devices, e.g. __/dev/null__ do not cause the error [ESPIPE], but return a pointer which value is undefined.
1 perry 37
38 !!NOTES
2 PerryLorier 39 This document's use of ''whence'' is incorrect English, but maintained for historical (hysterical?) reasons.
1 perry 40
2 PerryLorier 41 When converting old code, substitute values for ''whence'' with the following macros:
1 perry 42
4 JohnMcPherson 43 SVR1-3 returns __long__ instead of __off_t__, [BSD] returns __int__.
1 perry 44
45 !!SEE ALSO
46 dup(2), open(2), fseek(3)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.

PHP Warning

lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 10 times)