Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Oct 1999 09:53:04 -0500
From:      Dan Nelson <dnelson@emsphone.com>
To:        User Raymond <raymond@one.com.au>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: FreeBSD file size, lseek() etc
Message-ID:  <19991021095304.A87215@dan.emsphone.com>
In-Reply-To: <199910211112.VAA23665@gw.one.com.au>; from raymond@one.com.au on Thu, Oct 21, 1999 at 09:12:43PM %2B1000
References:  <199910211112.VAA23665@gw.one.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19991021095304.A87215>