From 8c7e8c4bbcfdae314c82a743f1539c665368b1d0 Mon Sep 17 00:00:00 2001 From: Hartmut Birr Date: Thu, 2 Jan 2003 21:42:56 +0000 Subject: [PATCH] Recalculate the partition value for freeldr. Freeldr uses a different partition numbering like linux. svn path=/trunk/; revision=3923 --- freeldr/freeldr/reactos/reactos.c | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/freeldr/freeldr/reactos/reactos.c b/freeldr/freeldr/reactos/reactos.c index 55e2ca11f87..c18535f8bcf 100644 --- a/freeldr/freeldr/reactos/reactos.c +++ b/freeldr/freeldr/reactos/reactos.c @@ -36,6 +36,14 @@ #define NDEBUG +#define IsRecognizedPartition(P) \ + ((P) == PARTITION_FAT_12 || \ + (P) == PARTITION_FAT_16 || \ + (P) == PARTITION_HUGE || \ + (P) == PARTITION_IFS || \ + (P) == PARTITION_FAT32 || \ + (P) == PARTITION_FAT32_XINT13 || \ + (P) == PARTITION_XINT13) static BOOL LoadKernel(PCHAR szFileName, int nPos) @@ -442,6 +450,8 @@ LoadAndBootReactOS(PUCHAR OperatingSystemName) char* Base; U32 Size; + PARTITION_TABLE_ENTRY PartitionTableEntry; + U32 rosPartition; // // Open the operating system section @@ -506,6 +516,32 @@ LoadAndBootReactOS(PUCHAR OperatingSystemName) ((char *)(&mb_info.boot_device))[0] = (char)BootDrive; ((char *)(&mb_info.boot_device))[1] = (char)BootPartition; + /* recalculate the boot partition for freeldr */ + i = 0; + rosPartition = 0; + while (1) + { + if (!DiskGetPartitionEntry(BootDrive, ++i, &PartitionTableEntry)) + { + BootPartition = 0; + break; + } + if (IsRecognizedPartition(PartitionTableEntry.SystemIndicator)) + { + if (++rosPartition == BootPartition) + { + BootPartition = i; + break; + } + } + } + if (BootPartition == 0) + { + sprintf(MsgBuffer,"Invalid system path: '%s'", value); + UiMessageBox(MsgBuffer); + return; + } + /* copy ARC path into kernel command line */ strcpy(multiboot_kernel_cmdline, value);