Author: hbelusca
Date: Sat May 13 16:40:30 2017
New Revision: 74532
URL:
http://svn.reactos.org/svn/reactos?rev=74532&view=rev
Log:
[USETUP]: Further improvements:
- Comment more some of the fields in the PARTENTRY, DISKETNRY and PARTLIST structures;
- Remove the redundant members "SystemDisk", "OriginalSystemDisk" and
"TempDisk" in PARTLIST as these can be consistently deduced from the
corresponding (Original)(System)(Temp)Partition members
(note that we however keep "CurrentDisk" alongside
"CurrentPartition", see the comment in the code why we do it so).
- Adjust the rest of the code to take the removal of the redundant members into account.
The 2nd parameter of GetNextUnformattedPartition() and GetNextUncheckedPartition() are now
really optional.
- Introduce a SetPartitionType() helper to simplify the code that sets the partition type,
which also automatically adjusts other internal variables of said partition in
accordance.
- "Mounted" logical drives can have assigned letters too, registered in
\DosDevices\.
Modified:
branches/setup_improvements/base/setup/usetup/interface/usetup.c
branches/setup_improvements/base/setup/usetup/partlist.c
branches/setup_improvements/base/setup/usetup/partlist.h
Modified: branches/setup_improvements/base/setup/usetup/interface/usetup.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/interface/usetup.c [iso-8859-1]
(original)
+++ branches/setup_improvements/base/setup/usetup/interface/usetup.c [iso-8859-1] Sat May
13 16:40:30 2017
@@ -2590,9 +2590,7 @@
/* Find or set the active system partition */
CheckActiveSystemPartition(PartitionList, FileSystemList);
-
- if (PartitionList->SystemDisk == NULL ||
- PartitionList->SystemPartition == NULL)
+ if (PartitionList->SystemPartition == NULL)
{
/* FIXME: show an error dialog */
return QUIT_PAGE;
@@ -2604,7 +2602,6 @@
case Start:
if (PartitionList->CurrentPartition != PartitionList->SystemPartition)
{
- PartitionList->TempDisk = PartitionList->SystemDisk;
PartitionList->TempPartition = PartitionList->SystemPartition;
PartitionList->TempPartition->NeedsCheck = TRUE;
@@ -2613,7 +2610,6 @@
}
else
{
- PartitionList->TempDisk = PartitionList->CurrentDisk;
PartitionList->TempPartition = PartitionList->CurrentPartition;
PartitionList->TempPartition->NeedsCheck = TRUE;
@@ -2623,7 +2619,6 @@
break;
case FormatSystemPartition:
- PartitionList->TempDisk = PartitionList->CurrentDisk;
PartitionList->TempPartition = PartitionList->CurrentPartition;
PartitionList->TempPartition->NeedsCheck = TRUE;
@@ -2633,7 +2628,7 @@
case FormatInstallPartition:
if (GetNextUnformattedPartition(PartitionList,
- &PartitionList->TempDisk,
+ NULL,
&PartitionList->TempPartition))
{
PartitionList->FormatState = FormatOtherPartition;
@@ -2650,7 +2645,7 @@
case FormatOtherPartition:
if (GetNextUnformattedPartition(PartitionList,
- &PartitionList->TempDisk,
+ NULL,
&PartitionList->TempPartition))
{
PartitionList->FormatState = FormatOtherPartition;
@@ -2671,8 +2666,8 @@
return QUIT_PAGE;
}
- DiskEntry = PartitionList->TempDisk;
PartEntry = PartitionList->TempPartition;
+ DiskEntry = PartEntry->DiskEntry;
/* Adjust disk size */
DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
@@ -2903,15 +2898,14 @@
MUIDisplayPage(FORMAT_PARTITION_PAGE);
if (PartitionList == NULL ||
- PartitionList->TempDisk == NULL ||
PartitionList->TempPartition == NULL)
{
/* FIXME: show an error dialog */
return QUIT_PAGE;
}
- DiskEntry = PartitionList->TempDisk;
PartEntry = PartitionList->TempPartition;
+ DiskEntry = PartEntry->DiskEntry;
while (TRUE)
{
@@ -2937,7 +2931,7 @@
if (PartEntry->SectorCount.QuadPart < 8192)
{
/* FAT12 CHS partition (disk is smaller than 4.1MB) */
- PartEntry->PartitionType = PARTITION_FAT_12;
+ SetPartitionType(PartEntry, PARTITION_FAT_12);
}
else if (PartEntry->StartSector.QuadPart < 1450560)
{
@@ -2946,17 +2940,17 @@
if (PartEntry->SectorCount.QuadPart < 65536)
{
/* FAT16 CHS partition (partition size < 32MB) */
- PartEntry->PartitionType = PARTITION_FAT_16;
+ SetPartitionType(PartEntry, PARTITION_FAT_16);
}
else if (PartEntry->SectorCount.QuadPart < 1048576)
{
/* FAT16 CHS partition (partition size < 512MB) */
- PartEntry->PartitionType = PARTITION_HUGE;
+ SetPartitionType(PartEntry, PARTITION_HUGE);
}
else
{
/* FAT32 CHS partition (partition size >= 512MB) */
- PartEntry->PartitionType = PARTITION_FAT32;
+ SetPartitionType(PartEntry, PARTITION_FAT32);
}
}
else
@@ -2966,35 +2960,23 @@
if (PartEntry->SectorCount.QuadPart < 1048576)
{
/* FAT16 LBA partition (partition size < 512MB) */
- PartEntry->PartitionType = PARTITION_XINT13;
+ SetPartitionType(PartEntry, PARTITION_XINT13);
}
else
{
/* FAT32 LBA partition (partition size >= 512MB) */
- PartEntry->PartitionType = PARTITION_FAT32_XINT13;
+ SetPartitionType(PartEntry, PARTITION_FAT32_XINT13);
}
}
-
- DiskEntry->Dirty = TRUE;
-
DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].PartitionType
= PartEntry->PartitionType;
-
DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].RewritePartition
= TRUE;
}
#if 0
else if (wcscmp(PartEntry->FileSystem->FileSystemName,
L"EXT2") == 0)
{
- PartEntry->PartitionType = PARTITION_EXT2;
-
- DiskEntry->Dirty = TRUE;
-
DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].PartitionType
= PartEntry->PartitionType;
-
DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].RewritePartition
= TRUE;
+ SetPartitionType(PartEntry, PARTITION_EXT2);
}
else if (wcscmp(PartEntry->FileSystem->FileSystemName,
L"NTFS") == 0)
{
- PartEntry->PartitionType = PARTITION_IFS;
-
- DiskEntry->Dirty = TRUE;
-
DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].PartitionType
= PartEntry->PartitionType;
-
DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].RewritePartition
= TRUE;
+ SetPartitionType(PartEntry, PARTITION_IFS);
}
#endif
else if (!PartEntry->FileSystem->FormatFunc)
@@ -4163,7 +4145,7 @@
RtlFreeUnicodeString(&SystemRootPath);
swprintf(PathBuffer,
L"\\Device\\Harddisk%lu\\Partition%lu",
- PartitionList->SystemDisk->DiskNumber,
+ PartitionList->SystemPartition->DiskEntry->DiskNumber,
PartitionList->SystemPartition->PartitionNumber);
RtlCreateUnicodeString(&SystemRootPath, PathBuffer);
DPRINT1("SystemRootPath: %wZ\n", &SystemRootPath);
@@ -4436,7 +4418,7 @@
/* Step 2: Write the MBR */
swprintf(DestinationDevicePathBuffer,
L"\\Device\\Harddisk%d\\Partition0",
- PartitionList->SystemDisk->DiskNumber);
+ PartitionList->SystemPartition->DiskEntry->DiskNumber);
wcscpy(SourceMbrPathBuffer, SourceRootPath.Buffer);
wcscat(SourceMbrPathBuffer, L"\\loader\\dosmbr.bin");
Modified: branches/setup_improvements/base/setup/usetup/partlist.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/partlist.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/usetup/partlist.c [iso-8859-1] Sat May 13
16:40:30 2017
@@ -699,10 +699,28 @@
if (IsContainerPartition(PartEntry->PartitionType))
{
PartEntry->FormatState = Unformatted;
+ PartEntry->FileSystem = NULL;
if (LogicalPartition == FALSE && DiskEntry->ExtendedPartition ==
NULL)
DiskEntry->ExtendedPartition = PartEntry;
}
+#if 0
+ else if (IsRecognizedPartition(PartEntry->PartitionType))
+ {
+ // FIXME FIXME! We should completely rework how we get this
'FileSystemList' available...
+ PartEntry->FileSystem = GetFileSystem(FileSystemList, PartEntry);
+ if (!PartEntry->FileSystem)
+ PartEntry->FormatState = Preformatted;
+ else
+ PartEntry->FormatState = Unformatted;
+ // PartEntry->FormatState = UnknownFormat;
+ }
+ else
+ {
+ /* Unknown partition, so unknown partition format (may or may not be actually
formatted) */
+ PartEntry->FormatState = UnknownFormat;
+ }
+#endif
else if ((PartEntry->PartitionType == PARTITION_FAT_12) ||
(PartEntry->PartitionType == PARTITION_FAT_16) ||
(PartEntry->PartitionType == PARTITION_HUGE) ||
@@ -805,6 +823,7 @@
DPRINT1("Total Sectors: %I64u\n",
NewPartEntry->SectorCount.QuadPart);
NewPartEntry->FormatState = Unformatted;
+ NewPartEntry->FileSystem = NULL;
InsertTailList(&DiskEntry->PrimaryPartListHead,
&NewPartEntry->ListEntry);
@@ -851,6 +870,7 @@
DPRINT1("Total Sectors: %I64u\n",
NewPartEntry->SectorCount.QuadPart);
NewPartEntry->FormatState = Unformatted;
+ NewPartEntry->FileSystem = NULL;
/* Insert the table into the list */
InsertTailList(&PartEntry->ListEntry,
@@ -891,6 +911,7 @@
DPRINT("Total Sectors: %I64u\n",
NewPartEntry->SectorCount.QuadPart);
NewPartEntry->FormatState = Unformatted;
+ NewPartEntry->FileSystem = NULL;
/* Append the table to the list */
InsertTailList(&DiskEntry->PrimaryPartListHead,
@@ -923,6 +944,7 @@
DPRINT1("Total Sectors: %I64u\n",
NewPartEntry->SectorCount.QuadPart);
NewPartEntry->FormatState = Unformatted;
+ NewPartEntry->FileSystem = NULL;
InsertTailList(&DiskEntry->LogicalPartListHead,
&NewPartEntry->ListEntry);
@@ -970,6 +992,7 @@
DPRINT("Total Sectors: %I64u\n",
NewPartEntry->SectorCount.QuadPart);
NewPartEntry->FormatState = Unformatted;
+ NewPartEntry->FileSystem = NULL;
/* Insert the table into the list */
InsertTailList(&PartEntry->ListEntry,
@@ -1011,6 +1034,7 @@
DPRINT("Total Sectors: %I64u\n",
NewPartEntry->SectorCount.QuadPart);
NewPartEntry->FormatState = Unformatted;
+ NewPartEntry->FileSystem = NULL;
/* Append the table to the list */
InsertTailList(&DiskEntry->LogicalPartListHead,
@@ -1157,6 +1181,11 @@
if (!NT_SUCCESS(Status))
return;
+ /*
+ * Check whether the disk is initialized, by looking at its MBR.
+ * NOTE that this must be generalized to GPT disks as well!
+ */
+
Mbr = (PARTITION_SECTOR*)RtlAllocateHeap(ProcessHeap,
0,
DiskGeometry.BytesPerSector);
@@ -1206,6 +1235,7 @@
DiskEntry->BiosFound = FALSE;
/* Check if this disk has a valid MBR */
+ // FIXME: Check for the MBR signature as well, etc...
if (Mbr->BootCode[0] == 0 && Mbr->BootCode[1] == 0)
DiskEntry->NoMbr = TRUE;
else
@@ -1213,6 +1243,7 @@
/* Free the MBR sector buffer */
RtlFreeHeap(ProcessHeap, 0, Mbr);
+
ListEntry = List->BiosDiskListHead.Flink;
while (ListEntry != &List->BiosDiskListHead)
@@ -1421,12 +1452,9 @@
List->CurrentDisk = NULL;
List->CurrentPartition = NULL;
- List->SystemDisk = NULL;
List->SystemPartition = NULL;
- List->OriginalSystemDisk = NULL;
List->OriginalSystemPartition = NULL;
- List->TempDisk = NULL;
List->TempPartition = NULL;
List->FormatState = Start;
@@ -2738,6 +2766,7 @@
PartEntry->IsPartitioned = TRUE;
PartEntry->PartitionType = PARTITION_ENTRY_UNUSED;
PartEntry->FormatState = Unformatted;
+ PartEntry->FileSystem = NULL;
PartEntry->AutoCreate = AutoCreate;
PartEntry->New = TRUE;
PartEntry->BootIndicator = FALSE;
@@ -2775,6 +2804,7 @@
NewPartEntry->New = TRUE;
NewPartEntry->FormatState = Unformatted;
+ NewPartEntry->FileSystem = NULL;
NewPartEntry->BootIndicator = FALSE;
PartEntry->StartSector.QuadPart = NewPartEntry->StartSector.QuadPart +
NewPartEntry->SectorCount.QuadPart;
@@ -2817,6 +2847,7 @@
DPRINT1("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart);
NewPartEntry->FormatState = Unformatted;
+ NewPartEntry->FileSystem = NULL;
InsertTailList(&DiskEntry->LogicalPartListHead,
&NewPartEntry->ListEntry);
@@ -2853,7 +2884,8 @@
/* Convert current entry to 'new (unformatted)' */
PartEntry->IsPartitioned = TRUE;
- PartEntry->FormatState = Formatted;
+ PartEntry->FormatState = Formatted; // FIXME???????? Possibly to make
GetNextUnformattedPartition work (i.e. skip the extended partition container)
+ PartEntry->FileSystem = NULL;
PartEntry->AutoCreate = FALSE;
PartEntry->New = FALSE;
PartEntry->BootIndicator = FALSE;
@@ -2898,7 +2930,8 @@
NewPartEntry->StartSector.QuadPart;
NewPartEntry->New = FALSE;
- NewPartEntry->FormatState = Formatted;
+ NewPartEntry->FormatState = Formatted; // FIXME???????? Possibly to make
GetNextUnformattedPartition work (i.e. skip the extended partition container)
+ NewPartEntry->FileSystem = NULL;
NewPartEntry->BootIndicator = FALSE;
if (NewPartEntry->StartSector.QuadPart < 1450560)
@@ -2966,6 +2999,7 @@
PartEntry->IsPartitioned = TRUE;
PartEntry->PartitionType = PARTITION_ENTRY_UNUSED;
PartEntry->FormatState = Unformatted;
+ PartEntry->FileSystem = NULL;
PartEntry->AutoCreate = FALSE;
PartEntry->New = TRUE;
PartEntry->BootIndicator = FALSE;
@@ -3004,6 +3038,7 @@
NewPartEntry->New = TRUE;
NewPartEntry->FormatState = Unformatted;
+ NewPartEntry->FileSystem = NULL;
NewPartEntry->BootIndicator = FALSE;
NewPartEntry->LogicalPartition = TRUE;
@@ -3041,7 +3076,6 @@
/* Clear the system disk and partition pointers if the system partition is being
deleted */
if (List->SystemPartition == List->CurrentPartition)
{
- List->SystemDisk = NULL;
List->SystemPartition = NULL;
}
@@ -3121,6 +3155,7 @@
PartEntry->IsPartitioned = FALSE;
PartEntry->PartitionType = PARTITION_ENTRY_UNUSED;
PartEntry->FormatState = Unformatted;
+ PartEntry->FileSystem = NULL;
PartEntry->DriveLetter = 0;
}
@@ -3147,9 +3182,7 @@
/* Check for empty disk list */
if (IsListEmpty(&List->DiskListHead))
{
- List->SystemDisk = NULL;
List->SystemPartition = NULL;
- List->OriginalSystemDisk = NULL;
List->OriginalSystemPartition = NULL;
return;
}
@@ -3160,35 +3193,31 @@
/* Check for empty partition list */
if (IsListEmpty(&DiskEntry->PrimaryPartListHead))
{
- List->SystemDisk = NULL;
List->SystemPartition = NULL;
- List->OriginalSystemDisk = NULL;
List->OriginalSystemPartition = NULL;
return;
}
- if (List->SystemDisk != NULL && List->SystemPartition != NULL)
+ if (List->SystemPartition != NULL)
{
/* We already have an active system partition */
DPRINT1("Use the current system partition %lu in disk %lu, drive letter
%c\n",
List->SystemPartition->PartitionNumber,
- List->SystemDisk->DiskNumber,
+ List->SystemPartition->DiskEntry->DiskNumber,
(List->SystemPartition->DriveLetter == 0) ? '-' :
List->SystemPartition->DriveLetter);
return;
}
DPRINT1("We are here (1)!\n");
- List->SystemDisk = NULL;
List->SystemPartition = NULL;
- List->OriginalSystemDisk = NULL;
List->OriginalSystemPartition = NULL;
/* Retrieve the first partition of the disk */
PartEntry = CONTAINING_RECORD(DiskEntry->PrimaryPartListHead.Flink,
PARTENTRY,
ListEntry);
- List->SystemDisk = DiskEntry;
+ ASSERT(DiskEntry == PartEntry->DiskEntry);
List->SystemPartition = PartEntry;
//
@@ -3200,16 +3229,14 @@
{
if (PartEntry->PartitionType == PARTITION_ENTRY_UNUSED ||
PartEntry->BootIndicator == FALSE)
{
- /* FIXME: Might be incorrect if partitions were created by Linux FDISK */
- List->SystemDisk = DiskEntry;
+ ASSERT(DiskEntry == PartEntry->DiskEntry);
List->SystemPartition = PartEntry;
- List->OriginalSystemDisk = List->SystemDisk;
List->OriginalSystemPartition = List->SystemPartition;
DPRINT1("Use new first active system partition %lu in disk %lu, drive
letter %c\n",
List->SystemPartition->PartitionNumber,
- List->SystemDisk->DiskNumber,
+ List->SystemPartition->DiskEntry->DiskNumber,
(List->SystemPartition->DriveLetter == 0) ? '-' :
List->SystemPartition->DriveLetter);
goto SetSystemPartition;
@@ -3248,22 +3275,18 @@
* OK we haven't encountered any used and active partition,
* so use the first one as the system partition.
*/
-
- /* FIXME: Might be incorrect if partitions were created by Linux FDISK */
- List->OriginalSystemDisk = List->SystemDisk; // DiskEntry
+ ASSERT(DiskEntry == List->SystemPartition->DiskEntry);
List->OriginalSystemPartition = List->SystemPartition; // First PartEntry
DPRINT1("Use first active system partition %lu in disk %lu, drive letter
%c\n",
List->SystemPartition->PartitionNumber,
- List->SystemDisk->DiskNumber,
+ List->SystemPartition->DiskEntry->DiskNumber,
(List->SystemPartition->DriveLetter == 0) ? '-' :
List->SystemPartition->DriveLetter);
goto SetSystemPartition;
}
- List->SystemDisk = NULL;
List->SystemPartition = NULL;
- List->OriginalSystemDisk = NULL;
List->OriginalSystemPartition = NULL;
DPRINT1("We are here (3)!\n");
@@ -3286,7 +3309,7 @@
if (PartEntry->BootIndicator)
{
/* Yes, we found it */
- List->SystemDisk = DiskEntry;
+ ASSERT(DiskEntry == PartEntry->DiskEntry);
List->SystemPartition = PartEntry;
DPRINT1("Found active system partition %lu in disk %lu, drive letter
%c\n",
@@ -3299,15 +3322,14 @@
}
/* Check if we have found the system partition */
- if (List->SystemDisk == NULL || List->SystemPartition == NULL)
+ if (List->SystemPartition == NULL)
{
/* Nothing, use the alternative system partition */
DPRINT1("No system partition found, use the alternative
partition!\n");
goto UseAlternativeSystemPartition;
}
- /* Save them */
- List->OriginalSystemDisk = List->SystemDisk;
+ /* Save it */
List->OriginalSystemPartition = List->SystemPartition;
/*
@@ -3331,7 +3353,7 @@
{
DPRINT1("System partition %lu in disk %lu with no FS?!\n",
List->OriginalSystemPartition->PartitionNumber,
- List->OriginalSystemDisk->DiskNumber);
+ List->OriginalSystemPartition->DiskEntry->DiskNumber);
goto FindAndUseAlternativeSystemPartition;
}
// HACK: WARNING: We cannot write on this FS yet!
@@ -3346,7 +3368,7 @@
DPRINT1("Use existing active system partition %lu in disk %lu, drive letter
%c\n",
List->SystemPartition->PartitionNumber,
- List->SystemDisk->DiskNumber,
+ List->SystemPartition->DiskEntry->DiskNumber,
(List->SystemPartition->DriveLetter == 0) ? '-' :
List->SystemPartition->DriveLetter);
return;
@@ -3363,25 +3385,24 @@
/* Unset the old system partition */
List->SystemPartition->BootIndicator = FALSE;
-
List->SystemDisk->LayoutBuffer->PartitionEntry[List->SystemPartition->PartitionIndex].BootIndicator
= FALSE;
-
List->SystemDisk->LayoutBuffer->PartitionEntry[List->SystemPartition->PartitionIndex].RewritePartition
= TRUE;
- List->SystemDisk->Dirty = TRUE;
+
List->SystemPartition->DiskEntry->LayoutBuffer->PartitionEntry[List->SystemPartition->PartitionIndex].BootIndicator
= FALSE;
+
List->SystemPartition->DiskEntry->LayoutBuffer->PartitionEntry[List->SystemPartition->PartitionIndex].RewritePartition
= TRUE;
+ List->SystemPartition->DiskEntry->Dirty = TRUE;
UseAlternativeSystemPartition:
- List->SystemDisk = List->CurrentDisk;
List->SystemPartition = List->CurrentPartition;
DPRINT1("Use alternative active system partition %lu in disk %lu, drive letter
%c\n",
List->SystemPartition->PartitionNumber,
- List->SystemDisk->DiskNumber,
+ List->SystemPartition->DiskEntry->DiskNumber,
(List->SystemPartition->DriveLetter == 0) ? '-' :
List->SystemPartition->DriveLetter);
SetSystemPartition:
/* Set the new active system partition */
List->SystemPartition->BootIndicator = TRUE;
-
List->SystemDisk->LayoutBuffer->PartitionEntry[List->SystemPartition->PartitionIndex].BootIndicator
= TRUE;
-
List->SystemDisk->LayoutBuffer->PartitionEntry[List->SystemPartition->PartitionIndex].RewritePartition
= TRUE;
- List->SystemDisk->Dirty = TRUE;
+
List->SystemPartition->DiskEntry->LayoutBuffer->PartitionEntry[List->SystemPartition->PartitionIndex].BootIndicator
= TRUE;
+
List->SystemPartition->DiskEntry->LayoutBuffer->PartitionEntry[List->SystemPartition->PartitionIndex].RewritePartition
= TRUE;
+ List->SystemPartition->DiskEntry->Dirty = TRUE;
}
@@ -3447,6 +3468,16 @@
if (FileHandle != NULL)
NtClose(FileHandle);
+
+ //
+ // NOTE: Originally (see r40437), we used to install here also a new MBR
+ // for this disk (by calling InstallMbrBootCodeToDisk), only if:
+ // DiskEntry->NewDisk == TRUE and DiskEntry->BiosDiskNumber == 0.
+ // Then after that, both DiskEntry->NewDisk and DiskEntry->NoMbr were set
+ // to FALSE. In the other place (in usetup.c) where InstallMbrBootCodeToDisk
+ // was called too, the installation test was modified by checking whether
+ // DiskEntry->NoMbr was TRUE (instead of NewDisk).
+ //
return Status;
}
@@ -3521,12 +3552,47 @@
Entry2 = Entry2->Flink;
}
+ Entry2 = DiskEntry->LogicalPartListHead.Flink;
+ while (Entry2 != &DiskEntry->LogicalPartListHead)
+ {
+ PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
+ if (PartEntry->IsPartitioned)
+ {
+ /* Assign a "\DosDevices\#:" mount point to this partition */
+ if (PartEntry->DriveLetter)
+ {
+ StartingOffset.QuadPart = PartEntry->StartSector.QuadPart *
DiskEntry->BytesPerSector;
+ if (!SetMountedDeviceValue(PartEntry->DriveLetter,
+ DiskEntry->LayoutBuffer->Signature,
+ StartingOffset))
+ {
+ return FALSE;
+ }
+ }
+ }
+
+ Entry2 = Entry2->Flink;
+ }
+
Entry1 = Entry1->Flink;
}
return TRUE;
}
+VOID
+SetPartitionType(
+ IN PPARTENTRY PartEntry,
+ IN UCHAR PartitionType)
+{
+ PDISKENTRY DiskEntry = PartEntry->DiskEntry;
+
+ PartEntry->PartitionType = PartitionType;
+
+ DiskEntry->Dirty = TRUE;
+
DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].PartitionType
= PartitionType;
+
DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].RewritePartition
= TRUE;
+}
ULONG
PrimaryPartitionCreationChecks(
@@ -3617,9 +3683,10 @@
PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
if (PartEntry->IsPartitioned && PartEntry->New)
{
- *pDiskEntry = DiskEntry;
- *pPartEntry = PartEntry;
- return TRUE;
+ ASSERT(DiskEntry == PartEntry->DiskEntry);
+ if (pDiskEntry) *pDiskEntry = DiskEntry;
+ *pPartEntry = PartEntry;
+ return TRUE;
}
Entry2 = Entry2->Flink;
@@ -3631,9 +3698,10 @@
PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
if (PartEntry->IsPartitioned && PartEntry->New)
{
- *pDiskEntry = DiskEntry;
- *pPartEntry = PartEntry;
- return TRUE;
+ ASSERT(DiskEntry == PartEntry->DiskEntry);
+ if (pDiskEntry) *pDiskEntry = DiskEntry;
+ *pPartEntry = PartEntry;
+ return TRUE;
}
Entry2 = Entry2->Flink;
@@ -3642,7 +3710,7 @@
Entry1 = Entry1->Flink;
}
- *pDiskEntry = NULL;
+ if (pDiskEntry) *pDiskEntry = NULL;
*pPartEntry = NULL;
return FALSE;
@@ -3671,9 +3739,10 @@
PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
if (PartEntry->NeedsCheck == TRUE)
{
- *pDiskEntry = DiskEntry;
- *pPartEntry = PartEntry;
- return TRUE;
+ ASSERT(DiskEntry == PartEntry->DiskEntry);
+ if (pDiskEntry) *pDiskEntry = DiskEntry;
+ *pPartEntry = PartEntry;
+ return TRUE;
}
Entry2 = Entry2->Flink;
@@ -3685,9 +3754,10 @@
PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
if (PartEntry->NeedsCheck == TRUE)
{
- *pDiskEntry = DiskEntry;
- *pPartEntry = PartEntry;
- return TRUE;
+ ASSERT(DiskEntry == PartEntry->DiskEntry);
+ if (pDiskEntry) *pDiskEntry = DiskEntry;
+ *pPartEntry = PartEntry;
+ return TRUE;
}
Entry2 = Entry2->Flink;
@@ -3696,7 +3766,7 @@
Entry1 = Entry1->Flink;
}
- *pDiskEntry = NULL;
+ if (pDiskEntry) *pDiskEntry = NULL;
*pPartEntry = NULL;
return FALSE;
Modified: branches/setup_improvements/base/setup/usetup/partlist.h
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/partlist.h [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/usetup/partlist.h [iso-8859-1] Sat May 13
16:40:30 2017
@@ -51,20 +51,22 @@
{
LIST_ENTRY ListEntry;
+ /* The disk this partition belongs to */
struct _DISKENTRY *DiskEntry;
+ /* Partition geometry */
ULARGE_INTEGER StartSector;
ULARGE_INTEGER SectorCount;
BOOLEAN BootIndicator;
UCHAR PartitionType;
ULONG HiddenSectors;
- ULONG PartitionNumber;
- ULONG PartitionIndex;
+ ULONG PartitionNumber; /* Enumerated partition number (primary partitions first --
excluding the extended partition container --, then the logical partitions) */
+ ULONG PartitionIndex; /* Index in the LayoutBuffer->PartitionEntry[] cached
array of the corresponding DiskEntry */
CHAR DriveLetter;
- CHAR VolumeLabel[17];
- CHAR FileSystemName[9];
+ // CHAR VolumeLabel[17]; // NOTE: On 1st-stage Win setup, the volume label is also
displayed in the list
+ // CHAR FileSystemName[9]; // NOTE: Superseded by the FileSystem member
BOOLEAN LogicalPartition;
@@ -77,12 +79,12 @@
/* Partition was created automatically */
BOOLEAN AutoCreate;
- FORMATSTATE FormatState;
-
/* Partition must be checked */
BOOLEAN NeedsCheck;
+ FORMATSTATE FormatState;
struct _FILE_SYSTEM_ITEM *FileSystem;
+
} PARTENTRY, *PPARTENTRY;
@@ -102,6 +104,8 @@
{
LIST_ENTRY ListEntry;
+ /* Disk geometry */
+
ULONGLONG Cylinders;
ULONG TracksPerCylinder;
ULONG SectorsPerTrack;
@@ -111,11 +115,13 @@
ULONG SectorAlignment;
ULONG CylinderAlignment;
+ /* BIOS parameters */
BOOLEAN BiosFound;
ULONG BiosDiskNumber;
// ULONG Signature;
// ULONG Checksum;
+ /* SCSI parameters */
ULONG DiskNumber;
USHORT Port;
USHORT Bus;
@@ -125,12 +131,17 @@
BOOLEAN Dirty;
BOOLEAN NewDisk;
- BOOLEAN NoMbr; /* MBR is absent */
+ BOOLEAN NoMbr; /* MBR is absent */ // See r40437
UNICODE_STRING DriverName;
PDRIVE_LAYOUT_INFORMATION LayoutBuffer;
-
+ // TODO: When adding support for GPT disks:
+ // Use PDRIVE_LAYOUT_INFORMATION_EX which indicates whether
+ // the disk is MBR, GPT, or unknown (uninitialized).
+ // Depending on the style, either use the MBR or GPT partition info.
+
+ /* Pointer to the unique extended partition on this disk */
PPARTENTRY ExtendedPartition;
LIST_ENTRY PrimaryPartListHead;
@@ -141,6 +152,7 @@
typedef struct _PARTLIST
{
+ /* UI stuff */
SHORT Left;
SHORT Top;
SHORT Right;
@@ -149,23 +161,32 @@
SHORT Line;
SHORT Offset;
+ /*
+ * NOTE that when CurrentPartition != NULL, then CurrentPartition->DiskEntry
+ * must be the same as CurrentDisk. We should however keep the two members
+ * separated as we can have a current (selected) disk without any current
+ * partition, if the former does not contain any.
+ */
PDISKENTRY CurrentDisk;
PPARTENTRY CurrentPartition;
- /* The system disk and partition where the boot manager resides */
- PDISKENTRY SystemDisk;
+ /*
+ * The system partition where the boot manager resides.
+ * The corresponding system disk is obtained via:
+ * SystemPartition->DiskEntry.
+ */
PPARTENTRY SystemPartition;
/*
- * The original system disk and partition in case we are redefining them
- * because we do not have write support on them.
- * Please not that this is partly a HACK and MUST NEVER happen on
+ * The original system partition in case we are redefining it because
+ * we do not have write support on it.
+ * Please note that this is partly a HACK and MUST NEVER happen on
* architectures where real system partitions are mandatory (because then
* they are formatted in FAT FS and we support write operation on them).
+ * The corresponding original system disk is obtained via:
+ * OriginalSystemPartition->DiskEntry.
*/
- PDISKENTRY OriginalSystemDisk;
PPARTENTRY OriginalSystemPartition;
- PDISKENTRY TempDisk;
PPARTENTRY TempPartition;
FORMATMACHINESTATE FormatState;
@@ -280,6 +301,11 @@
SetMountedDeviceValues(
IN PPARTLIST List);
+VOID
+SetPartitionType(
+ IN PPARTENTRY PartEntry,
+ IN UCHAR PartitionType);
+
ULONG
PrimaryPartitionCreationChecks(
IN PPARTLIST List);