1lseek64(3)                 Library Functions Manual                 lseek64(3)
2
3
4

NAME

6       lseek64 - reposition 64-bit read/write file offset
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #define _LARGEFILE64_SOURCE     /* See feature_test_macros(7) */
13       #include <sys/types.h>
14       #include <unistd.h>
15
16       off64_t lseek64(int fd, off64_t offset, int whence);
17

DESCRIPTION

19       The  lseek() family of functions reposition the offset of the open file
20       associated with the file descriptor fd to offset bytes relative to  the
21       start,  current position, or end of the file, when whence has the value
22       SEEK_SET, SEEK_CUR, or SEEK_END, respectively.
23
24       For more details, return value, and errors, see lseek(2).
25
26       Four  interfaces  are  available:  lseek(),  lseek64(),  llseek(),  and
27       _llseek().
28
29   lseek()
30       Prototype:
31
32           off_t lseek(int fd, off_t offset, int whence);
33
34       The  C library's lseek() wrapper function uses the type off_t.  This is
35       a 32-bit signed type on 32-bit architectures, unless one compiles with
36
37           #define _FILE_OFFSET_BITS 64
38
39       in which case it is a 64-bit signed type.
40
41   lseek64()
42       Prototype:
43
44           off64_t lseek64(int fd, off64_t offset, int whence);
45
46       The lseek64() library function uses a 64-bit type even when off_t is  a
47       32-bit  type.   Its  prototype (and the type off64_t) is available only
48       when one compiles with
49
50           #define _LARGEFILE64_SOURCE
51
52       The function lseek64() is available since glibc 2.1.
53
54   llseek()
55       Prototype:
56
57           loff_t llseek(int fd, loff_t offset, int whence);
58
59       The type loff_t is a 64-bit signed type.  The llseek() library function
60       is  available in glibc and works without special defines.  However, the
61       glibc headers do not provide a prototype.  Users should add  the  above
62       prototype,  or  something  equivalent, to their own source.  When users
63       complained about data loss caused by  a  miscompilation  of  e2fsck(8),
64       glibc 2.1.3 added the link-time warning
65
66           "the `llseek´ function may be dangerous; use `lseek64´ instead."
67
68       This  makes this function unusable if one desires a warning-free compi‐
69       lation.
70
71       Since glibc 2.28, this function symbol is no longer available to  newly
72       linked applications.
73
74   _llseek()
75       On 32-bit architectures, this is the system call that is used (by the C
76       library wrapper functions) to implement all  of  the  above  functions.
77       The prototype is:
78
79           int _llseek(int fd, off_t offset_hi, off_t offset_lo,
80                       loff_t *result, int whence);
81
82       For more details, see llseek(2).
83
84       64-bit systems don't need an _llseek() system call.  Instead, they have
85       an lseek(2) system call that supports 64-bit file offsets.
86

ATTRIBUTES

88       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
89       tributes(7).
90
91       ┌────────────────────────────────────────────┬───────────────┬─────────┐
92Interface                                   Attribute     Value   
93       ├────────────────────────────────────────────┼───────────────┼─────────┤
94lseek64()                                   │ Thread safety │ MT-Safe │
95       └────────────────────────────────────────────┴───────────────┴─────────┘
96

NOTES

98       lseek64()  is one of the functions that was specified in the Large File
99       Summit (LFS) specification that was completed in 1996.  The purpose  of
100       the  specification was to provide transitional support that allowed ap‐
101       plications on 32-bit systems to access files whose  size  exceeds  that
102       which  can  be  represented  with a 32-bit off_t type.  As noted above,
103       this symbol is exposed by header files if the _LARGEFILE64_SOURCE  fea‐
104       ture  test  macro  is  defined.  ALternatively, on a 32-bit system, the
105       symbol lseek is aliased to lseek64 if the  macro  _FILE_OFFSET_BITS  is
106       defined with the value 64.
107

SEE ALSO

109       llseek(2), lseek(2)
110
111
112
113Linux man-pages 6.04              2022-12-15                        lseek64(3)
Impressum