}
-static
-BOOLEAN
-IsLastPrimaryPartiton(
- IN PPARTENTRY PartEntry)
-{
- return (PartEntry->ListEntry.Flink == &PartEntry->DiskEntry->PrimaryPartListHead);
-}
-
-
-static
-BOOLEAN
-IsPreviousPartitionExtended(
- IN PPARTENTRY PartEntry,
- IN PDISKENTRY DiskEntry)
-{
- PPARTENTRY PrevPartEntry;
- PLIST_ENTRY Entry;
-
- Entry = PartEntry->ListEntry.Blink;
-
- while (Entry != &DiskEntry->PrimaryPartListHead)
- {
- PrevPartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
-
- if (IsContainerPartition(PrevPartEntry->PartitionType))
- return TRUE;
-
- Entry = Entry->Blink;
- }
-
- return FALSE;
-
-}
-
-
static
ULONG
GetPrimaryPartitionCount(
if (GetPrimaryPartitionCount(DiskEntry) > 4)
return ERROR_PARTITION_TABLE_FULL;
- /* Fail if this partiton is located behind an extended partition */
- if (IsPreviousPartitionExtended(PartEntry, DiskEntry))
- return ERROR_NOT_BEHIND_EXTENDED;
-
return ERROR_SUCCESS;
}
if (DiskEntry->ExtendedPartition != NULL)
return ERROR_ONLY_ONE_EXTENDED;
- /* Fail if the partition is not the last list entry */
- if (!IsLastPrimaryPartiton(PartEntry))
- return ERROR_EXTENDED_NOT_LAST;
-
return ERROR_SUCCESS;
}