Date: Thu, 30 Apr 1998 07:53:58 +0000 (GMT) From: Terry Lambert <tlambert@primenet.com> To: dnelson@emsphone.com (Dan Nelson) Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: how to fseek past 2GB? Message-ID: <199804300753.AAA00308@usr05.primenet.com> In-Reply-To: <19980429150055.A17639@emsphone.com> from "Dan Nelson" at Apr 29, 98 03:00:55 pm
next in thread | previous in thread | raw e-mail | index | archive | help
> I recently noticed that there is no way to fseek() past the 2GB mark on
> files opened with fopen(). The offset in the FILE struct is an fpos_t;
> there's just no way to get at it.
Heh.
...
fseek( fp, 1<<30, SEEK_SET); /* first 2G*/
fseek( fp, 1<<30, SEEK_CUR); /* next 2G*/
fseek( fp, 1, SEEK_END); /* last byte*/
...
It'd be easy to wrap this. 8-).
For a more FreeBSD-specific workaround:
off_t
lfseek( FILE *fp, off_t offset, int whence)
{
off_t new;
fp->_flags &= ~__SOFF; /* invalidate offset cache*/
new = lseek( fileno(fp), offset, whence);
fseek( fp, 0, SEEK_CUR);
return( new);
}
On your patches: I think there are standard names for the functions
you implemented, so they should probably be rolled in. But the
workarounds should work for 2.2.6 people.
Terry Lambert
terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199804300753.AAA00308>
