From fbd73e2e9e6641fcc5edbfe6f835f71c573f3f94 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Thu, 9 Apr 2009 12:42:09 +0000 Subject: [PATCH] - Recognize up to 4 partitions inside every primary partition table. However, installation will be performed to the first partition anyway. svn path=/trunk/; revision=40428 --- reactos/base/setup/usetup/partlist.c | 129 ++++++++++++++++++++++----- reactos/base/setup/usetup/partlist.h | 1 + 2 files changed, 109 insertions(+), 21 deletions(-) diff --git a/reactos/base/setup/usetup/partlist.c b/reactos/base/setup/usetup/partlist.c index 5335f9bbdc8..ff921cc6bf9 100644 --- a/reactos/base/setup/usetup/partlist.c +++ b/reactos/base/setup/usetup/partlist.c @@ -928,6 +928,7 @@ CreatePartitionList (SHORT Left, List->CurrentDisk = NULL; List->CurrentPartition = NULL; + List->CurrentPartitionNumber = 0; InitializeListHead (&List->DiskListHead); InitializeListHead (&List->BiosDiskListHead); @@ -984,6 +985,7 @@ CreatePartitionList (SHORT Left, { List->CurrentDisk = NULL; List->CurrentPartition = NULL; + List->CurrentPartitionNumber = 0; } else { @@ -995,6 +997,7 @@ CreatePartitionList (SHORT Left, if (IsListEmpty (&List->CurrentDisk->PartListHead)) { List->CurrentPartition = 0; + List->CurrentPartitionNumber = 0; } else { @@ -1002,6 +1005,7 @@ CreatePartitionList (SHORT Left, CONTAINING_RECORD (List->CurrentDisk->PartListHead.Flink, PARTENTRY, ListEntry); + List->CurrentPartitionNumber = 0; } } @@ -1091,7 +1095,8 @@ PrintEmptyLine (PPARTLIST List) static VOID PrintPartitionData (PPARTLIST List, PDISKENTRY DiskEntry, - PPARTENTRY PartEntry) + PPARTENTRY PartEntry, + ULONG PartNumber) { CHAR LineBuffer[128]; COORD coPos; @@ -1147,44 +1152,44 @@ PrintPartitionData (PPARTLIST List, } else if (PartEntry->Unpartitioned == FALSE) { - if ((PartEntry->PartInfo[0].PartitionType == PARTITION_FAT_12) || - (PartEntry->PartInfo[0].PartitionType == PARTITION_FAT_16) || - (PartEntry->PartInfo[0].PartitionType == PARTITION_HUGE) || - (PartEntry->PartInfo[0].PartitionType == PARTITION_XINT13)) + if ((PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_FAT_12) || + (PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_FAT_16) || + (PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_HUGE) || + (PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_XINT13)) { PartType = "FAT"; } - else if ((PartEntry->PartInfo[0].PartitionType == PARTITION_FAT32) || - (PartEntry->PartInfo[0].PartitionType == PARTITION_FAT32_XINT13)) + else if ((PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_FAT32) || + (PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_FAT32_XINT13)) { PartType = "FAT32"; } - else if (PartEntry->PartInfo[0].PartitionType == PARTITION_EXT2) + else if (PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_EXT2) { PartType = "EXT2"; } - else if (PartEntry->PartInfo[0].PartitionType == PARTITION_IFS) + else if (PartEntry->PartInfo[PartNumber].PartitionType == PARTITION_IFS) { PartType = "NTFS"; /* FIXME: Not quite correct! */ } } #if 0 - if (PartEntry->PartInfo[0].PartitionLength.QuadPart >= 0x280000000LL) /* 10 GB */ + if (PartEntry->PartInfo[PartNumber].PartitionLength.QuadPart >= 0x280000000LL) /* 10 GB */ { - PartSize.QuadPart = (PartEntry->PartInfo[0].PartitionLength.QuadPart + (1 << 29)) >> 30; + PartSize.QuadPart = (PartEntry->PartInfo[PartNumber].PartitionLength.QuadPart + (1 << 29)) >> 30; Unit = MUIGetString(STRING_GB); } else #endif - if (PartEntry->PartInfo[0].PartitionLength.QuadPart >= 0xA00000LL) /* 10 MB */ + if (PartEntry->PartInfo[PartNumber].PartitionLength.QuadPart >= 0xA00000LL) /* 10 MB */ { - PartSize.QuadPart = (PartEntry->PartInfo[0].PartitionLength.QuadPart + (1 << 19)) >> 20; + PartSize.QuadPart = (PartEntry->PartInfo[PartNumber].PartitionLength.QuadPart + (1 << 19)) >> 20; Unit = MUIGetString(STRING_MB); } else { - PartSize.QuadPart = (PartEntry->PartInfo[0].PartitionLength.QuadPart + (1 << 9)) >> 10; + PartSize.QuadPart = (PartEntry->PartInfo[PartNumber].PartitionLength.QuadPart + (1 << 9)) >> 10; Unit = MUIGetString(STRING_KB); } @@ -1194,7 +1199,7 @@ PrintPartitionData (PPARTLIST List, MUIGetString(STRING_HDDINFOUNK5), (PartEntry->DriveLetter == 0) ? '-' : PartEntry->DriveLetter, (PartEntry->DriveLetter == 0) ? '-' : ':', - PartEntry->PartInfo[0].PartitionType, + PartEntry->PartInfo[PartNumber].PartitionType, PartSize.u.LowPart, Unit); } @@ -1211,7 +1216,8 @@ PrintPartitionData (PPARTLIST List, } Attribute = (List->CurrentDisk == DiskEntry && - List->CurrentPartition == PartEntry) ? + List->CurrentPartition == PartEntry && + List->CurrentPartitionNumber == PartNumber) ? FOREGROUND_BLUE | BACKGROUND_WHITE : FOREGROUND_WHITE | BACKGROUND_BLUE; @@ -1259,6 +1265,7 @@ PrintDiskData (PPARTLIST List, USHORT Height; ULARGE_INTEGER DiskSize; PCHAR Unit; + ULONG i; Width = List->Right - List->Left - 1; Height = List->Bottom - List->Top - 2; @@ -1338,9 +1345,16 @@ PrintDiskData (PPARTLIST List, LIST_FOR_EACH(PartEntry, &DiskEntry->PartListHead, PARTENTRY, ListEntry) { /* Print disk entry */ - PrintPartitionData (List, - DiskEntry, - PartEntry); + for (i=0; i<4; i++) + { + if (PartEntry->PartInfo[i].PartitionType != PARTITION_ENTRY_UNUSED) + { + PrintPartitionData (List, + DiskEntry, + PartEntry, + i); + } + } } /* Print separator line */ @@ -1589,6 +1603,7 @@ SelectPartition(PPARTLIST List, ULONG DiskNumber, ULONG PartitionNumber) { List->CurrentDisk = DiskEntry; List->CurrentPartition = PartEntry; + List->CurrentPartitionNumber = i; DrawPartitionList (List); return TRUE; } @@ -1610,6 +1625,7 @@ ScrollDownPartitionList (PPARTLIST List) PPARTENTRY PartEntry; PLIST_ENTRY Entry1; PLIST_ENTRY Entry2; + UCHAR i; /* Check for empty disks */ if (IsListEmpty (&List->DiskListHead)) @@ -1618,7 +1634,30 @@ ScrollDownPartitionList (PPARTLIST List) /* Check for next usable entry on current disk */ if (List->CurrentPartition != NULL) { - Entry2 = List->CurrentPartition->ListEntry.Flink; + Entry2 = &List->CurrentPartition->ListEntry; + PartEntry = CONTAINING_RECORD (Entry2, PARTENTRY, ListEntry); + + /* Check if we can move inside primary partitions */ + for (i = List->CurrentPartitionNumber + 1; i < 4; i++) + { + if (PartEntry->PartInfo[i].PartitionType != PARTITION_ENTRY_UNUSED) + break; + } + + if (i == 4) + { + /* We're out of partitions in the current partition table. + Try to move to the next one if possible. */ + Entry2 = Entry2->Flink; + } + else + { + /* Just advance to the next partition */ + List->CurrentPartitionNumber = i; + DrawPartitionList (List); + return; + } + while (Entry2 != &List->CurrentDisk->PartListHead) { PartEntry = CONTAINING_RECORD (Entry2, PARTENTRY, ListEntry); @@ -1626,6 +1665,7 @@ ScrollDownPartitionList (PPARTLIST List) // if (PartEntry->HidePartEntry == FALSE) { List->CurrentPartition = PartEntry; + List->CurrentPartitionNumber = 0; DrawPartitionList (List); return; } @@ -1650,6 +1690,7 @@ ScrollDownPartitionList (PPARTLIST List) { List->CurrentDisk = DiskEntry; List->CurrentPartition = PartEntry; + List->CurrentPartitionNumber = 0; DrawPartitionList (List); return; } @@ -1670,6 +1711,7 @@ ScrollUpPartitionList (PPARTLIST List) PPARTENTRY PartEntry; PLIST_ENTRY Entry1; PLIST_ENTRY Entry2; + UCHAR i; /* Check for empty disks */ if (IsListEmpty (&List->DiskListHead)) @@ -1678,7 +1720,28 @@ ScrollUpPartitionList (PPARTLIST List) /* check for previous usable entry on current disk */ if (List->CurrentPartition != NULL) { - Entry2 = List->CurrentPartition->ListEntry.Blink; + Entry2 = &List->CurrentPartition->ListEntry; + PartEntry = CONTAINING_RECORD (Entry2, PARTENTRY, ListEntry); + + /* Check if we can move inside primary partitions */ + if (List->CurrentPartitionNumber > 0) + { + /* Find a previous partition */ + for (i = List->CurrentPartitionNumber - 1; i > 0; i--) + { + if (PartEntry->PartInfo[i].PartitionType != PARTITION_ENTRY_UNUSED) + break; + } + + /* Move to it and return */ + List->CurrentPartitionNumber = i; + DrawPartitionList (List); + return; + } + + /* Move to the previous entry */ + Entry2 = Entry2->Blink; + while (Entry2 != &List->CurrentDisk->PartListHead) { PartEntry = CONTAINING_RECORD (Entry2, PARTENTRY, ListEntry); @@ -1686,6 +1749,18 @@ ScrollUpPartitionList (PPARTLIST List) // if (PartEntry->HidePartEntry == FALSE) { List->CurrentPartition = PartEntry; + + /* Find last existing partition in the table */ + for (i = 3; i > 0; i--) + { + if (PartEntry->PartInfo[i].PartitionType != PARTITION_ENTRY_UNUSED) + break; + } + + /* Move to it */ + List->CurrentPartitionNumber = i; + + /* Draw partition list and return */ DrawPartitionList (List); return; } @@ -1711,6 +1786,18 @@ ScrollUpPartitionList (PPARTLIST List) { List->CurrentDisk = DiskEntry; List->CurrentPartition = PartEntry; + + /* Find last existing partition in the table */ + for (i = 3; i > 0; i--) + { + if (PartEntry->PartInfo[i].PartitionType != PARTITION_ENTRY_UNUSED) + break; + } + + /* Move to it */ + List->CurrentPartitionNumber = i; + + /* Draw partition list and return */ DrawPartitionList (List); return; } diff --git a/reactos/base/setup/usetup/partlist.h b/reactos/base/setup/usetup/partlist.h index 05e2bd60fa3..9264b256eb7 100644 --- a/reactos/base/setup/usetup/partlist.h +++ b/reactos/base/setup/usetup/partlist.h @@ -132,6 +132,7 @@ typedef struct _PARTLIST PDISKENTRY CurrentDisk; PPARTENTRY CurrentPartition; + UCHAR CurrentPartitionNumber; PDISKENTRY ActiveBootDisk; PPARTENTRY ActiveBootPartition;