diff --git a/src/helpers/partutil.c b/src/helpers/partutil.c index 72a8fe3..2804906 100644 --- a/src/helpers/partutil.c +++ b/src/helpers/partutil.c @@ -394,7 +394,7 @@ part_table_parse_bsd (int fd, guint64 offset, guint64 size, int block_size) #define MSDOS_PARTTABLE_OFFSET 0x1be #define MSDOS_SIG_OFF 0x1fe -#if 0 +#if 1 static void hexdump (const guint8 *mem, int size) { @@ -479,7 +479,7 @@ part_table_parse_msdos_extended (int fd, goto out; } - //hexdump (embr, 512); + hexdump (embr, 512); if (memcmp (&embr[MSDOS_SIG_OFF], MSDOS_MAGIC, 2) != 0) { @@ -499,39 +499,48 @@ part_table_parse_msdos_extended (int fd, for (n = 0; n < 2; n++) { PartitionEntry *pe; + PartitionTable* e_part_table; guint64 pstart; guint64 psize; + guint8 ptype; pstart = block_size * ((guint64) get_le32 (&(embr[MSDOS_PARTTABLE_OFFSET + n * 16 + 8]))); psize = block_size * ((guint64) get_le32 (&(embr[MSDOS_PARTTABLE_OFFSET + n * 16 + 12]))); + ptype = embr[MSDOS_PARTTABLE_OFFSET + n * 16 + 4]; + e_part_table = NULL; + + if (5 == ptype) { // 15 == ptype || + DEBUG("Found nested extended partition! Recursing into it"); + e_part_table = part_table_parse_msdos_extended (fd, pstart, psize, block_size); + } if (psize == 0) continue; pe = NULL; - if (n == 0) + if (n == 0 || 5 == ptype) { - //DEBUG ("part %d (offset %lld, size %lld, type 0x%02x)", - // n, readfrom + pstart, psize, ptype)); + DEBUG ("part %d (offset %lld, size %lld, type 0x%02x)", + n, readfrom + pstart, psize, ptype); - //DEBUG ("pstart = %lld", pstart)); + DEBUG ("pstart = %lld", pstart); - //hexdump (&(embr[MSDOS_PARTTABLE_OFFSET + n * 16]), 16); + hexdump (&(embr[MSDOS_PARTTABLE_OFFSET + n * 16]), 16); - pe = part_entry_new (NULL, &(embr[MSDOS_PARTTABLE_OFFSET + n * 16]), 16, readfrom + pe = part_entry_new (e_part_table, &(embr[MSDOS_PARTTABLE_OFFSET + n * 16]), 16, readfrom + MSDOS_PARTTABLE_OFFSET + n * 16); } else { if (pstart != 0) { - //DEBUG ("found chain at offset %lld", offset + pstart); + DEBUG ("found chain at offset %lld", offset + pstart); next = offset + pstart; } } - //DEBUG ("pe = %p", pe)); + DEBUG ("pe = %p", pe); if (pe != NULL) {