]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2008-06-13 Bean <bean123ch@gmail.com>
authorbean <bean@localhost>
Fri, 13 Jun 2008 06:47:46 +0000 (06:47 +0000)
committerbean <bean@localhost>
Fri, 13 Jun 2008 06:47:46 +0000 (06:47 +0000)
* commands/hexdump.c (grub_cmd_hexdump): Adjust offset for partition.

* fs/ext2.c (grub_ext3_get_journal): Fix revoke block handling.

* fs/fshelp.c (grub_fshelp_map_block): Don't map block 0 as it's used
to indicate sparse block.

ChangeLog
commands/hexdump.c
fs/ext2.c
fs/fshelp.c

index 9cc6165480ae8b344387fe462b6ebcbcdb3bdca0..22beade10afde948d889b3dd8fcf0cdb098f96a5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-06-13  Bean  <bean123ch@gmail.com>
+
+       * commands/hexdump.c (grub_cmd_hexdump): Adjust offset for partition.
+
+       * fs/ext2.c (grub_ext3_get_journal): Fix revoke block handling.
+
+       * fs/fshelp.c (grub_fshelp_map_block): Don't map block 0 as it's used
+       to indicate sparse block.
+
 2008-06-12  Pavel Roskin  <proski@gnu.org>
 
        * fs/ext2.c (grub_ext2_read_inode): Don't normalize block
index 6d97fe4fe6b928ce07dd7ebe0e95cc4025e6db17..c9aa441e1c77e2a4bf571e008f03c336fb3f4cdc 100644 (file)
@@ -25,6 +25,7 @@
 #include <grub/misc.h>
 #include <grub/gzio.h>
 #include <grub/hexdump.h>
+#include <grub/partition.h>
 
 static const struct grub_arg_option options[] = {
   {"skip", 's', 0, "skip offset bytes from the beginning of file.", 0,
@@ -84,7 +85,7 @@ grub_cmd_hexdump (struct grub_arg_list *state, int argc, char **args)
 {
   char buf[GRUB_DISK_SECTOR_SIZE * 4];
   grub_ssize_t size, length;
-  unsigned long skip;
+  grub_disk_addr_t skip;
   int namelen;
 
   if (argc != 1)
@@ -107,6 +108,9 @@ grub_cmd_hexdump (struct grub_arg_list *state, int argc, char **args)
       if (! disk)
         return 0;
 
+      if (disk->partition)
+        skip += grub_partition_get_start (disk->partition) << GRUB_DISK_SECTOR_BITS;
+
       sector = (skip >> (GRUB_DISK_SECTOR_BITS + 2)) * 4;
       ofs = skip & (GRUB_DISK_SECTOR_SIZE * 4 - 1);
       while (length)
index 3768a816eb2b156d77c8a982628daa0617ce4884..184b973ce8b13218cac4711706f0157cd1442c93 100644 (file)
--- a/fs/ext2.c
+++ b/fs/ext2.c
@@ -436,12 +436,12 @@ grub_ext3_get_journal (struct grub_ext2_data *data)
     {
       struct grub_ext3_journal_header *jh;
 
-      if (grub_fshelp_read_file (data->disk, &data->logfile, 0,
-                                 block << (log2bs + 9), sizeof (buf),
-                                 buf, grub_ext2_read_block,
-                                 log->last_block << (log2bs + 9),
-                                 log2bs) !=
-          (int) sizeof (buf))
+      grub_fshelp_read_file (data->disk, &data->logfile, 0,
+                             block << (log2bs + 9), sizeof (buf),
+                             buf, grub_ext2_read_block,
+                             log->last_block << (log2bs + 9),
+                             log2bs);
+      if (grub_errno)
         break;
 
       jh = (struct grub_ext3_journal_header *) &buf[0];
@@ -493,11 +493,13 @@ grub_ext3_get_journal (struct grub_ext2_data *data)
         case EXT3_JOURNAL_REVOKE_BLOCK:
           {
             struct grub_ext3_journal_revoke_header *jrh;
-            grub_uint32_t i;
+            grub_uint32_t i, cnt;
 
             jrh = (struct grub_ext3_journal_revoke_header *) jh;
+            cnt = (grub_be_to_cpu32 (jrh->count) -
+                   sizeof (struct grub_ext3_journal_revoke_header)) >> 2;
 
-            for (i = 0; i < grub_be_to_cpu32 (jrh->count); i++)
+            for (i = 0; i < cnt; i++)
               {
                 int j;
                 grub_uint32_t map;
index 52131b019ddced427a397dfe015708ab7a636e0a..2fae065c8e162f44efbb8b00d74ff82d605a515d 100644 (file)
@@ -356,7 +356,7 @@ grub_fshelp_map_block (grub_fshelp_journal_t log, grub_disk_addr_t block)
 {
   int map_block;
 
-  if (! log)
+  if ((! log) || (! block))
     return block;
 
   for (map_block = log->num_mappings - 1; map_block >= 0; map_block--)