Kernel: mbr: Fix bug when four primary partitions are present (also saves 15 bytes)
authorWill Sowerbutts <will@sowerbutts.com>
Mon, 5 Jan 2015 02:32:24 +0000 (02:32 +0000)
committerWill Sowerbutts <will@sowerbutts.com>
Mon, 5 Jan 2015 02:33:05 +0000 (02:33 +0000)
Kernel/dev/mbr.c

index 3b78c43..37247da 100644 (file)
@@ -23,7 +23,7 @@ typedef struct {
 void mbr_parse(blkdev_t *blk, char letter)
 {
     boot_record_t *br;
-    uint8_t i, maxbr = 50;
+    uint8_t i, seen = 0;
     uint32_t lba = 0, ep_offset = 0, br_offset = 0;
     uint8_t next = 0;
 
@@ -35,10 +35,10 @@ void mbr_parse(blkdev_t *blk, char letter)
            break;
 
        /* avoid an infinite loop where extended boot records form a loop */
-       if(--maxbr == 0)
+       if(seen >= 50)
            break;
 
-       if(next < 4 && lba != 0){ 
+       if(seen == 1){ 
            /* we just loaded the first extended boot record */
            ep_offset = lba;
            next = 4;
@@ -74,6 +74,7 @@ void mbr_parse(blkdev_t *blk, char letter)
                    kprintf("hd%c%d ", letter, next);
            }
        }
+       seen++;
     }while(lba);
 
     if(next >= 4)