Hi,

Ok, I fix some bugs, please see if the new patch works.

-- 
Bean
diff --git a/fs/ext2.c b/fs/ext2.c
index ffe9e33..4d1e3e1 100644
--- a/fs/ext2.c
+++ b/fs/ext2.c
@@ -443,20 +443,25 @@ grub_ext3_get_journal (struct grub_ext2_data *data)
   log->last_block = grub_be_to_cpu32 (jsb->maxlen);
   log->start_block = grub_be_to_cpu32 (jsb->start);
 
+  grub_printf ("header: %d %d %d\n", log->first_block, log->last_block, log->start_block);
+
   last_num = num = 0;
   block = log->start_block;
   seq = grub_be_to_cpu32 (jsb->sequence);
+  grub_printf ("seq: %d\n", seq);
 
   while (1)
     {
       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_printf ("block: %d\n", block);
+
+      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];
@@ -476,6 +481,7 @@ grub_ext3_get_journal (struct grub_ext2_data *data)
             struct grub_ext3_journal_block_tag *tag;
             int ofs, flags;
 
+            grub_printf ("dblock: ");
             ofs = sizeof (struct grub_ext3_journal_header);
 
             do
@@ -491,15 +497,19 @@ grub_ext3_get_journal (struct grub_ext2_data *data)
                   ofs += 16;
 
                 log->mapping[num++] = grub_be_to_cpu32 (tag->block);
+                grub_printf ("%d ", grub_be_to_cpu32 (tag->block));
                 next_block();
               }
             while (! (flags & EXT3_JOURNAL_FLAG_LAST_TAG));
 
+            grub_printf ("\n");
+
             continue;
           }
 
         case EXT3_JOURNAL_COMMIT_BLOCK:
           {
+            grub_printf ("cblock: %d\n", seq);
             seq++;
             last_num = num - 1;
             continue;
@@ -508,21 +518,24 @@ 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;
 
                 map = grub_be_to_cpu32 (jrh->data[i]);
+                grub_printf ("%d ", map);
                 for (j = 0; j < num; j++)
                   if (log->mapping[j] == map)
                     log->mapping[j] = GRUB_FSHELP_JOURNAL_UNUSED_MAPPING;
               }
-
+            grub_printf ("\n");
             continue;
           }
         default:
@@ -538,6 +551,7 @@ quit:
     {
       int size;
 
+      grub_printf ("num: %d\n", last_num);
       size = sizeof (struct grub_fshelp_journal) +
             last_num * sizeof (grub_disk_addr_t);
 
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to