1 .\" Copyright 2004 Andries Brouwer <aeb@cwi.nl>.
2 .\" and Copyright (c) 2020 Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .TH LSEEK64 3 2021-03-22 "Linux" "Linux Programmer's Manual"
28 lseek64 \- reposition 64-bit read/write file offset
31 .BR "#define _LARGEFILE64_SOURCE" " /* See feature_test_macros(7) */"
32 .B #include <sys/types.h>
33 .B #include <unistd.h>
35 .BI "off64_t lseek64(int " fd ", off64_t " offset ", int " whence );
40 family of functions reposition the offset of the open file associated
41 with the file descriptor
45 bytes relative to the start, current position, or end of the file,
55 For more details, return value, and errors, see
58 Four interfaces are available:
65 .\" For some background details, see:
66 .\" https://lore.kernel.org/linux-man/CAKgNAkhNSWR3uYhYYaxx74fZfJ3JrpfAAPVrK0AFk_cAOUsbDg@mail.gmail.com/
73 .BI "off_t lseek(int " fd ", off_t " offset ", int " whence );
79 wrapper function uses the type
81 This is a 32-bit signed type on 32-bit architectures, unless one
86 #define _FILE_OFFSET_BITS 64
90 in which case it is a 64-bit signed type.
96 .BI "off64_t lseek64(int " fd ", off64_t " offset ", int " whence );
102 library function uses a 64-bit type even when
105 Its prototype (and the type
107 is available only when one compiles with
111 #define _LARGEFILE64_SOURCE
117 .\" in glibc 2.0.94, not in 2.0.6
118 is available since glibc 2.1.
125 .BI "loff_t llseek(int " fd ", loff_t " offset ", int " whence );
131 is a 64-bit signed type.
134 library function is available in glibc and works without special defines.
135 However, the glibc headers do not provide a prototype.
137 the above prototype, or something equivalent, to their own source.
138 When users complained about data loss caused by a miscompilation of
140 glibc 2.1.3 added the link-time warning
143 "the \`llseek\' function may be dangerous; use \`lseek64\' instead."
146 This makes this function unusable if one desires a warning-free
150 .\" glibc commit 5c5c0dd747070db624c8e2c43691cec854f114ef
151 this function symbol is no longer available to newly linked applications.
154 On 32-bit architectures,
155 this is the system call that is used (by the C library wrapper functions)
156 to implement all of the above functions.
161 .BI "int _llseek(int " fd ", off_t " offset_hi ", off_t " offset_lo ,
162 .BI " loff_t *" result ", int " whence );
166 For more details, see
169 64-bit systems don't need an
172 Instead, they have an
174 system call that supports 64-bit file offsets.
175 .\" In arch/x86/entry/syscalls/syscall_32.tbl,
176 .\" we see the following line:
178 .\" 140 i386 _llseek sys_llseek
180 .\" This is essentially telling us that 'sys_llseek' (the name generated
181 .\" by SYSCALL_DEFINE5(llseek...)) is exposed to user-space as system call
182 .\" number 140, and that system call number will (IIUC) be exposed in
183 .\" autogenerated headers with the name "__NR__llseek" (i.e., "_llseek").
184 .\" The "i386" is telling us that this happens in i386 (32-bit Intel).
185 .\" There is nothing equivalent on x86-64, because 64 bit systems don't
186 .\" need an _llseek system call.
188 For an explanation of the terms used in this section, see
196 Interface Attribute Value
199 T} Thread safety MT-Safe
206 is one of the functions that was specified in the Large File Summit (LFS)
207 specification that was completed in 1996.
208 The purpose of the specification was to provide transitional support
209 that allowed applications on 32-bit systems to access
210 files whose size exceeds that which can be represented with a 32-bit
213 As noted above, this symbol is exposed by header files if the
214 .B _LARGEFILE64_SOURCE
215 feature test macro is defined.
216 ALternatively, on a 32-bit system, the symbol
222 is defined with the value 64.