[syslinux:master] chain: Add DOS partition dumping routine for debugging
syslinux-bot for Shao Miller
shao.miller at yrdsb.edu.on.ca
Fri Jun 25 14:12:22 PDT 2010
Commit-ID: b487ac97cc06d6e44e6dbfcb305114a2b315139a
Gitweb: http://syslinux.zytor.com/commit/b487ac97cc06d6e44e6dbfcb305114a2b315139a
Author: Shao Miller <shao.miller at yrdsb.edu.on.ca>
AuthorDate: Wed, 23 Jun 2010 00:23:30 -0400
Committer: Shao Miller <shao.miller at yrdsb.edu.on.ca>
CommitDate: Wed, 23 Jun 2010 00:23:30 -0400
chain: Add DOS partition dumping routine for debugging
Signed-off-by: Shao Miller <shao.miller at yrdsb.edu.on.ca>
---
com32/modules/chain.c | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/com32/modules/chain.c b/com32/modules/chain.c
index d7c6a1c..d5bf4f0 100644
--- a/com32/modules/chain.c
+++ b/com32/modules/chain.c
@@ -81,6 +81,8 @@
* FAT/NTFS boot sector.
*/
+#define DEBUG 0 /* 1 to enable */
+
#include <com32.h>
#include <stdlib.h>
#include <stdio.h>
@@ -364,6 +366,33 @@ struct part_entry {
uint32_t length;
} __attribute__ ((packed));
+#if DEBUG
+static void mbr_part_dump(const struct part_entry *part)
+{
+ printf("-------------------------------\n"
+ "Partition status _____ : 0x%.2x\n"
+ "Partition CHS start\n"
+ " Cylinder ___________ : 0x%.4x\n"
+ " Head _______________ : 0x%.2x\n"
+ " Sector _____________ : 0x%.2x\n"
+ "Partition type _______ : 0x%.2x\n"
+ "Partition CHS end\n"
+ " Cylinder ___________ : 0x%.4x\n"
+ " Head _______________ : 0x%.2x\n"
+ " Sector _____________ : 0x%.2x\n"
+ "Partition LBA start __ : 0x%.16x\n"
+ "Partition LBA count __ : 0x%.16x\n",
+ part->active_flag,
+ chs_cylinder(part->start),
+ chs_head(part->start),
+ chs_sector(part->start),
+ part->ostype,
+ chs_cylinder(part->end),
+ chs_head(part->end),
+ chs_sector(part->end), part->start_lba, part->length);
+}
+#endif
+
/* A DOS MBR */
struct mbr {
char code[440];
@@ -446,6 +475,10 @@ static struct part_entry *find_logical_partition(int whichpart, struct mbr *br,
ptab[i].start_lba >= root->start_lba + root->length)
continue;
+#if DEBUG
+ mbr_part_dump(ptab + i);
+#endif
+
/* OK, it's a data partition. Is it the one we're looking for? */
if (nextpart++ == whichpart) {
memcpy(<ab_entry, &ptab[i], sizeof ltab_entry);
More information about the Syslinux-commits
mailing list