Re: Accessing file > 2GB?

Stephen C. Tweedie (sct@redhat.com)
Fri, 30 Oct 1998 13:01:01 GMT


Hi,

On 29 Oct 1998 07:53:30 -0700, glhenni@cs.sandia.gov (Gary L. Hennigan)
said:

> A fellow Debian user managed to create a tar.gz file that is 2.6GB in
> size on a FAT32 partition. Of course now he can't get anything to read
> the thing to extract some data from it. Is there any solution for this
> problem?

No --- the kernel VFS is totally incapable of dealing with files larger
than 2GB (at least on 32-bit architectures). It was a bug to allow such
files to be created in the first place!

The patches below limit fat filesystem writes to 0x7FFFFFFF bytes for
both 2.0.35 and 2.1.127-pre3. Of course, this is a bit late for anyone
who already has a 2.6G file to be recovered...

--Stephen

fat-fbig-2.0.35.diff:
----------------------------------------------------------------
--- fs/fat/file.c~ Tue Jun 23 14:24:52 1998
+++ fs/fat/file.c Fri Oct 30 12:19:52 1998
@@ -324,6 +324,12 @@
#else
if (count <= 0) return 0;
#endif
+ if (filp->f_pos + count > 0x7FFFFFFFLL) {
+ count = 0x7FFFFFFFLL - filp->f_pos;
+ if (!count)
+ return -EFBIG;
+ }
+
error = carry = 0;
for (start = buf; count || carry; count -= size) {
while (!(sector = fat_smap(inode,filp->f_pos >> SECTOR_BITS)))
----------------------------------------------------------------

fat-fbig-2.1.127.diff:
----------------------------------------------------------------
--- fs/fat/file.c~ Mon Aug 24 21:02:44 1998
+++ fs/fat/file.c Fri Oct 30 12:17:22 1998
@@ -375,6 +375,12 @@
*ppos = inode->i_size;
if (count == 0)
return 0;
+ if (*ppos + count > 0x7FFFFFFFLL) {
+ count = 0x7FFFFFFFLL-*ppos;
+ if (!count)
+ return -EFBIG;
+ }
+
error = carry = 0;
for (start = buf; count || carry; count -= size) {
while (!(sector = fat_smap(inode,*ppos >> SECTOR_BITS)))
----------------------------------------------------------------

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/