Skip to contentSkip to conversation

Fix hexdump not to duplicate code with kern/partition.c

PATCH In review Vladimir 'phcoder' Serbinenko 2 participants 2 messages Jul 31, 2009 – Aug 2, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix hexdump not to duplicate code with kern/partition.c

Splitted from nested partition patch

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
ChangeLog +5 -0
index e553828..e987af6 100644
@@ -1,3 +1,8 @@
+2009-06-08  Vladimir Serbinenko  <[email protected]>
+
+	* commands/hexdump.c (grub_cmd_hexdump): Use grub_disk_read instead
+	of homegrown code.
+
 2009-07-31  Vladimir Serbinenko  <[email protected]>
 
 	* partmap/pc.c (pc_partition_map_iterate): Check that boot flags are
commands/hexdump.c +5 -11
index 0e560c0..f59ba36 100644
@@ -22,7 +22,6 @@
 #include <grub/disk.h>
 #include <grub/misc.h>
 #include <grub/gzio.h>
-#include <grub/partition.h>
 #include <grub/lib/hexdump.h>
 #include <grub/extcmd.h>
 
@@ -62,25 +61,20 @@ grub_cmd_hexdump (grub_extcmd_t cmd, 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)
         {
-          grub_size_t len, n;
+          grub_size_t len;
 
           len = length;
-          if (ofs + len > sizeof (buf))
-            len = sizeof (buf) - ofs;
+          if (len > sizeof (buf))
+            len = sizeof (buf);
 
-          n = ((ofs + len + GRUB_DISK_SECTOR_SIZE - 1)
-               >> GRUB_DISK_SECTOR_BITS);
-          if (disk->dev->read (disk, sector, n, buf))
+          if (grub_disk_read (disk, sector, ofs, len, buf))
             break;
 
-          hexdump (skip, &buf[ofs], len);
+          hexdump (skip, buf, len);
 
           ofs = 0;
           skip += len;
#1 lore raw
Quoted 13 lines · Vladimir 'phcoder' Serbinenko

Splitted from nested partition patch

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
ChangeLog +0 -0
index e553828..e987af6 100644

ChangeLog line 5

Quoted 5 lines
ChangeLog +5 -0
@@ -1,3 +1,8 @@
+2009-06-08  Vladimir Serbinenko  <[email protected]>
+
+	* commands/hexdump.c (grub_cmd_hexdump): Use grub_disk_read instead
+	of homegrown code.
+

Hi,

Looks good, but I haven't tried it. Assuming you've tested it and also builds warning-free, I'm fine with it.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."