OSDN Git Service

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