man-pages/man3/lseek64.3.html
2021-03-31 01:06:50 +01:00

273 lines
5.4 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of LSEEK64</TITLE>
</HEAD><BODY>
<H1>LSEEK64</H1>
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
lseek64 - reposition 64-bit read/write file offset
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>#define _LARGEFILE64_SOURCE</B> /* See <A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A>(7) */
<BR>
<B>#include &lt;<A HREF="file:///usr/include/sys/types.h">sys/types.h</A>&gt;</B>
<BR>
<B>#include &lt;<A HREF="file:///usr/include/unistd.h">unistd.h</A>&gt;</B>
<P>
<B>off64_t lseek64(int </B><I>fd</I><B>, off64_t </B><I>offset</I><B>, int </B><I>whence</I><B>);</B>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
The
<B><A HREF="/cgi-bin/man/man2html?2+lseek">lseek</A></B>(2)
family of functions reposition the offset of the open file associated
with the file descriptor
<I>fd</I>
to
<I>offset</I>
bytes relative to the start, current position, or end of the file,
when
<I>whence</I>
has the value
<B>SEEK_SET</B>,
<B>SEEK_CUR</B>,
or
<B>SEEK_END</B>,
respectively.
<P>
For more details, return value, and errors, see
<B><A HREF="/cgi-bin/man/man2html?2+lseek">lseek</A></B>(2).
<P>
Four interfaces are available:
<B><A HREF="/cgi-bin/man/man2html?2+lseek">lseek</A></B>(2),
<B>lseek64</B>(),
<B><A HREF="/cgi-bin/man/man2html?2+llseek">llseek</A></B>(2),
and
<B><A HREF="/cgi-bin/man/man2html?2+_llseek">_llseek</A></B>(2).
<A NAME="lbAE">&nbsp;</A>
<H3>lseek()</H3>
Prototype:
<P>
<B>off_t lseek(int </B><I>fd</I><B>, off_t </B><I>offset</I><B>, int </B><I>whence</I><B>);</B>
<P>
<B><A HREF="/cgi-bin/man/man2html?2+lseek">lseek</A></B>(2)
uses the type
<I>off_t</I>.
This is a 32-bit signed type on 32-bit architectures, unless one
compiles with
<P>
#define _FILE_OFFSET_BITS 64
<P>
in which case it is a 64-bit signed type.
<A NAME="lbAF">&nbsp;</A>
<H3>lseek64()</H3>
Prototype:
<P>
<B>off64_t lseek64(int </B><I>fd</I><B>, off64_t </B><I>offset</I><B>, int </B><I>whence</I><B>);</B>
<P>
The library routine
<B>lseek64</B>()
uses a 64-bit type even when
<I>off_t</I>
is a 32-bit type.
Its prototype (and the type
<I>off64_t</I>)
is available only when one compiles with
<P>
#define _LARGEFILE64_SOURCE
<P>
The function
<B>lseek64</B>()
is available since glibc 2.1, and is defined to be an alias for
<B>llseek</B>().
<A NAME="lbAG">&nbsp;</A>
<H3>llseek()</H3>
Prototype:
<P>
<B>loff_t llseek(int </B><I>fd</I><B>, loff_t </B><I>offset</I><B>, int </B><I>whence</I><B>);</B>
<P>
The type
<I>loff_t</I>
is a 64-bit signed type.
The library routine
<B>llseek</B>()
is available in glibc and works without special defines.
However, the glibc headers do not provide a prototype.
Users should add
the above prototype, or something equivalent, to their own source.
When users complained about data loss caused by a miscompilation of
<B><A HREF="/cgi-bin/man/man2html?8+e2fsck">e2fsck</A></B>(8),
glibc 2.1.3 added the link-time warning
<P>
&quot;the `llseek' function may be dangerous; use `lseek64' instead.&quot;
<P>
This makes this function unusable if one desires a warning-free
compilation.
<A NAME="lbAH">&nbsp;</A>
<H3>_llseek()</H3>
On 32-bit architectures,
this is the system call that is used to implement all of the above functions.
The prototype is:
<P>
<B>int _llseek(int </B><I>fd</I><B>, off_t </B><I>offset_hi</I><B>, off_t </B><I>offset_lo</I><B>,</B>
<B> loff_t *</B><I>result</I><B>, int </B><I>whence</I><B>);</B>
<P>
For more details, see
<B><A HREF="/cgi-bin/man/man2html?2+llseek">llseek</A></B>(2).
<P>
64-bit systems don't need an
<B>_llseek</B>()
system call.
Instead, they have an
<B><A HREF="/cgi-bin/man/man2html?2+lseek">lseek</A></B>(2)
system call that supports 64-bit file offsets.
<A NAME="lbAI">&nbsp;</A>
<H2>ATTRIBUTES</H2>
For an explanation of the terms used in this section, see
<B><A HREF="/cgi-bin/man/man2html?7+attributes">attributes</A></B>(7).
<TABLE BORDER>
<TR VALIGN=top><TD><B>Interface</B></TD><TD><B>Attribute</B></TD><TD><B>Value</B><BR></TD></TR>
<TR VALIGN=top><TD>
<B>lseek64</B>()
</TD><TD>Thread safety</TD><TD>MT-Safe<BR></TD></TR>
</TABLE>
<A NAME="lbAJ">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?2+llseek">llseek</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+lseek">lseek</A></B>(2)
<A NAME="lbAK">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
<DT id="2"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="3"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DL>
<DT id="4"><A HREF="#lbAE">lseek()</A><DD>
<DT id="5"><A HREF="#lbAF">lseek64()</A><DD>
<DT id="6"><A HREF="#lbAG">llseek()</A><DD>
<DT id="7"><A HREF="#lbAH">_llseek()</A><DD>
</DL>
<DT id="8"><A HREF="#lbAI">ATTRIBUTES</A><DD>
<DT id="9"><A HREF="#lbAJ">SEE ALSO</A><DD>
<DT id="10"><A HREF="#lbAK">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:47 GMT, March 31, 2021
</BODY>
</HTML>