bug-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

incorrect handling of holes in ext2 files


From: Michael Hohnbaum
Subject: incorrect handling of holes in ext2 files
Date: Thu, 05 Aug 2004 14:41:57 -0700

Grub is not correctly handling holes in files in ext2 filesystems.
The current code in stage2/fsys_ext2fs.c does not check upon
return from ext2fs_block_map() if a zero was returned.  Rather,
it happily reads in block zero from the filesystem.  Most of
the time this works alright as block 0 tends to be sparsely
populated.  However, it does not contain all zeroes and the 
extra bits can lead to problems.  

This problem goes away with reiserfs.  I've not tried other filesystems.

I've ran into this problem on multiple machines with various versions
of Linux including:
  P3 based machines with RedHat 8, SuSE SLES 9, Fedora Core 1
  P4 based machine with Debian
  Athlon64 machine with Fedora Core 2

Grub versions have included 0.92 and 0.95.

The following patch against 0.95 solves this problem.  Any chance this,
or something similar can be applied for the next release?

--- grub-0.95.orig/stage2/fsys_ext2fs.c 2003-12-30 04:34:03.000000000
-0800
+++ grub-0.95/stage2/fsys_ext2fs.c      2004-08-05 13:37:07.000000000
-0700
@@ -432,12 +432,16 @@
       if (size > len)
        size = len;

-      disk_read_func = disk_read_hook;
+      if ( map == 0 ) {
+       memset ((char *) buf, 0, size);
+      } else {
+       disk_read_func = disk_read_hook;

-      devread (map * (EXT2_BLOCK_SIZE (SUPERBLOCK) / DEV_BSIZE),
+       devread (map * (EXT2_BLOCK_SIZE (SUPERBLOCK) / DEV_BSIZE),
               offset, size, buf);

-      disk_read_func = NULL;
+       disk_read_func = NULL;
+      }

       buf += size;
       len -= size;


-- 

Michael Hohnbaum                      503-578-5486
address@hidden                   T/L 775-5486






reply via email to

[Prev in Thread] Current Thread [Next in Thread]