for (i = 0; i < DiskEntry->LayoutBuffer->PartitionCount; i++)
{
PartitionInfo = &DiskEntry->LayoutBuffer->PartitionEntry[i];
- DbgPrint("%lu: %12I64u %12I64u %10lu %2lu %2x %c %c\n",
+ DPRINT("\n%lu: %12I64u %12I64u %10lu %2lu %2x %c %c\n",
i,
PartitionInfo->StartingOffset.QuadPart,
PartitionInfo->PartitionLength.QuadPart,
PPARTENTRY NewPartEntry;
PLIST_ENTRY Entry;
- DPRINT1("ScanForUnpartitionedDiskSpace()\n");
+ DPRINT("ScanForUnpartitionedDiskSpace()\n");
if (IsListEmpty(&DiskEntry->PrimaryPartListHead))
{
NewPartEntry->StartSector.QuadPart = LastStartSector + LastSectorCount;
NewPartEntry->SectorCount.QuadPart = Align(NewPartEntry->StartSector.QuadPart + LastUnusedSectorCount, DiskEntry->SectorAlignment) -
NewPartEntry->StartSector.QuadPart;
-DPRINT1("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart);
-DPRINT1("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1);
-DPRINT1("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart);
+ DPRINT("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart);
+ DPRINT("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1);
+ DPRINT("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart);
NewPartEntry->FormatState = Unformatted;
NewPartEntry->StartSector.QuadPart = LastStartSector + LastSectorCount;
NewPartEntry->SectorCount.QuadPart = Align(NewPartEntry->StartSector.QuadPart + LastUnusedSectorCount, DiskEntry->SectorAlignment) -
NewPartEntry->StartSector.QuadPart;
-DPRINT1("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart);
-DPRINT1("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1);
-DPRINT1("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart);
+ DPRINT("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart);
+ DPRINT("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1);
+ DPRINT("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart);
NewPartEntry->FormatState = Unformatted;
NewPartEntry->StartSector.QuadPart = LastStartSector + LastSectorCount;
NewPartEntry->SectorCount.QuadPart = Align(NewPartEntry->StartSector.QuadPart + LastUnusedSectorCount, DiskEntry->SectorAlignment) -
NewPartEntry->StartSector.QuadPart;
-DPRINT1("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart);
-DPRINT1("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1);
-DPRINT1("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart);
+ DPRINT("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart);
+ DPRINT("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1);
+ DPRINT("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart);
NewPartEntry->FormatState = Unformatted;
}
}
- DPRINT1("ScanForUnpartitionedDiskSpace() done\n");
+ DPRINT("ScanForUnpartitionedDiskSpace() done\n");
}
DiskEntry->SectorAlignment = DiskGeometry.SectorsPerTrack;
- DPRINT1("SectorCount %I64u\n", DiskEntry->SectorCount);
- DPRINT1("SectorAlignment %lu\n", DiskEntry->SectorAlignment);
+ DPRINT("SectorCount %I64u\n", DiskEntry->SectorCount);
+ DPRINT("SectorAlignment %lu\n", DiskEntry->SectorAlignment);
DiskEntry->DiskNumber = DiskNumber;
DiskEntry->Port = ScsiAddress.PortNumber;
InsertAscendingList(&List->DiskListHead, DiskEntry, DISKENTRY, ListEntry, DiskNumber);
/*
- * Allocate a buffer for 26 logical drives (2 entries each == 52)
+ * Allocate a buffer for 26 logical drives (2 entries each == 52)
* plus the main partiton table (4 entries). Total 56 entries.
*/
LayoutBufferSize = sizeof(DRIVE_LAYOUT_INFORMATION) +
{
if ((DiskEntry->LayoutBuffer->PartitionEntry[0].StartingOffset.QuadPart / DiskEntry->BytesPerSector) % DiskEntry->SectorsPerTrack == 0)
{
- DPRINT1("Use %lu Sector alignment!\n", DiskEntry->SectorsPerTrack);
+ DPRINT("Use %lu Sector alignment!\n", DiskEntry->SectorsPerTrack);
}
else if (DiskEntry->LayoutBuffer->PartitionEntry[0].StartingOffset.QuadPart % 1048756 == 0)
{
{
/* Primary or extended partition */
- if (IsContainerPartition(List->CurrentPartition->PartitionType))
+ if (List->CurrentPartition->IsPartitioned == TRUE &&
+ IsContainerPartition(List->CurrentPartition->PartitionType))
{
/* First logical partition */
PartListEntry = List->CurrentDisk->LogicalPartListHead.Flink;
{
PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
- if (IsContainerPartition(PartEntry->PartitionType))
+ if (PartEntry->IsPartitioned == TRUE &&
+ IsContainerPartition(PartEntry->PartitionType))
{
PartListEntry = List->CurrentDisk->LogicalPartListHead.Blink;
PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
{
PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
- if (IsContainerPartition(PartEntry->PartitionType))
+ if (PartEntry->IsPartitioned == TRUE &&
+ IsContainerPartition(PartEntry->PartitionType))
{
PartListEntry = DiskEntry->LogicalPartListHead.Blink;
if (PartListEntry != &DiskEntry->LogicalPartListHead)
{
/* Nothing to merge but change current entry */
PartEntry->IsPartitioned = FALSE;
+ PartEntry->PartitionType = PARTITION_ENTRY_UNUSED;
PartEntry->FormatState = Unformatted;
PartEntry->DriveLetter = 0;
}
}
-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;
}