From 842bf96e2cbfa5e377a404bc73dd2eb097bb3bf4 Mon Sep 17 00:00:00 2001 From: Conrad Pankoff Date: Sat, 8 Jun 2019 18:31:36 +1000 Subject: [PATCH] Kernel: Fix booting from "inactive" MBR partitions Apparently you can boot from any MBR partition, not just the one labeled as "bootable" or "active". The only ones you don't want to boot from are the ones that don't exist. --- Kernel/Devices/MBRPartitionTable.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Kernel/Devices/MBRPartitionTable.cpp b/Kernel/Devices/MBRPartitionTable.cpp index 369be452e1..b194855b3e 100644 --- a/Kernel/Devices/MBRPartitionTable.cpp +++ b/Kernel/Devices/MBRPartitionTable.cpp @@ -53,9 +53,17 @@ RetainPtr MBRPartitionTable::partition(unsigned index) kprintf("MBRPartitionTable::partition: status=%#x offset=%#x\n", entry.status, entry.offset); #endif - if (entry.status == 0x00) { + if (entry.offset == 0x00) { +#ifdef MBR_DEBUG + kprintf("MBRPartitionTable::partition: missing partition requested index=%d\n", index); +#endif + return nullptr; } +#ifdef MBR_DEBUG + kprintf("MBRPartitionTable::partition: found partition index=%d type=%x\n", index, entry.type); +#endif + return DiskPartition::create(m_device.copy_ref(), entry.offset); }