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,
return;
}
+ PartEntry->DiskEntry = DiskEntry;
+
PartEntry->StartSector.QuadPart = (ULONGLONG)PartitionInfo->StartingOffset.QuadPart / DiskEntry->BytesPerSector;
PartEntry->SectorCount.QuadPart = (ULONGLONG)PartitionInfo->PartitionLength.QuadPart / DiskEntry->BytesPerSector;
PPARTENTRY NewPartEntry;
PLIST_ENTRY Entry;
- DPRINT1("ScanForUnpartitionedDiskSpace()\n");
+ DPRINT("ScanForUnpartitionedDiskSpace()\n");
if (IsListEmpty(&DiskEntry->PrimaryPartListHead))
{
NewPartEntry->DiskEntry = DiskEntry;
NewPartEntry->IsPartitioned = FALSE;
- NewPartEntry->StartSector.QuadPart = (ULONGLONG)DiskEntry->SectorsPerTrack;
+ NewPartEntry->StartSector.QuadPart = (ULONGLONG)DiskEntry->SectorAlignment;
NewPartEntry->SectorCount.QuadPart = Align(DiskEntry->SectorCount.QuadPart, DiskEntry->SectorAlignment) -
- DiskEntry->SectorsPerTrack;
-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);
+ 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);
NewPartEntry->FormatState = Unformatted;
}
/* Start partition at head 1, cylinder 0 */
- LastStartSector = DiskEntry->SectorsPerTrack;
+ LastStartSector = DiskEntry->SectorAlignment;
LastSectorCount = 0ULL;
LastUnusedSectorCount = 0ULL;
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);
+
+ 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);
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->LogicalPartition = TRUE;
NewPartEntry->IsPartitioned = FALSE;
- NewPartEntry->StartSector.QuadPart = DiskEntry->ExtendedPartition->StartSector.QuadPart + (ULONGLONG)DiskEntry->SectorsPerTrack;
- NewPartEntry->SectorCount.QuadPart = DiskEntry->ExtendedPartition->SectorCount.QuadPart - (ULONGLONG)DiskEntry->SectorsPerTrack;
+ NewPartEntry->StartSector.QuadPart = DiskEntry->ExtendedPartition->StartSector.QuadPart + (ULONGLONG)DiskEntry->SectorAlignment;
+ NewPartEntry->SectorCount.QuadPart = DiskEntry->ExtendedPartition->SectorCount.QuadPart - (ULONGLONG)DiskEntry->SectorAlignment;
DPRINT1("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart);
DPRINT1("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1);
}
/* Start partition at head 1, cylinder 0 */
- LastStartSector = DiskEntry->ExtendedPartition->StartSector.QuadPart + (ULONGLONG)DiskEntry->SectorsPerTrack;
+ LastStartSector = DiskEntry->ExtendedPartition->StartSector.QuadPart + (ULONGLONG)DiskEntry->SectorAlignment;
LastSectorCount = 0ULL;
LastUnusedSectorCount = 0ULL;
PartEntry->SectorCount.QuadPart != 0ULL)
{
LastUnusedSectorCount =
- PartEntry->StartSector.QuadPart - (ULONGLONG)DiskEntry->SectorsPerTrack - (LastStartSector + LastSectorCount);
+ PartEntry->StartSector.QuadPart - (ULONGLONG)DiskEntry->SectorAlignment - (LastStartSector + LastSectorCount);
- if ((PartEntry->StartSector.QuadPart - (ULONGLONG)DiskEntry->SectorsPerTrack) > (LastStartSector + LastSectorCount) &&
+ if ((PartEntry->StartSector.QuadPart - (ULONGLONG)DiskEntry->SectorAlignment) > (LastStartSector + LastSectorCount) &&
LastUnusedSectorCount >= (ULONGLONG)DiskEntry->SectorAlignment)
{
DPRINT("Unpartitioned disk space %I64u sectors\n", LastUnusedSectorCount);
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)
+ else if (DiskEntry->LayoutBuffer->PartitionEntry[0].StartingOffset.QuadPart % (1024 * 1024) == 0)
{
- DPRINT1("Use megabyte (%lu Sectors) alignment!\n", 1048756 / DiskEntry->BytesPerSector);
+ DPRINT1("Use megabyte (%lu Sectors) alignment!\n", (1024 * 1024) / DiskEntry->BytesPerSector);
}
else
{
}
else
{
- DPRINT1("No valid partiton table found! Use megabyte (%lu Sectors) alignment!\n", 1048756 / DiskEntry->BytesPerSector);
+ DPRINT1("No valid partiton table found! Use megabyte (%lu Sectors) alignment!\n", (1024 * 1024) / DiskEntry->BytesPerSector);
}
MUIGetString(STRING_HDDINFOUNK5),
(PartEntry->DriveLetter == 0) ? '-' : PartEntry->DriveLetter,
(PartEntry->DriveLetter == 0) ? '-' : ':',
+ PartEntry->BootIndicator ? '*' : ' ',
PartEntry->LogicalPartition ? " " : "",
PartEntry->PartitionType,
PartEntry->LogicalPartition ? "" : " ",
else
{
sprintf(LineBuffer,
- "%c%c %s%-24s%s %6lu %s",
+ "%c%c %c %s%-24s%s %6lu %s",
(PartEntry->DriveLetter == 0) ? '-' : PartEntry->DriveLetter,
(PartEntry->DriveLetter == 0) ? '-' : ':',
+ PartEntry->BootIndicator ? '*' : ' ',
PartEntry->LogicalPartition ? " " : "",
PartType,
PartEntry->LogicalPartition ? "" : " ",
ScrollDownPartitionList(
PPARTLIST List)
{
-// PDISKENTRY DiskEntry;
+ PLIST_ENTRY DiskListEntry;
+ PLIST_ENTRY PartListEntry;
+ PDISKENTRY DiskEntry;
PPARTENTRY PartEntry;
- PLIST_ENTRY Entry;
- /* Check for empty disks */
+ /* Fail, if no disks are available */
if (IsListEmpty(&List->DiskListHead))
return FALSE;
-
/* Check for next usable entry on current disk */
if (List->CurrentPartition != NULL)
{
{
/* Logical partition */
- Entry = List->CurrentPartition->ListEntry.Flink;
- if (Entry != &List->CurrentDisk->LogicalPartListHead)
+ PartListEntry = List->CurrentPartition->ListEntry.Flink;
+ if (PartListEntry != &List->CurrentDisk->LogicalPartListHead)
{
/* Next logical partition */
- PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
+ PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
List->CurrentPartition = PartEntry;
return TRUE;
}
else
{
- Entry = List->CurrentDisk->ExtendedPartition->ListEntry.Flink;
- if (Entry != &List->CurrentDisk->PrimaryPartListHead)
+ PartListEntry = List->CurrentDisk->ExtendedPartition->ListEntry.Flink;
+ if (PartListEntry != &List->CurrentDisk->PrimaryPartListHead)
{
- PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
+ PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
List->CurrentPartition = PartEntry;
return TRUE;
{
/* Primary or extended partition */
- if (IsContainerPartition(List->CurrentPartition->PartitionType))
+ if (List->CurrentPartition->IsPartitioned == TRUE &&
+ IsContainerPartition(List->CurrentPartition->PartitionType))
{
/* First logical partition */
- Entry = List->CurrentDisk->LogicalPartListHead.Flink;
- if (Entry != &List->CurrentDisk->LogicalPartListHead)
+ PartListEntry = List->CurrentDisk->LogicalPartListHead.Flink;
+ if (PartListEntry != &List->CurrentDisk->LogicalPartListHead)
{
- PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
+ PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
List->CurrentPartition = PartEntry;
return TRUE;
else
{
/* Next primary partition */
- Entry = List->CurrentPartition->ListEntry.Flink;
- if (Entry != &List->CurrentDisk->PrimaryPartListHead)
+ PartListEntry = List->CurrentPartition->ListEntry.Flink;
+ if (PartListEntry != &List->CurrentDisk->PrimaryPartListHead)
{
- PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
+ PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
List->CurrentPartition = PartEntry;
return TRUE;
}
}
- DPRINT1("TODO: Check the next drive!\n");
-
-#if 0
- /* Check for first usable entry on next disk */
- if (List->CurrentDisk != NULL)
+ /* Search for the first partition entry on the next disk */
+ DiskListEntry = List->CurrentDisk->ListEntry.Flink;
+ while (DiskListEntry != &List->DiskListHead)
{
- Entry1 = List->CurrentDisk->ListEntry.Flink;
- while (Entry1 != &List->DiskListHead)
- {
- DiskEntry = CONTAINING_RECORD(Entry1, DISKENTRY, ListEntry);
+ DiskEntry = CONTAINING_RECORD(DiskListEntry, DISKENTRY, ListEntry);
- Entry2 = DiskEntry->PartListHead.Flink;
- if (Entry2 != &DiskEntry->PartListHead)
- {
- PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
-
- List->CurrentDisk = DiskEntry;
- List->CurrentPartition = PartEntry;
- DrawPartitionList(List);
- return;
- }
+ PartListEntry = DiskEntry->PrimaryPartListHead.Flink;
+ if (PartListEntry != &DiskEntry->PrimaryPartListHead)
+ {
+ PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
- Entry1 = Entry1->Flink;
+ List->CurrentDisk = DiskEntry;
+ List->CurrentPartition = PartEntry;
+ return TRUE;
}
+
+ DiskListEntry = DiskListEntry->Flink;
}
-#endif
return FALSE;
}
ScrollUpPartitionList(
PPARTLIST List)
{
-// PDISKENTRY DiskEntry;
+ PLIST_ENTRY DiskListEntry;
+ PLIST_ENTRY PartListEntry;
+ PDISKENTRY DiskEntry;
PPARTENTRY PartEntry;
- PLIST_ENTRY Entry;
- /* Check for empty disks */
+ /* Fail, if no disks are available */
if (IsListEmpty(&List->DiskListHead))
return FALSE;
if (List->CurrentPartition->LogicalPartition)
{
/* Logical partition */
- Entry = List->CurrentPartition->ListEntry.Blink;
- if (Entry != &List->CurrentDisk->LogicalPartListHead)
+ PartListEntry = List->CurrentPartition->ListEntry.Blink;
+ if (PartListEntry != &List->CurrentDisk->LogicalPartListHead)
{
/* Previous logical partition */
- PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
+ PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
}
else
{
{
/* Primary or extended partition */
- Entry = List->CurrentPartition->ListEntry.Blink;
- if (Entry != &List->CurrentDisk->PrimaryPartListHead)
+ PartListEntry = List->CurrentPartition->ListEntry.Blink;
+ if (PartListEntry != &List->CurrentDisk->PrimaryPartListHead)
{
- PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
+ PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
- if (IsContainerPartition(PartEntry->PartitionType))
+ if (PartEntry->IsPartitioned == TRUE &&
+ IsContainerPartition(PartEntry->PartitionType))
{
- Entry = List->CurrentDisk->LogicalPartListHead.Blink;
- PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry);
+ PartListEntry = List->CurrentDisk->LogicalPartListHead.Blink;
+ PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
}
List->CurrentPartition = PartEntry;
}
}
- DPRINT1("TODO: Check the previous drive!\n");
-
-#if 0
- /* check for last usable entry on previous disk */
- if (List->CurrentDisk != NULL)
+ /* Search for the last partition entry on the previous disk */
+ DiskListEntry = List->CurrentDisk->ListEntry.Blink;
+ while (DiskListEntry != &List->DiskListHead)
{
- Entry1 = List->CurrentDisk->ListEntry.Blink;
- while (Entry1 != &List->DiskListHead)
+ DiskEntry = CONTAINING_RECORD(DiskListEntry, DISKENTRY, ListEntry);
+
+ PartListEntry = DiskEntry->PrimaryPartListHead.Blink;
+ if (PartListEntry != &DiskEntry->PrimaryPartListHead)
{
- DiskEntry = CONTAINING_RECORD(Entry1, DISKENTRY, ListEntry);
+ PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
- Entry2 = DiskEntry->PrimaryPartListHead.Blink;
- if (Entry2 != &DiskEntry->PrimaryPartListHead)
+ if (PartEntry->IsPartitioned == TRUE &&
+ IsContainerPartition(PartEntry->PartitionType))
{
- PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
+ PartListEntry = DiskEntry->LogicalPartListHead.Blink;
+ if (PartListEntry != &DiskEntry->LogicalPartListHead)
+ {
+ PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
+ List->CurrentDisk = DiskEntry;
+ List->CurrentPartition = PartEntry;
+ return TRUE;
+ }
+ }
+ else
+ {
List->CurrentDisk = DiskEntry;
List->CurrentPartition = PartEntry;
-
- /* Draw partition list and return */
- DrawPartitionList(List);
- return;
+ return TRUE;
}
-
- Entry1 = Entry1->Blink;
}
+
+ DiskListEntry = DiskListEntry->Blink;
}
-#endif
return FALSE;
}
ULONG Index = 0;
ULONG PartitionNumber = 1;
-DPRINT1("UpdateDiskLayout()\n");
+ DPRINT1("UpdateDiskLayout()\n");
ListEntry = DiskEntry->PrimaryPartListHead.Flink;
while (ListEntry != &DiskEntry->PrimaryPartListHead)
if (!IsSamePrimaryLayoutEntry(PartitionInfo, DiskEntry, PartEntry))
{
-DPRINT1("Updating partition entry %lu\n", Index);
+ DPRINT1("Updating partition entry %lu\n", Index);
+
PartitionInfo->StartingOffset.QuadPart = PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector;
PartitionInfo->PartitionLength.QuadPart = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
PartitionInfo->HiddenSectors = 0;
if (!IsEmptyLayoutEntry(PartitionInfo))
{
-DPRINT1("Wiping partition entry %lu\n", Index);
+ DPRINT1("Wiping partition entry %lu\n", Index);
+
PartitionInfo->StartingOffset.QuadPart = 0;
PartitionInfo->PartitionLength.QuadPart = 0;
PartitionInfo->HiddenSectors = 0;
DiskEntry = List->CurrentDisk;
PartEntry = List->CurrentPartition;
-DPRINT1("Current partition sector count: %I64u\n", PartEntry->SectorCount.QuadPart);
+ DPRINT1("Current partition sector count: %I64u\n", PartEntry->SectorCount.QuadPart);
if (AutoCreate == TRUE ||
Align(PartEntry->StartSector.QuadPart + SectorCount, DiskEntry->SectorAlignment) - PartEntry->StartSector.QuadPart == PartEntry->SectorCount.QuadPart)
{
-DPRINT1("Convert existing partition entry\n");
+ DPRINT1("Convert existing partition entry\n");
+
/* Convert current entry to 'new (unformatted)' */
PartEntry->IsPartitioned = TRUE;
PartEntry->PartitionType = PARTITION_ENTRY_UNUSED;
PartEntry->FormatState = Unformatted;
PartEntry->AutoCreate = AutoCreate;
PartEntry->New = TRUE;
- PartEntry->BootIndicator = FALSE; /* FIXME */
+ PartEntry->BootIndicator = FALSE;
-DPRINT1("First Sector: %I64u\n", PartEntry->StartSector.QuadPart);
-DPRINT1("Last Sector: %I64u\n", PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - 1);
-DPRINT1("Total Sectors: %I64u\n", PartEntry->SectorCount.QuadPart);
+ DPRINT1("First Sector: %I64u\n", PartEntry->StartSector.QuadPart);
+ DPRINT1("Last Sector: %I64u\n", PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - 1);
+ DPRINT1("Total Sectors: %I64u\n", PartEntry->SectorCount.QuadPart);
}
else
{
-DPRINT1("Add new partition entry\n");
+ DPRINT1("Add new partition entry\n");
/* Insert and initialize a new partition entry */
NewPartEntry = RtlAllocateHeap(ProcessHeap,
NewPartEntry->StartSector.QuadPart;
NewPartEntry->PartitionType = PARTITION_ENTRY_UNUSED;
-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);
+ 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);
NewPartEntry->New = TRUE;
NewPartEntry->FormatState = Unformatted;
- NewPartEntry->BootIndicator = FALSE; /* FIXME */
+ NewPartEntry->BootIndicator = FALSE;
PartEntry->StartSector.QuadPart = NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart;
PartEntry->SectorCount.QuadPart -= (PartEntry->StartSector.QuadPart - NewPartEntry->StartSector.QuadPart);
NewPartEntry->LogicalPartition = TRUE;
NewPartEntry->IsPartitioned = FALSE;
- NewPartEntry->StartSector.QuadPart = DiskEntry->ExtendedPartition->StartSector.QuadPart + (ULONGLONG)DiskEntry->SectorsPerTrack;
- NewPartEntry->SectorCount.QuadPart = DiskEntry->ExtendedPartition->SectorCount.QuadPart - (ULONGLONG)DiskEntry->SectorsPerTrack;
+ NewPartEntry->StartSector.QuadPart = DiskEntry->ExtendedPartition->StartSector.QuadPart + (ULONGLONG)DiskEntry->SectorAlignment;
+ NewPartEntry->SectorCount.QuadPart = DiskEntry->ExtendedPartition->SectorCount.QuadPart - (ULONGLONG)DiskEntry->SectorAlignment;
DPRINT1("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart);
DPRINT1("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1);
DiskEntry = List->CurrentDisk;
PartEntry = List->CurrentPartition;
-DPRINT1("Current partition sector count: %I64u\n", PartEntry->SectorCount.QuadPart);
+ DPRINT1("Current partition sector count: %I64u\n", PartEntry->SectorCount.QuadPart);
if (Align(PartEntry->StartSector.QuadPart + SectorCount, DiskEntry->SectorAlignment) - PartEntry->StartSector.QuadPart == PartEntry->SectorCount.QuadPart)
{
-DPRINT1("Convert existing partition entry\n");
+ DPRINT1("Convert existing partition entry\n");
+
/* Convert current entry to 'new (unformatted)' */
PartEntry->IsPartitioned = TRUE;
PartEntry->FormatState = Formatted;
PartEntry->AutoCreate = FALSE;
PartEntry->New = FALSE;
- PartEntry->BootIndicator = FALSE; /* FIXME */
+ PartEntry->BootIndicator = FALSE;
if (PartEntry->StartSector.QuadPart < 1450560)
{
DiskEntry->ExtendedPartition = PartEntry;
-DPRINT1("First Sector: %I64u\n", PartEntry->StartSector.QuadPart);
-DPRINT1("Last Sector: %I64u\n", PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - 1);
-DPRINT1("Total Sectors: %I64u\n", PartEntry->SectorCount.QuadPart);
+ DPRINT1("First Sector: %I64u\n", PartEntry->StartSector.QuadPart);
+ DPRINT1("Last Sector: %I64u\n", PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - 1);
+ DPRINT1("Total Sectors: %I64u\n", PartEntry->SectorCount.QuadPart);
}
else
{
-DPRINT1("Add new partition entry\n");
+ DPRINT1("Add new partition entry\n");
/* Insert and initialize a new partition entry */
NewPartEntry = RtlAllocateHeap(ProcessHeap,
NewPartEntry->New = FALSE;
NewPartEntry->FormatState = Formatted;
- NewPartEntry->BootIndicator = FALSE; /* FIXME */
+ NewPartEntry->BootIndicator = FALSE;
if (NewPartEntry->StartSector.QuadPart < 1450560)
{
PartEntry->StartSector.QuadPart = NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart;
PartEntry->SectorCount.QuadPart -= (PartEntry->StartSector.QuadPart - 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);
+ 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);
}
AddLogicalDiskSpace(DiskEntry);
{
/* 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;
}