From 1043e25b6f3f5f804374e97bd87e1c003d7b92c2 Mon Sep 17 00:00:00 2001 From: Michael Kerrisk Date: Mon, 13 Dec 2004 12:42:20 +0000 Subject: [PATCH] New page from Andries Brouwer --- man3/lseek64.3 | 160 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 man3/lseek64.3 diff --git a/man3/lseek64.3 b/man3/lseek64.3 new file mode 100644 index 000000000..9035c8f1e --- /dev/null +++ b/man3/lseek64.3 @@ -0,0 +1,160 @@ +.\" Copyright 2004 Andries Brouwer . +.\" +.\" Permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" Permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" Since the Linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. The author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. The author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" Formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" +.TH LSEEK64 3 2004-12-11 "Linux" "Linux Programmer's Manual" +.SH NAME +lseek64 \- reposition 64-bit read/write file offset +.SH SYNOPSIS +.B #define _LARGEFILE64_SOURCE +.br +.B #include +.br +.B #include +.sp +.BI "off64_t lseek64(int " fd ", off64_t " offset ", int " whence ); +.SH DESCRIPTION +The +.BR lseek (2) +family functions reposition the offset of the file descriptor +.I fd +to +.I offset +bytes relative to start, current position, or end-of-file of the file, +when +.I whence +has the value +.BR SEEK_SET , +.BR SEEK_CUR , +or +.BR SEEK_END , +respectively. +.LP +For more details, return value, and errors, see +.BR lseek (2). +.PP +Four interfaces are available: +.IR lseek() , +.IR lseek64() , +.IR llseek() , +and the raw system call +.IR _llseek() . +.SS lseek +Prototype: +.nf +.sp +.in +5n +.BI "off_t lseek(int " fd ", off_t " offset ", int " whence ); +.in -5n +.fi +.sp +The library routine +.I lseek() +uses the type +.B off_t +which is a 32-bit signed type on 32-bit architectures, unless one +compiles with +.nf +.sp +.in +5n +#define _FILE_OFFSET_BITS 64 +.in -5n +.sp +.fi +in which case it is a 64-bit signed type. + +.SS lseek64 +Prototype: +.nf +.sp +.in +5n +.BI "off64_t lseek64(int " fd ", off64_t " offset ", int " whence ); +.in -5n +.fi +.sp +The library routine +.I lseek64() +uses a 64-bit type even when +.B off_t +is a 32-bit type. Its prototype (and the type +.BR off64_t ) +is available only when one compiles with +.nf +.sp +.in +5n +#define _LARGEFILE64_SOURCE +.in -5n +.sp +.fi +The function +.I lseek64() +.\" in glibc 2.0.94, not in 2.0.6 +is available since glibc 2.1, and is defined to be an alias of +.IR llseek() . + +.SS llseek +Prototype: +.nf +.sp +.in +5n +.BI "loff_t llseek(int " fd ", loff_t " offset ", int " whence ); +.in -5n +.fi +.sp +The type +.B loff_t +is a 64-bit signed type. +The library routine +.I llseek() +.\" in libc 5.0.9, not in 4.7.6 +is available in libc5 and glibc and works without special defines. +Its prototype was given in +.I +with libc5, but glibc does not provide a prototype. +This is bad, since a prototype is needed. Users should add +the above prototype, or something equivalent, to their own source. +When users complained about data loss caused by a miscompilation of +.BR e2fsck (8), +glibc 2.1.3 added the link-time warning +.sp +.in +5n +"the `llseek' function may be dangerous; use `lseek64' instead." +.in -5b +.sp +This makes this function unusable if one desires a warning-free +compilation. + +.SS _llseek +All the above functions are implemented in terms of the system call. +The prototype is: +.nf +.sp +.in +5n +.BI "int _llseek (int " fd ", off_t " offset_hi ", off_t " offset_lo , +.BI "loff_t *" result ", int " whence ); +.in -5n +.fi +.sp +For more details, see +.BR llseek (2). +.SH "SEE ALSO" +.BR llseek (2), +.BR lseek (2)