From owner-freebsd-questions Thu Oct 21 7:53:22 1999 Delivered-To: freebsd-questions@freebsd.org Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by hub.freebsd.org (Postfix) with ESMTP id A6B4614D01 for ; Thu, 21 Oct 1999 07:53:18 -0700 (PDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.9.3/8.9.3) id JAA87613; Thu, 21 Oct 1999 09:53:04 -0500 (CDT) (envelope-from dan) Date: Thu, 21 Oct 1999 09:53:04 -0500 From: Dan Nelson To: User Raymond Cc: freebsd-questions@freebsd.org Subject: Re: FreeBSD file size, lseek() etc Message-ID: <19991021095304.A87215@dan.emsphone.com> References: <199910211112.VAA23665@gw.one.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre4i In-Reply-To: <199910211112.VAA23665@gw.one.com.au>; from raymond@one.com.au on Thu, Oct 21, 1999 at 09:12:43PM +1000 X-OS: FreeBSD 4.0-CURRENT Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In the last episode (Oct 21), User Raymond said: > We are trying to construct a file that is larger than the basic 2GB > allowed by lseek(). I am sure I have seen some discussion on this > somewhere but I've forgotten where... huh? lseek() has no 2gb restrictions at all. Under 2.2.* this was the only way to seek to files over 2gb. You must be thinking of fseek(), which is limited to 2gb becuase of its "int whence" prototype. lseek() takes an off_t which is a 64-bit type. > So these questions. > > 1. Does FreeBSD support file sizes greater than 2GB? Yes. > 2. If so is there another way (other than lseek()) to address them? Yes. Unser 3.2 and higher you can use fseeko() (which has an off_t whence) to access a FILE * past the 2gb point. > 3. If not, will multiple calls to lseek() with whence = SEEK_CUR > work or will the internal pointer wrap? Again, you must be thinking of fseek(), and no, this won't work becuase fseek() internally converts SEEK_CUR to a SEEK_SET after first determining the current file offset (and storing it in an int, thus wrapping at the 2gb point). So. bottom line: lseek() works past 2gb on all versions. If you need to seek a stdio FILE *, you need fseeko(), which appeared in 3.2. If you have an earlier version of FreeBSD that you need fseeko() on, I can send you patches for it. -- Dan Nelson dnelson@emsphone.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message