BSD 4_4 development
[unix-history] / usr / share / man / cat2 / seek.0
CommitLineData
8bb980a3
C
1LSEEK(2) BSD Programmer's Manual LSEEK(2)
2
3N\bNA\bAM\bME\bE
4 l\bls\bse\bee\bek\bk - reposition read/write file offset
5
6S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
7 #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<u\bun\bni\bis\bst\btd\bd.\b.h\bh>\b>
8
9 _\bo_\bf_\bf_\b__\bt
10 l\bls\bse\bee\bek\bk(_\bi_\bn_\bt _\bf_\bi_\bl_\bd_\be_\bs, _\bo_\bf_\bf_\b__\bt _\bo_\bf_\bf_\bs_\be_\bt, _\bi_\bn_\bt _\bw_\bh_\be_\bn_\bc_\be);
11
12D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
13 The l\bls\bse\bee\bek\bk() function repositions the offset of the file descriptor _\bf_\bi_\bl_\bd_\be_\bs
14 to the argument _\bo_\bf_\bf_\bs_\be_\bt according to the directive _\bw_\bh_\be_\bn_\bc_\be_\b. The argument
15 _\bf_\bi_\bl_\bd_\be_\bs must be an open file descriptor. L\bLs\bse\bee\bek\bk() repositions the file
16 pointer _\bf_\bi_\bl_\bd_\be_\bs as follows:
17
18 If _\bw_\bh_\be_\bn_\bc_\be is SEEK_SET, the offset is set to _\bo_\bf_\bf_\bs_\be_\bt bytes.
19
20 If _\bw_\bh_\be_\bn_\bc_\be is SEEK_CUR, the offset is set to its current location
21 plus _\bo_\bf_\bf_\bs_\be_\bt bytes.
22
23 If _\bw_\bh_\be_\bn_\bc_\be is SEEK_END, the offset is set to the size of the file
24 plus _\bo_\bf_\bf_\bs_\be_\bt bytes.
25
26 The l\bls\bse\bee\bek\bk() function allows the file offset to be set beyond the end of
27 the existing end-of-file of the file. If data is later written at this
28 point, subsequent reads of the data in the gap return bytes of zeros (un-
29 til data is actualy written into the gap).
30
31 Some devices are incapable of seeking. The value of the pointer associ-
32 ated with such a device is undefined.
33
34R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
35 Upon successful completion, l\bls\bse\bee\bek\bk() returns the resulting offset location
36 as measured in bytes from the begining of the file. Otherwise, a value
37 of -1 is returned and _\be_\br_\br_\bn_\bo is set to indicate the error.
38
39E\bER\bRR\bRO\bOR\bRS\bS
40 L\bLs\bse\bee\bek\bk() will fail and the file pointer will remain unchanged if:
41
42 [EBADF] _\bF_\bi_\bl_\bd_\be_\bs is not an open file descriptor.
43
44 [ESPIPE] _\bF_\bi_\bl_\bd_\be_\bs is associated with a pipe, socket, or FIFO.
45
46 [EINVAL] _\bW_\bh_\be_\bn_\bc_\be is not a proper value.
47
48S\bSE\bEE\bE A\bAL\bLS\bSO\bO
49 dup(2), open(2)
50
51B\bBU\bUG\bGS\bS
52 This document's use of _\bw_\bh_\be_\bn_\bc_\be is incorrect English, but maintained for
53 historical reasons.
54
55S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
56 The l\bls\bse\bee\bek\bk() function conforms to IEEE Std 1003.1-1988 (``POSIX'').
57
584th Berkeley Distribution June 4, 1993 1