Recalculate the partition value for freeldr. Freeldr uses a different partition numbe...
authorHartmut Birr <osexpert@googlemail.com>
Thu, 2 Jan 2003 21:42:56 +0000 (21:42 +0000)
committerHartmut Birr <osexpert@googlemail.com>
Thu, 2 Jan 2003 21:42:56 +0000 (21:42 +0000)
svn path=/trunk/; revision=3923

freeldr/freeldr/reactos/reactos.c

index 55e2ca1..c18535f 100644 (file)
 
 #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);