xref: /386bsd/usr/share/man/cat2/seek.0 (revision a2142627)
1LSEEK(2)                  386BSD Programmer's Manual                  LSEEK(2)
2
3NNAAMMEE
4     llsseeeekk - reposition read/write file offset
5
6SSYYNNOOPPSSIISS
7     ##iinncclluuddee <<uunniissttdd..hh>>
8
9     _o_f_f__t
10     llsseeeekk(_i_n_t _f_i_l_d_e_s, _o_f_f__t _o_f_f_s_e_t, _i_n_t _w_h_e_n_c_e)
11
12DDEESSCCRRIIPPTTIIOONN
13     The llsseeeekk() function repositions the offset of the file descriptor _f_i_l_d_e_s
14     to the argument _o_f_f_s_e_t according to the directive _w_h_e_n_c_e. The argument
15     _f_i_l_d_e_s must be an open file descriptor.  LLsseeeekk() repositions the file
16     pointer _f_i_l_d_e_s as follows:
17
18           If _w_h_e_n_c_e is SEEK_SET, the offset is set to _o_f_f_s_e_t bytes.
19
20           If _w_h_e_n_c_e is SEEK_CUR, the offset is set to its current location
21           plus _o_f_f_s_e_t bytes.
22
23           If _w_h_e_n_c_e is SEEK_END, the offset is set to the size of the file
24           plus _o_f_f_s_e_t bytes.
25
26     The llsseeeekk() 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
29     (until data is actualy written into the gap).
30
31     Some devices are incapable of seeking.  The value of the pointer
32     associated with such a device is undefined.
33
34RREETTUURRNN VVAALLUUEESS
35     Upon successful completion, llsseeeekk() 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 _e_r_r_n_o is set to indicate the error.
38
39EERRRROORRSS
40     LLsseeeekk() will fail and the file pointer will remain unchanged if:
41
42     [EBADF]   _F_i_l_d_e_s is not an open file descriptor.
43
44     [ESPIPE]  _F_i_l_d_e_s is associated with a pipe, socket, or FIFO.
45
46     [EINVAL]  _W_h_e_n_c_e is not a proper value.
47
48SSEEEE AALLSSOO
49     dup(2),  open(2)
50
51BBUUGGSS
52     This document's use of _w_h_e_n_c_e is incorrect English, but maintained for
53     historical reasons.
54
55SSTTAANNDDAARRDDSS
56     The llsseeeekk() function conforms to IEEE Std 1003.1-1988 (``POSIX'').
57
584th Berkeley Distribution       March 10, 1991                               1
59
60
61
62
63
64
65
66
67