1LSEEK64(3) Linux Programmer's Manual LSEEK64(3)
2
3
4
6 lseek64 - reposition 64-bit read/write file offset
7
9 #define _LARGEFILE64_SOURCE /* See feature_test_macros(7) */
10 #include <sys/types.h>
11 #include <unistd.h>
12
13 off64_t lseek64(int fd, off64_t offset, int whence);
14
16 The lseek(2) family of functions reposition the offset of the open file
17 associated with the file descriptor fd to offset bytes relative to the
18 start, current position, or end of the file, when whence has the value
19 SEEK_SET, SEEK_CUR, or SEEK_END, respectively.
20
21 For more details, return value, and errors, see lseek(2).
22
23 Four interfaces are available: lseek(2), lseek64(), llseek(2), and
24 _llseek(2).
25
26 lseek()
27 Prototype:
28
29 off_t lseek(int fd, off_t offset, int whence);
30
31 lseek(2) uses the type off_t. This is a 32-bit signed type on 32-bit
32 architectures, unless one compiles with
33
34 #define _FILE_OFFSET_BITS 64
35
36 in which case it is a 64-bit signed type.
37
38 lseek64()
39 Prototype:
40
41 off64_t lseek64(int fd, off64_t offset, int whence);
42
43 The library routine lseek64() uses a 64-bit type even when off_t is a
44 32-bit type. Its prototype (and the type off64_t) is available only
45 when one compiles with
46
47 #define _LARGEFILE64_SOURCE
48
49 The function lseek64() is available since glibc 2.1, and is defined to
50 be an alias for llseek().
51
52 llseek()
53 Prototype:
54
55 loff_t llseek(int fd, loff_t offset, int whence);
56
57 The type loff_t is a 64-bit signed type. The library routine llseek()
58 is available in glibc and works without special defines. However, the
59 glibc headers do not provide a prototype. Users should add the above
60 prototype, or something equivalent, to their own source. When users
61 complained about data loss caused by a miscompilation of e2fsck(8),
62 glibc 2.1.3 added the link-time warning
63
64 "the `llseek´ function may be dangerous; use `lseek64´ instead."
65
66 This makes this function unusable if one desires a warning-free compi‐
67 lation.
68
69 _llseek()
70 On 32-bit architectures, this is the system call that is used to imple‐
71 ment all of the above functions. The prototype is:
72
73 int _llseek(int fd, off_t offset_hi, off_t offset_lo,
74 loff_t *result, int whence);
75
76 For more details, see llseek(2).
77
78 64-bit systems don't need an _llseek() system call. Instead, they have
79 an lseek(2) system call that supports 64-bit file offsets.
80
82 For an explanation of the terms used in this section, see
83 attributes(7).
84
85 ┌──────────┬───────────────┬─────────┐
86 │Interface │ Attribute │ Value │
87 ├──────────┼───────────────┼─────────┤
88 │lseek64() │ Thread safety │ MT-Safe │
89 └──────────┴───────────────┴─────────┘
91 llseek(2), lseek(2)
92
94 This page is part of release 4.16 of the Linux man-pages project. A
95 description of the project, information about reporting bugs, and the
96 latest version of this page, can be found at
97 https://www.kernel.org/doc/man-pages/.
98
99
100
101Linux 2017-09-15 LSEEK64(3)