OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man3 / lseek64.3
1 .\" Copyright 2004 Andries Brouwer <aeb@cwi.nl>.
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .TH LSEEK64 3 2014-08-19 "Linux" "Linux Programmer's Manual"
26 .SH NAME
27 lseek64 \- reposition 64-bit read/write file offset
28 .SH SYNOPSIS
29 .BR "#define _LARGEFILE64_SOURCE" "     /* See feature_test_macros(7) */"
30 .br
31 .B #include <sys/types.h>
32 .br
33 .B #include <unistd.h>
34 .sp
35 .BI "off64_t lseek64(int " fd ", off64_t " offset ", int " whence );
36 .SH DESCRIPTION
37 The
38 .BR lseek (2)
39 family of functions reposition the offset of the open file associated
40 with the file descriptor
41 .I fd
42 to
43 .I offset
44 bytes relative to the start, current position, or end of the file,
45 when
46 .I whence
47 has the value
48 .BR SEEK_SET ,
49 .BR SEEK_CUR ,
50 or
51 .BR SEEK_END ,
52 respectively.
53 .LP
54 For more details, return value, and errors, see
55 .BR lseek (2).
56 .PP
57 Four interfaces are available:
58 .BR lseek (2),
59 .BR lseek64 (),
60 .BR llseek (2),
61 and the raw system call
62 .BR _llseek (2).
63 .SS lseek
64 Prototype:
65 .nf
66 .sp
67 .in +4n
68 .BI "off_t lseek(int " fd ", off_t " offset ", int " whence );
69 .in
70 .fi
71 .sp
72 .BR lseek (2)
73 uses the type
74 .IR off_t .
75 This is a 32-bit signed type on 32-bit architectures, unless one
76 compiles with
77 .nf
78 .sp
79 .in +4n
80 #define _FILE_OFFSET_BITS 64
81 .in
82 .sp
83 .fi
84 in which case it is a 64-bit signed type.
85 .SS lseek64
86 Prototype:
87 .nf
88 .sp
89 .in +4n
90 .BI "off64_t lseek64(int " fd ", off64_t " offset ", int " whence );
91 .in
92 .fi
93 .sp
94 The library routine
95 .BR lseek64 ()
96 uses a 64-bit type even when
97 .I off_t
98 is a 32-bit type.
99 Its prototype (and the type
100 .IR off64_t )
101 is available only when one compiles with
102 .nf
103 .sp
104 .in +4n
105 #define _LARGEFILE64_SOURCE
106 .in
107 .sp
108 .fi
109 The function
110 .BR lseek64 ()
111 .\" in glibc 2.0.94, not in 2.0.6
112 is available since glibc 2.1, and is defined to be an alias for
113 .BR llseek ().
114 .SS llseek
115 Prototype:
116 .nf
117 .sp
118 .in +4n
119 .BI "loff_t llseek(int " fd ", loff_t " offset ", int " whence );
120 .in
121 .fi
122 .sp
123 The type
124 .I loff_t
125 is a 64-bit signed type.
126 The library routine
127 .BR llseek ()
128 .\" in libc 5.0.9, not in 4.7.6
129 is available in the glibc and works without special defines.
130 However, the glibc headers do not provide a prototype.
131 Users should add
132 the above prototype, or something equivalent, to their own source.
133 When users complained about data loss caused by a miscompilation of
134 .BR e2fsck (8),
135 glibc 2.1.3 added the link-time warning
136 .sp
137 .in +4n
138 "the \`llseek\' function may be dangerous; use \`lseek64\' instead."
139 .in
140 .sp
141 This makes this function unusable if one desires a warning-free
142 compilation.
143 .SS _llseek
144 All the above functions are implemented in terms of this system call.
145 The prototype is:
146 .nf
147 .sp
148 .in +4n
149 .BI "int _llseek(int " fd ", off_t " offset_hi ", off_t " offset_lo ,
150 .BI "            loff_t *" result ", int " whence );
151 .in
152 .fi
153 .sp
154 For more details, see
155 .BR llseek (2).
156 .SH ATTRIBUTES
157 .SS Multithreading (see pthreads(7))
158 The
159 .BR lseek64 ()
160 function is thread-safe.
161 .SH SEE ALSO
162 .BR llseek (2),
163 .BR lseek (2)
164 .SH COLOPHON
165 This page is part of release 3.79 of the Linux
166 .I man-pages
167 project.
168 A description of the project,
169 information about reporting bugs,
170 and the latest version of this page,
171 can be found at
172 \%http://www.kernel.org/doc/man\-pages/.