1llseek(2)                        System Calls                        llseek(2)
2
3
4

NAME

6       llseek - move extended read/write file pointer
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <unistd.h>
11
12       offset_t llseek(int fildes, offset_t offset, int whence);
13
14

DESCRIPTION

16       The  llseek() function sets the 64-bit extended file pointer associated
17       with the open file descriptor specified by fildes as follows:
18
19           o      If whence is SEEK_SET, the pointer is set to offset bytes.
20
21           o      If whence is SEEK_CUR, the pointer is  set  to  its  current
22                  location plus offset.
23
24           o      If whence is SEEK_END, the pointer is set to the size of the
25                  file plus offset.
26
27           o      If whence is SEEK_HOLE, the offset of the start of the  next
28                  hole  greater  than  or  equal  to  the  supplied  offset is
29                  returned. The definition of a hole immediately follows  this
30                  list.
31
32           o      If whence is SEEK_DATA, the file pointer is set to the start
33                  of the next non-hole file region greater than  or  equal  to
34                  the supplied offset.
35
36
37       A  "hole" is defined as a contiguous range of bytes in a file, all hav‐
38       ing the value of zero, but not all zeros in a file are guaranteed to be
39       represented  as  holes returned with SEEK_HOLE. Filesystems are allowed
40       to expose ranges of zeros with SEEK_HOLE, but not required to. Applica‐
41       tions can use SEEK_HOLE to optimise their behavior for ranges of zeros,
42       but must not depend on it to find all such ranges in a file. The  exis‐
43       tence  of  a  hole at the end of every data region allows for easy pro‐
44       gramming and implies that a virtual hole exists at the end of the file.
45
46
47       For filesystems that do not supply information about  holes,  the  file
48       will be represented as one entire data region.
49
50
51       Although  each  file has a 64-bit file pointer associated with it, some
52       existing file system types (such as tmpfs)  do  not  support  the  full
53       range  of  64-bit  offsets.   In particular, on such file systems, non-
54       device files remain limited to offsets  of  less  than  two  gigabytes.
55       Device  drivers  may support offsets of up to 1024 gigabytes for device
56       special files.
57
58
59       Some devices are incapable of seeking. The value of  the  file  pointer
60       associated with such a device is undefined.
61

RETURN VALUES

63       Upon  successful  completion,  llseek()  returns  the resulting pointer
64       location as measured in bytes from the beginning of  the  file.  Remote
65       file  descriptors  are the only ones that allow negative file pointers.
66       Otherwise, −1 is returned, the  file  pointer  remains  unchanged,  and
67       errno is set to indicate the error.
68

ERRORS

70       The llseek() function will fail if:
71
72       EBADF     The fildes argument is not an open file descriptor.
73
74
75       EINVAL    The  whence  argument is not SEEK_SET, SEEK_CUR, or SEEK_END;
76                 the offset argument is not a valid offset for this file  sys‐
77                 tem  type;  or  the  fildes  argument  is  not  a remote file
78                 descriptor and the resulting file pointer would be negative.
79
80
81       ENXIO     For SEEK_DATA, there are no more data regions past  the  sup‐
82                 plied offset. For SEEK_HOLE, there are no more holes past the
83                 supplied offset.
84
85
86       ESPIPE    The fildes argument is associated with a pipe or FIFO.
87
88

SEE ALSO

90       creat(2), dup(2), fcntl(2), lseek(2), open(2)
91
92
93
94SunOS 5.11                        1 Apr 2005                         llseek(2)
Impressum