Date: Thu, 30 Apr 1998 22:20:09 -0700 (PDT) From: Sean Eric Fagan <sef@kithrup.com> To: hackers@FreeBSD.ORG Subject: Re: how to fseek past 2GB? Message-ID: <199805010520.WAA16794@kithrup.com> In-Reply-To: <19980430222914.A20607.kithrup.freebsd.hackers@emsphone.com> References: <199804300753.AAA00308@usr05.primenet.com>; from "Terry Lambert" on Thu Apr 30 07:53:58 GMT 1998
next in thread | previous in thread | raw e-mail | index | archive | help
In article <19980430222914.A20607.kithrup.freebsd.hackers@emsphone.com> you write:
> For fseek(), the resulting file offset would be a value which
> cannot be represented correctly in an object of type long.
>
>Should I code for this error case, or let fseek hopscotch into the >2GB
>area? Are there any programs that even know it's possible?
Or you could apply these patches which, admittedly, I haven't even compiled
yet ;).
This is approximately what Chris Torek did to do the same thing, he says.
Index: fgetpos.c
===================================================================
RCS file: /usr/cvs/src/lib/libc/stdio/fgetpos.c,v
retrieving revision 1.6
diff -u -r1.6 fgetpos.c
--- fgetpos.c 1998/04/11 07:40:42 1.6
+++ fgetpos.c 1998/05/01 05:17:47
@@ -50,6 +50,7 @@
FILE *fp;
fpos_t *pos;
{
+ extern fpos_t __sftell(FILE*);
int retval;
FLOCKFILE(fp);
retval = (*pos = ftell(fp)) == (fpos_t)-1;
Index: fseek.c
===================================================================
RCS file: /usr/cvs/src/lib/libc/stdio/fseek.c,v
retrieving revision 1.7
diff -u -r1.7 fseek.c
--- fseek.c 1998/04/11 07:40:44 1.7
+++ fseek.c 1998/05/01 05:17:49
@@ -58,9 +58,9 @@
* `Whence' must be one of the three SEEK_* macros.
*/
int
-fseek(fp, offset, whence)
+__sfseek(fp, offset, whence)
register FILE *fp;
- long offset;
+ fpos_t offset;
int whence;
{
register fpos_t (*seekfn) __P((void *, fpos_t, int));
@@ -257,4 +257,13 @@
fp->_flags &= ~__SEOF;
FUNLOCKFILE(fp);
return (0);
+}
+
+int
+fseek(fp, offset, whence)
+ FILE *fp;
+ long offset;
+ int whence;
+{
+ return __sfseek(fp, (fpos_t)offset, whence);
}
Index: fsetpos.c
===================================================================
RCS file: /usr/cvs/src/lib/libc/stdio/fsetpos.c,v
retrieving revision 1.5
diff -u -r1.5 fsetpos.c
--- fsetpos.c 1997/02/22 15:02:06 1.5
+++ fsetpos.c 1998/05/01 05:17:49
@@ -52,5 +52,6 @@
FILE *iop;
const fpos_t *pos;
{
- return (fseek(iop, (long)*pos, SEEK_SET));
+ extern int __sfseek(FILE *, fpos_t, int)
+ return (__sfseek(iop, *pos, SEEK_SET));
}
Index: ftell.c
===================================================================
RCS file: /usr/cvs/src/lib/libc/stdio/ftell.c,v
retrieving revision 1.9
diff -u -r1.9 ftell.c
--- ftell.c 1998/04/11 07:40:44 1.9
+++ ftell.c 1998/05/01 05:17:48
@@ -50,8 +50,8 @@
/*
* ftell: return current offset.
*/
-long
-ftell(fp)
+fpos_t
+__sftell(fp)
register FILE *fp;
{
register fpos_t pos;
@@ -94,4 +94,11 @@
}
FUNLOCKFILE(fp);
return (pos);
+}
+
+long
+ftell(fp)
+ register FILE *fp;
+{
+ return (long)__sftell(fp);
}
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?199805010520.WAA16794>
