2 .\" Copyright 2004 Andries Brouwer <aeb@cwi.nl>.
3 .\" and Copyright (c) 2020 Michael Kerrisk <mtk.manpages@gmail.com>
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .TH lseek64 3 (date) "Linux man-pages (unreleased)"
9 lseek64 \- reposition 64-bit read/write file offset
12 .RI ( libc ", " \-lc )
15 .BR "#define _LARGEFILE64_SOURCE" " /* See feature_test_macros(7) */"
16 .B #include <sys/types.h>
17 .B #include <unistd.h>
19 .BI "off64_t lseek64(int " fd ", off64_t " offset ", int " whence );
24 family of functions reposition the offset of the open file associated
25 with the file descriptor
29 bytes relative to the start, current position, or end of the file,
39 For more details, return value, and errors, see
42 Four interfaces are available:
49 .\" For some background details, see:
50 .\" https://lore.kernel.org/linux-man/CAKgNAkhNSWR3uYhYYaxx74fZfJ3JrpfAAPVrK0AFk_cAOUsbDg@mail.gmail.com/
57 .BI "off_t lseek(int " fd ", off_t " offset ", int " whence );
63 wrapper function uses the type
65 This is a 32-bit signed type on 32-bit architectures, unless one
70 #define _FILE_OFFSET_BITS 64
74 in which case it is a 64-bit signed type.
80 .BI "off64_t lseek64(int " fd ", off64_t " offset ", int " whence );
86 library function uses a 64-bit type even when
89 Its prototype (and the type
91 is available only when one compiles with
95 #define _LARGEFILE64_SOURCE
101 .\" in glibc 2.0.94, not in glibc 2.0.6
102 is available since glibc 2.1.
109 .BI "loff_t llseek(int " fd ", loff_t " offset ", int " whence );
115 is a 64-bit signed type.
118 library function is available in glibc and works without special defines.
119 However, the glibc headers do not provide a prototype.
121 the above prototype, or something equivalent, to their own source.
122 When users complained about data loss caused by a miscompilation of
124 glibc 2.1.3 added the link-time warning
127 "the \`llseek\' function may be dangerous; use \`lseek64\' instead."
130 This makes this function unusable if one desires a warning-free
134 .\" glibc commit 5c5c0dd747070db624c8e2c43691cec854f114ef
135 this function symbol is no longer available to newly linked applications.
138 On 32-bit architectures,
139 this is the system call that is used (by the C library wrapper functions)
140 to implement all of the above functions.
145 .BI "int _llseek(int " fd ", off_t " offset_hi ", off_t " offset_lo ,
146 .BI " loff_t *" result ", int " whence );
150 For more details, see
153 64-bit systems don't need an
156 Instead, they have an
158 system call that supports 64-bit file offsets.
159 .\" In arch/x86/entry/syscalls/syscall_32.tbl,
160 .\" we see the following line:
162 .\" 140 i386 _llseek sys_llseek
164 .\" This is essentially telling us that 'sys_llseek' (the name generated
165 .\" by SYSCALL_DEFINE5(llseek...)) is exposed to user-space as system call
166 .\" number 140, and that system call number will (IIUC) be exposed in
167 .\" autogenerated headers with the name "__NR__llseek" (i.e., "_llseek").
168 .\" The "i386" is telling us that this happens in i386 (32-bit Intel).
169 .\" There is nothing equivalent on x86-64, because 64 bit systems don't
170 .\" need an _llseek system call.
172 For an explanation of the terms used in this section, see
178 Interface Attribute Value
183 T} Thread safety MT-Safe
187 is one of the functions that was specified in the Large File Summit (LFS)
188 specification that was completed in 1996.
189 The purpose of the specification was to provide transitional support
190 that allowed applications on 32-bit systems to access
191 files whose size exceeds that which can be represented with a 32-bit
194 As noted above, this symbol is exposed by header files if the
195 .B _LARGEFILE64_SOURCE
196 feature test macro is defined.
197 ALternatively, on a 32-bit system, the symbol
203 is defined with the value 64.