chain.c32, libcom32: Move mbr_part_dump() as disk_dos_part_dump()
authorShao Miller <shao.miller@yrdsb.edu.on.ca>
Mon, 28 Jun 2010 06:54:36 +0000 (02:54 -0400)
committerShao Miller <shao.miller@yrdsb.edu.on.ca>
Sat, 10 Jul 2010 05:03:06 +0000 (01:03 -0400)
Moving portions of chain.c32 into libcom32.

Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
com32/include/syslinux/disk.h
com32/lib/syslinux/disk.c
com32/modules/chain.c

index 79adae5..6e213c5 100644 (file)
@@ -86,5 +86,6 @@ extern int disk_write_sector(const struct disk_info *const diskinfo,
                             unsigned int lba, const void *data);
 extern int disk_write_verify_sector(const struct disk_info *const diskinfo,
                                    unsigned int lba, const void *buf);
+extern void disk_dos_part_dump(const struct disk_dos_part_entry *const part);
 
 #endif /* _SYSLINUX_DISK_H */
index 3b23fef..b702207 100644 (file)
@@ -33,6 +33,7 @@
  * Deal with disks and partitions
  */
 
+#include <dprintf.h>
 #include <stdlib.h>
 #include <string.h>
 #include <syslinux/disk.h>
@@ -284,3 +285,41 @@ int disk_write_verify_sector(const struct disk_info *const diskinfo,
     free(rb);
     return rv ? -1 : 0;
 }
+
+/**
+ * Dump info about a DOS partition entry
+ *
+ * @v part                     The 16-byte partition entry to examine
+ */
+void disk_dos_part_dump(const struct disk_dos_part_entry *const part)
+{
+    (void)part;
+    dprintf("Partition status _____ : 0x%.2x\n"
+           "Partition CHS start\n"
+           "  Cylinder ___________ : 0x%.4x (%u)\n"
+           "  Head _______________ : 0x%.2x (%u)\n"
+           "  Sector _____________ : 0x%.2x (%u)\n"
+           "Partition type _______ : 0x%.2x\n"
+           "Partition CHS end\n"
+           "  Cylinder ___________ : 0x%.4x (%u)\n"
+           "  Head _______________ : 0x%.2x (%u)\n"
+           "  Sector _____________ : 0x%.2x (%u)\n"
+           "Partition LBA start __ : 0x%.8x (%u)\n"
+           "Partition LBA count __ : 0x%.8x (%u)\n"
+           "-------------------------------\n",
+           part->active_flag,
+           chs_cylinder(part->start),
+           chs_cylinder(part->start),
+           chs_head(part->start),
+           chs_head(part->start),
+           chs_sector(part->start),
+           chs_sector(part->start),
+           part->ostype,
+           chs_cylinder(part->end),
+           chs_cylinder(part->end),
+           chs_head(part->end),
+           chs_head(part->end),
+           chs_sector(part->end),
+           chs_sector(part->end),
+           part->start_lba, part->start_lba, part->length, part->length);
+}
index fd5cb66..04b1560 100644 (file)
@@ -147,39 +147,6 @@ static inline void error(const char *msg)
 
 static struct disk_info diskinfo;
 
-static void mbr_part_dump(const struct disk_dos_part_entry *part)
-{
-    (void)part;
-    dprintf("Partition status _____ : 0x%.2x\n"
-           "Partition CHS start\n"
-           "  Cylinder ___________ : 0x%.4x (%u)\n"
-           "  Head _______________ : 0x%.2x (%u)\n"
-           "  Sector _____________ : 0x%.2x (%u)\n"
-           "Partition type _______ : 0x%.2x\n"
-           "Partition CHS end\n"
-           "  Cylinder ___________ : 0x%.4x (%u)\n"
-           "  Head _______________ : 0x%.2x (%u)\n"
-           "  Sector _____________ : 0x%.2x (%u)\n"
-           "Partition LBA start __ : 0x%.8x (%u)\n"
-           "Partition LBA count __ : 0x%.8x (%u)\n"
-           "-------------------------------\n",
-           part->active_flag,
-           chs_cylinder(part->start),
-           chs_cylinder(part->start),
-           chs_head(part->start),
-           chs_head(part->start),
-           chs_sector(part->start),
-           chs_sector(part->start),
-           part->ostype,
-           chs_cylinder(part->end),
-           chs_cylinder(part->end),
-           chs_head(part->end),
-           chs_head(part->end),
-           chs_sector(part->end),
-           chs_sector(part->end),
-           part->start_lba, part->start_lba, part->length, part->length);
-}
-
 /* A DOS MBR */
 struct mbr {
     char code[440];
@@ -296,7 +263,7 @@ static struct disk_part_iter *next_ebr_part(struct disk_part_iter *part)
     }
     ebr_table = ((const struct mbr *)part->block)->table;
     dprintf("next_ebr_part:\n");
-    mbr_part_dump(ebr_table);
+    disk_dos_part_dump(ebr_table);
 
     /*
      * Sanity check entry: must not extend outside the
@@ -373,7 +340,7 @@ static struct disk_part_iter *next_mbr_part(struct disk_part_iter *part)
        return next_ebr_part(ebr_part);
     }
     dprintf("next_mbr_part:\n");
-    mbr_part_dump(table + part->private.mbr_index);
+    disk_dos_part_dump(table + part->private.mbr_index);
 
     /* Update parameters to reflect this new partition.  Re-use iterator */
     part->lba_data = table[part->private.mbr_index].start_lba;
@@ -1550,7 +1517,7 @@ int main(int argc, char *argv[])
            regs.esi.w[0] = 0x7be;
 
            dprintf("GPT handover:\n");
-           mbr_part_dump(record);
+           disk_dos_part_dump(record);
            gpt_part_dump((struct gpt_part *)(plen + 1));
        } else if (cur_part->record) {
            /* MBR handover protocol */
@@ -1566,7 +1533,7 @@ int main(int argc, char *argv[])
            regs.esi.w[0] = 0x7be;
 
            dprintf("MBR handover:\n");
-           mbr_part_dump(&handover_record);
+           disk_dos_part_dump(&handover_record);
        }
     }