mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[SETUPLIB][USETUP] Additional partition validity checks.
Always perform the partition validity checks when creating new primary/extended/logical partitions, and also when a new partition is automatically created when unpartitioned space is selected for ReactOS installation. CORE-12246
This commit is contained in:
parent
2d320f5a8d
commit
70fa2e2eb4
3 changed files with 65 additions and 19 deletions
|
@ -2203,6 +2203,8 @@ UpdateDiskLayout(
|
|||
ListEntry = ListEntry->Flink;
|
||||
}
|
||||
|
||||
ASSERT(Index <= 4);
|
||||
|
||||
/* Update the logical partition table */
|
||||
Index = 4;
|
||||
ListEntry = DiskEntry->LogicalPartListHead.Flink;
|
||||
|
@ -2356,12 +2358,13 @@ GetNextUnpartitionedEntry(
|
|||
return NULL;
|
||||
}
|
||||
|
||||
VOID
|
||||
BOOLEAN
|
||||
CreatePrimaryPartition(
|
||||
IN PPARTLIST List,
|
||||
IN ULONGLONG SectorCount,
|
||||
IN BOOLEAN AutoCreate)
|
||||
{
|
||||
ERROR_NUMBER Error;
|
||||
PDISKENTRY DiskEntry;
|
||||
PPARTENTRY PartEntry;
|
||||
PPARTENTRY NewPartEntry;
|
||||
|
@ -2371,9 +2374,16 @@ CreatePrimaryPartition(
|
|||
if (List == NULL ||
|
||||
List->CurrentDisk == NULL ||
|
||||
List->CurrentPartition == NULL ||
|
||||
List->CurrentPartition->IsPartitioned != FALSE)
|
||||
List->CurrentPartition->IsPartitioned)
|
||||
{
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Error = PrimaryPartitionCreationChecks(List);
|
||||
if (Error != NOT_AN_ERROR)
|
||||
{
|
||||
DPRINT1("PrimaryPartitionCreationChecks() failed with error %lu\n", Error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DiskEntry = List->CurrentDisk;
|
||||
|
@ -2408,7 +2418,7 @@ CreatePrimaryPartition(
|
|||
HEAP_ZERO_MEMORY,
|
||||
sizeof(PARTENTRY));
|
||||
if (NewPartEntry == NULL)
|
||||
return;
|
||||
return FALSE;
|
||||
|
||||
/* Insert the new entry into the list */
|
||||
InsertTailList(&PartEntry->ListEntry,
|
||||
|
@ -2440,6 +2450,8 @@ CreatePrimaryPartition(
|
|||
DiskEntry->Dirty = TRUE;
|
||||
|
||||
AssignDriveLetters(List);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static
|
||||
|
@ -2476,11 +2488,12 @@ AddLogicalDiskSpace(
|
|||
&NewPartEntry->ListEntry);
|
||||
}
|
||||
|
||||
VOID
|
||||
BOOLEAN
|
||||
CreateExtendedPartition(
|
||||
IN PPARTLIST List,
|
||||
IN ULONGLONG SectorCount)
|
||||
{
|
||||
ERROR_NUMBER Error;
|
||||
PDISKENTRY DiskEntry;
|
||||
PPARTENTRY PartEntry;
|
||||
PPARTENTRY NewPartEntry;
|
||||
|
@ -2490,9 +2503,16 @@ CreateExtendedPartition(
|
|||
if (List == NULL ||
|
||||
List->CurrentDisk == NULL ||
|
||||
List->CurrentPartition == NULL ||
|
||||
List->CurrentPartition->IsPartitioned != FALSE)
|
||||
List->CurrentPartition->IsPartitioned)
|
||||
{
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Error = ExtendedPartitionCreationChecks(List);
|
||||
if (Error != NOT_AN_ERROR)
|
||||
{
|
||||
DPRINT1("ExtendedPartitionCreationChecks() failed with error %lu\n", Error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DiskEntry = List->CurrentDisk;
|
||||
|
@ -2538,7 +2558,7 @@ CreateExtendedPartition(
|
|||
HEAP_ZERO_MEMORY,
|
||||
sizeof(PARTENTRY));
|
||||
if (NewPartEntry == NULL)
|
||||
return;
|
||||
return FALSE;
|
||||
|
||||
/* Insert the new entry into the list */
|
||||
InsertTailList(&PartEntry->ListEntry,
|
||||
|
@ -2584,14 +2604,17 @@ CreateExtendedPartition(
|
|||
DiskEntry->Dirty = TRUE;
|
||||
|
||||
AssignDriveLetters(List);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
VOID
|
||||
BOOLEAN
|
||||
CreateLogicalPartition(
|
||||
IN PPARTLIST List,
|
||||
IN ULONGLONG SectorCount,
|
||||
IN BOOLEAN AutoCreate)
|
||||
{
|
||||
ERROR_NUMBER Error;
|
||||
PDISKENTRY DiskEntry;
|
||||
PPARTENTRY PartEntry;
|
||||
PPARTENTRY NewPartEntry;
|
||||
|
@ -2601,9 +2624,16 @@ CreateLogicalPartition(
|
|||
if (List == NULL ||
|
||||
List->CurrentDisk == NULL ||
|
||||
List->CurrentPartition == NULL ||
|
||||
List->CurrentPartition->IsPartitioned != FALSE)
|
||||
List->CurrentPartition->IsPartitioned)
|
||||
{
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Error = LogicalPartitionCreationChecks(List);
|
||||
if (Error != NOT_AN_ERROR)
|
||||
{
|
||||
DPRINT1("LogicalPartitionCreationChecks() failed with error %lu\n", Error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DiskEntry = List->CurrentDisk;
|
||||
|
@ -2639,7 +2669,7 @@ CreateLogicalPartition(
|
|||
HEAP_ZERO_MEMORY,
|
||||
sizeof(PARTENTRY));
|
||||
if (NewPartEntry == NULL)
|
||||
return;
|
||||
return FALSE;
|
||||
|
||||
/* Insert the new entry into the list */
|
||||
InsertTailList(&PartEntry->ListEntry,
|
||||
|
@ -2672,6 +2702,8 @@ CreateLogicalPartition(
|
|||
DiskEntry->Dirty = TRUE;
|
||||
|
||||
AssignDriveLetters(List);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
VOID
|
||||
|
@ -3286,7 +3318,7 @@ PrimaryPartitionCreationChecks(
|
|||
PartEntry = List->CurrentPartition;
|
||||
|
||||
/* Fail if the partition is already in use */
|
||||
if (PartEntry->IsPartitioned != FALSE)
|
||||
if (PartEntry->IsPartitioned)
|
||||
return ERROR_NEW_PARTITION;
|
||||
|
||||
/* Fail if there are already 4 primary partitions in the list */
|
||||
|
@ -3307,7 +3339,7 @@ ExtendedPartitionCreationChecks(
|
|||
PartEntry = List->CurrentPartition;
|
||||
|
||||
/* Fail if the partition is already in use */
|
||||
if (PartEntry->IsPartitioned != FALSE)
|
||||
if (PartEntry->IsPartitioned)
|
||||
return ERROR_NEW_PARTITION;
|
||||
|
||||
/* Fail if there are already 4 primary partitions in the list */
|
||||
|
@ -3332,7 +3364,7 @@ LogicalPartitionCreationChecks(
|
|||
PartEntry = List->CurrentPartition;
|
||||
|
||||
/* Fail if the partition is already in use */
|
||||
if (PartEntry->IsPartitioned != FALSE)
|
||||
if (PartEntry->IsPartitioned)
|
||||
return ERROR_NEW_PARTITION;
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
|
|
|
@ -284,18 +284,18 @@ PPARTENTRY
|
|||
GetPrevPartition(
|
||||
IN PPARTLIST List);
|
||||
|
||||
VOID
|
||||
BOOLEAN
|
||||
CreatePrimaryPartition(
|
||||
IN PPARTLIST List,
|
||||
IN ULONGLONG SectorCount,
|
||||
IN BOOLEAN AutoCreate);
|
||||
|
||||
VOID
|
||||
BOOLEAN
|
||||
CreateExtendedPartition(
|
||||
IN PPARTLIST List,
|
||||
IN ULONGLONG SectorCount);
|
||||
|
||||
VOID
|
||||
BOOLEAN
|
||||
CreateLogicalPartition(
|
||||
IN PPARTLIST List,
|
||||
IN ULONGLONG SectorCount,
|
||||
|
|
|
@ -1607,12 +1607,26 @@ SelectPartitionPage(PINPUT_RECORD Ir)
|
|||
{
|
||||
if (PartitionList->CurrentPartition->LogicalPartition)
|
||||
{
|
||||
Error = LogicalPartitionCreationChecks(PartitionList);
|
||||
if (Error != NOT_AN_ERROR)
|
||||
{
|
||||
MUIDisplayError(Error, Ir, POPUP_WAIT_ANY_KEY);
|
||||
return SELECT_PARTITION_PAGE;
|
||||
}
|
||||
|
||||
CreateLogicalPartition(PartitionList,
|
||||
0ULL,
|
||||
TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
Error = PrimaryPartitionCreationChecks(PartitionList);
|
||||
if (Error != NOT_AN_ERROR)
|
||||
{
|
||||
MUIDisplayError(Error, Ir, POPUP_WAIT_ANY_KEY);
|
||||
return SELECT_PARTITION_PAGE;
|
||||
}
|
||||
|
||||
CreatePrimaryPartition(PartitionList,
|
||||
0ULL,
|
||||
TRUE);
|
||||
|
@ -2580,7 +2594,7 @@ DeletePartitionPage(PINPUT_RECORD Ir)
|
|||
* QuitPage
|
||||
*
|
||||
* SIDEEFFECTS
|
||||
* Sets PartEntry->DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].PartitionType (via UpdatePartitionType)
|
||||
* Calls UpdatePartitionType()
|
||||
* Calls CheckActiveSystemPartition()
|
||||
*
|
||||
* RETURNS
|
||||
|
|
Loading…
Reference in a new issue