Implemented partition creation and deletion on the internal partition list.

Moved some functions from usetup.c to partlist.c.
Removed unused code.

svn path=/trunk/; revision=5440
This commit is contained in:
Eric Kohl 2003-08-06 16:37:46 +00:00
parent 1e452928ca
commit 3b90d80a10
3 changed files with 223 additions and 445 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: partlist.c,v 1.14 2003/08/05 20:39:24 ekohl Exp $ /* $Id: partlist.c,v 1.15 2003/08/06 16:37:46 ekohl Exp $
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS text-mode setup * PROJECT: ReactOS text-mode setup
* FILE: subsys/system/usetup/partlist.c * FILE: subsys/system/usetup/partlist.c
@ -688,7 +688,7 @@ PrintPartitionData(PPARTLIST List,
if (PartType == NULL) if (PartType == NULL)
{ {
sprintf (LineBuffer, sprintf (LineBuffer,
"%c%c Type %-3lu %6I64u %s", "%c%c Type %-3lu %6I64u %s",
(PartEntry->DriveLetter == 0) ? '-' : PartEntry->DriveLetter, (PartEntry->DriveLetter == 0) ? '-' : PartEntry->DriveLetter,
(PartEntry->DriveLetter == 0) ? '-' : ':', (PartEntry->DriveLetter == 0) ? '-' : ':',
PartEntry->PartInfo[0].PartitionType, PartEntry->PartInfo[0].PartitionType,
@ -1092,348 +1092,221 @@ GetActiveBootPartition(PPARTLIST List,
} }
BOOLEAN VOID
CreateSelectedPartition(PPARTLIST List, CreateNewPartition (PPARTLIST List,
ULONG PartType, ULONGLONG PartitionSize)
ULONGLONG NewPartSize)
{ {
#if 0
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
ULONG PartEntryNumber; PPARTENTRY PrevPartEntry;
OBJECT_ATTRIBUTES ObjectAttributes; PPARTENTRY NextPartEntry;
DRIVE_LAYOUT_INFORMATION *LayoutBuffer; PPARTENTRY NewPartEntry;
IO_STATUS_BLOCK Iosb;
NTSTATUS Status; if (List == NULL ||
WCHAR Buffer[MAX_PATH]; List->CurrentDisk == NULL ||
UNICODE_STRING Name; List->CurrentPartition == NULL ||
HANDLE FileHandle; List->CurrentPartition->Unpartitioned == FALSE)
LARGE_INTEGER li; {
return;
}
DiskEntry = List->CurrentDisk; DiskEntry = List->CurrentDisk;
PartEntry = List->CurrentPartition; PartEntry = List->CurrentPartition;
PartEntry->PartType = PartType; if (PartitionSize == PartEntry->UnpartitionedLength)
PartEntryNumber = List->CurrentPartition;
DPRINT("NewPartSize %d (%d MB)\n", NewPartSize, NewPartSize / (1024 * 1024));
DPRINT("PartEntry->StartingOffset %d\n", PartEntry->StartingOffset);
DPRINT("PartEntry->PartSize %d\n", PartEntry->PartSize);
DPRINT("PartEntry->PartNumber %d\n", PartEntry->PartNumber);
DPRINT("PartEntry->PartType 0x%x\n", PartEntry->PartType);
DPRINT("PartEntry->FileSystemName %s\n", PartEntry->FileSystemName);
swprintf(Buffer,
L"\\Device\\Harddisk%d\\Partition0",
DiskEntry->DiskNumber);
RtlInitUnicodeString(&Name, Buffer);
InitializeObjectAttributes(&ObjectAttributes,
&Name,
0,
NULL,
NULL);
Status = NtOpenFile(&FileHandle,
0x10001,
&ObjectAttributes,
&Iosb,
1,
FILE_SYNCHRONOUS_IO_NONALERT);
if (NT_SUCCESS(Status))
{ {
LayoutBuffer = (DRIVE_LAYOUT_INFORMATION*)RtlAllocateHeap(ProcessHeap, 0, 8192); /* Convert current entry to 'new (unformatted)' */
PartEntry->PartInfo[0].StartingOffset.QuadPart =
PartEntry->UnpartitionedOffset + DiskEntry->TrackSize;
PartEntry->PartInfo[0].PartitionLength.QuadPart =
PartEntry->UnpartitionedLength - DiskEntry->TrackSize;
PartEntry->PartInfo[0].PartitionType = PARTITION_ENTRY_UNUSED;
PartEntry->PartInfo[0].BootIndicator = FALSE; /* FIXME */
PartEntry->PartInfo[0].RewritePartition = TRUE;
Status = NtDeviceIoControlFile(FileHandle, /* Check for previous partition entry */
NULL, if (PartEntry->ListEntry.Blink != &DiskEntry->PartListHead)
NULL, {
NULL, PrevPartEntry = CONTAINING_RECORD (PartEntry->ListEntry.Blink,
&Iosb, PARTENTRY,
IOCTL_DISK_GET_DRIVE_LAYOUT, ListEntry);
NULL,
0,
LayoutBuffer,
8192);
if (!NT_SUCCESS(Status))
{
DPRINT("IOCTL_DISK_GET_DRIVE_LAYOUT failed() 0x%.08x\n", Status);
NtClose(FileHandle);
RtlFreeHeap(ProcessHeap, 0, LayoutBuffer);
return FALSE;
}
li.QuadPart = PartEntry->StartingOffset;
LayoutBuffer->PartitionEntry[PartEntryNumber].StartingOffset = li;
/* FIXME: Adjust PartitionLength so the partition will end on the last sector of a track */
li.QuadPart = NewPartSize;
LayoutBuffer->PartitionEntry[PartEntryNumber].PartitionLength = li;
LayoutBuffer->PartitionEntry[PartEntryNumber].HiddenSectors =
PartEntry->StartingOffset / DiskEntry->BytesPerSector;
LayoutBuffer->PartitionEntry[PartEntryNumber].PartitionType = PartType;
LayoutBuffer->PartitionEntry[PartEntryNumber].RecognizedPartition = TRUE;
LayoutBuffer->PartitionEntry[PartEntryNumber].RewritePartition = TRUE;
Status = NtDeviceIoControlFile(FileHandle, /* FIXME: Update extended partition entries */
NULL,
NULL,
NULL, }
&Iosb,
IOCTL_DISK_SET_DRIVE_LAYOUT, PartEntry->New = TRUE;
LayoutBuffer, PartEntry->Unpartitioned = FALSE;
8192, PartEntry->UnpartitionedOffset = 0ULL;
NULL, PartEntry->UnpartitionedLength = 0ULL;
0);
if (!NT_SUCCESS(Status))
{
DPRINT("IOCTL_DISK_SET_DRIVE_LAYOUT failed() 0x%.08x\n", Status);
NtClose(FileHandle);
RtlFreeHeap(ProcessHeap, 0, LayoutBuffer);
return FALSE;
}
} }
else else
{ {
DPRINT("NtOpenFile failed() 0x%.08x\n", Status); /* Insert an initialize a new partition entry */
NtClose(FileHandle); NewPartEntry = (PPARTENTRY)RtlAllocateHeap (ProcessHeap,
RtlFreeHeap(ProcessHeap, 0, LayoutBuffer); 0,
return FALSE; sizeof(PARTENTRY));
if (NewPartEntry == NULL)
return;
RtlZeroMemory (NewPartEntry,
sizeof(PARTENTRY));
/* Insert the new entry into the list */
InsertTailList (&PartEntry->ListEntry,
&NewPartEntry->ListEntry);
NewPartEntry->New = TRUE;
NewPartEntry->PartInfo[0].StartingOffset.QuadPart =
PartEntry->UnpartitionedOffset + DiskEntry->TrackSize;
NewPartEntry->PartInfo[0].PartitionLength.QuadPart =
PartitionSize - DiskEntry->TrackSize;
NewPartEntry->PartInfo[0].PartitionType = PARTITION_ENTRY_UNUSED;
NewPartEntry->PartInfo[0].BootIndicator = FALSE; /* FIXME */
NewPartEntry->PartInfo[0].RewritePartition = TRUE;
/* FIXME: Update extended partition entries */
/* Update offset and size of the remaining unpartitioned disk space */
PartEntry->UnpartitionedOffset += PartitionSize;
PartEntry->UnpartitionedLength -= PartitionSize;
} }
NtClose(FileHandle); DiskEntry->Modified = TRUE;
RtlFreeHeap(ProcessHeap, 0, LayoutBuffer);
#endif /* FIXME: Update partition numbers and drive letters */
return TRUE;
} }
BOOLEAN VOID
DeleteSelectedPartition(PPARTLIST List) DeleteCurrentPartition (PPARTLIST List)
{ {
#if 0
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
// ULONG PartEntryNumber; PPARTENTRY PrevPartEntry;
OBJECT_ATTRIBUTES ObjectAttributes; PPARTENTRY NextPartEntry;
DRIVE_LAYOUT_INFORMATION *LayoutBuffer;
IO_STATUS_BLOCK Iosb; if (List == NULL ||
NTSTATUS Status; List->CurrentDisk == NULL ||
WCHAR Buffer[MAX_PATH]; List->CurrentPartition == NULL ||
UNICODE_STRING Name; List->CurrentPartition->Unpartitioned == TRUE)
HANDLE FileHandle; {
LARGE_INTEGER li; return;
}
DiskEntry = List->CurrentDisk; DiskEntry = List->CurrentDisk;
PartEntry = List->CurrentPartition; PartEntry = List->CurrentPartition;
PartEntry->PartType = PARTITION_ENTRY_UNUSED;
// PartEntryNumber = List->CurrentPartition; /* Get pointer to previous partition entry */
PrevPartEntry = NULL;
DPRINT1("DeleteSelectedPartition(PartEntryNumber = %d)\n", PartEntryNumber); if (PartEntry->ListEntry.Blink != &DiskEntry->PartListHead)
DPRINT1("PartEntry->StartingOffset %d\n", PartEntry->StartingOffset);
DPRINT1("PartEntry->PartSize %d\n", PartEntry->PartSize);
DPRINT1("PartEntry->PartNumber %d\n", PartEntry->PartNumber);
DPRINT1("PartEntry->PartType 0x%x\n", PartEntry->PartType);
DPRINT1("PartEntry->FileSystemName %s\n", PartEntry->FileSystemName);
swprintf(Buffer,
L"\\Device\\Harddisk%d\\Partition0",
DiskEntry->DiskNumber);
RtlInitUnicodeString(&Name, Buffer);
InitializeObjectAttributes(&ObjectAttributes,
&Name,
0,
NULL,
NULL);
Status = NtOpenFile(&FileHandle,
0x10001,
&ObjectAttributes,
&Iosb,
1,
FILE_SYNCHRONOUS_IO_NONALERT);
if (NT_SUCCESS(Status))
{ {
LayoutBuffer = (DRIVE_LAYOUT_INFORMATION*)RtlAllocateHeap(ProcessHeap, 0, 8192); PrevPartEntry = CONTAINING_RECORD (PartEntry->ListEntry.Blink,
PARTENTRY,
ListEntry);
}
Status = NtDeviceIoControlFile(FileHandle, /* Get pointer to previous partition entry */
NULL, NextPartEntry = NULL;
NULL, if (PartEntry->ListEntry.Flink != &DiskEntry->PartListHead)
NULL, {
&Iosb, NextPartEntry = CONTAINING_RECORD (PartEntry->ListEntry.Flink,
IOCTL_DISK_GET_DRIVE_LAYOUT, PARTENTRY,
NULL, ListEntry);
0, }
LayoutBuffer,
8192);
if (!NT_SUCCESS(Status))
{
DPRINT("IOCTL_DISK_GET_DRIVE_LAYOUT failed() 0x%.08x\n", Status);
NtClose(FileHandle);
RtlFreeHeap(ProcessHeap, 0, LayoutBuffer);
return FALSE;
}
li.QuadPart = 0; if ((PrevPartEntry != NULL && PrevPartEntry->Unpartitioned == TRUE) &&
LayoutBuffer->PartitionEntry[PartEntryNumber].StartingOffset = li; (NextPartEntry != NULL && NextPartEntry->Unpartitioned == TRUE))
li.QuadPart = 0; {
LayoutBuffer->PartitionEntry[PartEntryNumber].PartitionLength = li; /* Merge previous, current and next entry */
LayoutBuffer->PartitionEntry[PartEntryNumber].HiddenSectors = 0;
LayoutBuffer->PartitionEntry[PartEntryNumber].PartitionType = 0;
LayoutBuffer->PartitionEntry[PartEntryNumber].RecognizedPartition = FALSE;
LayoutBuffer->PartitionEntry[PartEntryNumber].RewritePartition = TRUE;
Status = NtDeviceIoControlFile(FileHandle, /* Adjust the previous entries length */
NULL, PrevPartEntry->UnpartitionedLength +=
NULL, (PartEntry->PartInfo[0].PartitionLength.QuadPart + DiskEntry->TrackSize +
NULL, NextPartEntry->UnpartitionedLength);
&Iosb,
IOCTL_DISK_SET_DRIVE_LAYOUT, /* FIXME: Container entries ?? */
LayoutBuffer,
8192, /* Remove the current entry */
NULL, RemoveEntryList (&PartEntry->ListEntry);
0); RtlFreeHeap (ProcessHeap,
if (!NT_SUCCESS(Status)) 0,
{ PartEntry);
DPRINT("IOCTL_DISK_SET_DRIVE_LAYOUT failed() 0x%.08x\n", Status);
NtClose(FileHandle); /* Remove the next entry */
RtlFreeHeap(ProcessHeap, 0, LayoutBuffer); RemoveEntryList (&NextPartEntry->ListEntry);
return FALSE; RtlFreeHeap (ProcessHeap,
} 0,
NextPartEntry);
/* Update current partition */
List->CurrentPartition = PrevPartEntry;
}
else if (PrevPartEntry != NULL && PrevPartEntry->Unpartitioned == TRUE)
{
/* Merge current and previous entry */
/* Adjust the previous entries length */
PrevPartEntry->UnpartitionedLength +=
(PartEntry->PartInfo[0].PartitionLength.QuadPart + DiskEntry->TrackSize);
/* FIXME: Container entries ?? */
/* Remove the current entry */
RemoveEntryList (&PartEntry->ListEntry);
RtlFreeHeap (ProcessHeap,
0,
PartEntry);
/* Update current partition */
List->CurrentPartition = PrevPartEntry;
}
else if (NextPartEntry != NULL && NextPartEntry->Unpartitioned == TRUE)
{
/* Merge current and next entry */
/* Adjust the next entries offset and length */
NextPartEntry->UnpartitionedOffset =
PartEntry->PartInfo[0].StartingOffset.QuadPart - DiskEntry->TrackSize;
NextPartEntry->UnpartitionedLength +=
(PartEntry->PartInfo[0].PartitionLength.QuadPart + DiskEntry->TrackSize);
/* FIXME: Container entries ?? */
/* Remove the current entry */
RemoveEntryList (&PartEntry->ListEntry);
RtlFreeHeap (ProcessHeap,
0,
PartEntry);
/* Update current partition */
List->CurrentPartition = NextPartEntry;
} }
else else
{ {
DPRINT("NtOpenFile failed() 0x%.08x\n", Status); /* Nothing to merge but change current entry */
NtClose(FileHandle); PartEntry->New = FALSE;
RtlFreeHeap(ProcessHeap, 0, LayoutBuffer); PartEntry->Unpartitioned = TRUE;
return FALSE; PartEntry->UnpartitionedOffset =
PartEntry->PartInfo[0].StartingOffset.QuadPart - DiskEntry->TrackSize;
PartEntry->UnpartitionedLength =
PartEntry->PartInfo[0].PartitionLength.QuadPart + DiskEntry->TrackSize;
/* FIXME: Container entries ?? */
/* Wipe the partition table */
RtlZeroMemory (&PartEntry->PartInfo,
sizeof(PartEntry->PartInfo));
} }
NtClose(FileHandle); DiskEntry->Modified = TRUE;
RtlFreeHeap(ProcessHeap, 0, LayoutBuffer);
#endif /* FIXME: Update partition numbers and drive letters */
return TRUE;
} }
#if 0
BOOLEAN
MarkPartitionActive (ULONG DiskNumber,
ULONG PartitionNumber,
PPARTDATA ActivePartition)
{
PPARTLIST List;
PPARTENTRY PartEntry;
ULONG PartEntryNumber;
OBJECT_ATTRIBUTES ObjectAttributes;
DRIVE_LAYOUT_INFORMATION *LayoutBuffer;
IO_STATUS_BLOCK Iosb;
NTSTATUS Status;
WCHAR Buffer[MAX_PATH];
UNICODE_STRING Name;
HANDLE FileHandle;
List = InitializePartitionList ();
if (List == NULL)
{
return(FALSE);
}
PartEntry = GetPartitionInformation(List,
DiskNumber,
PartitionNumber,
&PartEntryNumber);
if (List == NULL)
{
DestroyPartitionList(List);
return(FALSE);
}
swprintf(Buffer,
L"\\Device\\Harddisk%d\\Partition0",
DiskNumber);
RtlInitUnicodeString(&Name, Buffer);
InitializeObjectAttributes(&ObjectAttributes,
&Name,
0,
NULL,
NULL);
Status = NtOpenFile(&FileHandle,
0x10001,
&ObjectAttributes,
&Iosb,
1,
FILE_SYNCHRONOUS_IO_NONALERT);
if (NT_SUCCESS(Status))
{
LayoutBuffer = (DRIVE_LAYOUT_INFORMATION*)RtlAllocateHeap(ProcessHeap, 0, 8192);
Status = NtDeviceIoControlFile(FileHandle,
NULL,
NULL,
NULL,
&Iosb,
IOCTL_DISK_GET_DRIVE_LAYOUT,
NULL,
0,
LayoutBuffer,
8192);
if (!NT_SUCCESS(Status))
{
NtClose(FileHandle);
RtlFreeHeap(ProcessHeap, 0, LayoutBuffer);
DestroyPartitionList(List);
return FALSE;
}
LayoutBuffer->PartitionEntry[PartEntryNumber].BootIndicator = TRUE;
Status = NtDeviceIoControlFile(FileHandle,
NULL,
NULL,
NULL,
&Iosb,
IOCTL_DISK_SET_DRIVE_LAYOUT,
LayoutBuffer,
8192,
NULL,
0);
if (!NT_SUCCESS(Status))
{
NtClose(FileHandle);
RtlFreeHeap(ProcessHeap, 0, LayoutBuffer);
DestroyPartitionList(List);
return FALSE;
}
}
else
{
NtClose(FileHandle);
RtlFreeHeap(ProcessHeap, 0, LayoutBuffer);
DestroyPartitionList(List);
return FALSE;
}
NtClose(FileHandle);
RtlFreeHeap(ProcessHeap, 0, LayoutBuffer);
PartEntry->Active = TRUE;
if (!GetActiveBootPartition(List, ActivePartition))
{
DestroyPartitionList(List);
DPRINT("GetActiveBootPartition() failed\n");
return FALSE;
}
DestroyPartitionList(List);
return TRUE;
}
#endif
/* EOF */ /* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: partlist.h,v 1.14 2003/08/05 20:39:24 ekohl Exp $ /* $Id: partlist.h,v 1.15 2003/08/06 16:37:46 ekohl Exp $
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS text-mode setup * PROJECT: ReactOS text-mode setup
* FILE: subsys/system/usetup/partlist.h * FILE: subsys/system/usetup/partlist.h
@ -72,6 +72,9 @@ typedef struct _DISKENTRY
USHORT Bus; USHORT Bus;
USHORT Id; USHORT Id;
/* Has the partition list been modified? */
BOOLEAN Modified;
UNICODE_STRING DriverName; UNICODE_STRING DriverName;
LIST_ENTRY PartListHead; LIST_ENTRY PartListHead;
@ -107,42 +110,34 @@ typedef struct _PARTLIST
PPARTLIST PPARTLIST
CreatePartitionList(SHORT Left, CreatePartitionList (SHORT Left,
SHORT Top, SHORT Top,
SHORT Right, SHORT Right,
SHORT Bottom); SHORT Bottom);
VOID VOID
DestroyPartitionList(PPARTLIST List); DestroyPartitionList (PPARTLIST List);
VOID VOID
DrawPartitionList(PPARTLIST List); DrawPartitionList (PPARTLIST List);
VOID VOID
ScrollDownPartitionList(PPARTLIST List); ScrollDownPartitionList (PPARTLIST List);
VOID VOID
ScrollUpPartitionList(PPARTLIST List); ScrollUpPartitionList (PPARTLIST List);
VOID VOID
GetActiveBootPartition(PPARTLIST List, GetActiveBootPartition(PPARTLIST List,
PDISKENTRY *DiskEntry, PDISKENTRY *DiskEntry,
PPARTENTRY *PartEntry); PPARTENTRY *PartEntry);
BOOLEAN VOID
CreateSelectedPartition(PPARTLIST List, CreateNewPartition (PPARTLIST List,
ULONG PartType, ULONGLONG PartitionSize);
ULONGLONG NewPartSize);
BOOLEAN VOID
DeleteSelectedPartition(PPARTLIST List); DeleteCurrentPartition (PPARTLIST List);
#if 0
BOOLEAN
MarkPartitionActive(ULONG DiskNumber,
ULONG PartitionNumber,
PPARTDATA ActivePartition);
#endif
#endif /* __PARTLIST_H__ */ #endif /* __PARTLIST_H__ */

View file

@ -1051,10 +1051,8 @@ ShowPartitionSizeInputBox(SHORT Left,
static PAGE_NUMBER static PAGE_NUMBER
CreatePartitionPage (PINPUT_RECORD Ir) CreatePartitionPage (PINPUT_RECORD Ir)
{ {
WCHAR PathBuffer[MAX_PATH];
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
BOOLEAN Valid;
SHORT xScreen; SHORT xScreen;
SHORT yScreen; SHORT yScreen;
BOOLEAN Quit; BOOLEAN Quit;
@ -1062,7 +1060,6 @@ CreatePartitionPage (PINPUT_RECORD Ir)
CHAR InputBuffer[50]; CHAR InputBuffer[50];
ULONG MaxSize; ULONG MaxSize;
ULONGLONG PartSize; ULONGLONG PartSize;
ULONGLONG DiskSize; ULONGLONG DiskSize;
PCHAR Unit; PCHAR Unit;
@ -1135,7 +1132,6 @@ CreatePartitionPage (PINPUT_RECORD Ir)
PartEntry = PartitionList->CurrentPartition; PartEntry = PartitionList->CurrentPartition;
while (TRUE) while (TRUE)
{ {
// MaxSize = PartEntry->UnpartitionedLength / (1024 * 1024); /* in MBytes */
MaxSize = (PartEntry->UnpartitionedLength + (1 << 19)) >> 20; /* in MBytes (rounded) */ MaxSize = (PartEntry->UnpartitionedLength + (1 << 19)) >> 20; /* in MBytes (rounded) */
ShowPartitionSizeInputBox (12, 14, xScreen - 12, 17, /* left, top, right, bottom */ ShowPartitionSizeInputBox (12, 14, xScreen - 12, 17, /* left, top, right, bottom */
MaxSize, InputBuffer, &Quit, &Cancel); MaxSize, InputBuffer, &Quit, &Cancel);
@ -1152,7 +1148,7 @@ CreatePartitionPage (PINPUT_RECORD Ir)
} }
else else
{ {
PartSize = atoi(InputBuffer); PartSize = atoi (InputBuffer);
if (PartSize < 1) if (PartSize < 1)
{ {
/* Too small */ /* Too small */
@ -1182,93 +1178,11 @@ CreatePartitionPage (PINPUT_RECORD Ir)
PartSize = PartEntry->UnpartitionedLength; PartSize = PartEntry->UnpartitionedLength;
} }
if (PartSize == PartEntry->UnpartitionedLength) DPRINT ("Partition size: %I64u bytes\n", PartSize);
{
/* FIXME: Convert current entry to 'new (unformatted)' */
PartEntry->PartInfo[0].StartingOffset.QuadPart =
PartEntry->UnpartitionedOffset + DiskEntry->TrackSize;
PartEntry->PartInfo[0].PartitionLength.QuadPart =
PartEntry->UnpartitionedLength - DiskEntry->TrackSize;
PartEntry->PartInfo[0].PartitionType = PARTITION_ENTRY_UNUSED;
PartEntry->PartInfo[0].BootIndicator = FALSE; /* FIXME */
PartEntry->PartInfo[0].RewritePartition = TRUE;
/* FIXME: Update extended partition entries */ CreateNewPartition (PartitionList,
PartSize);
PartEntry->New = TRUE;
PartEntry->Unpartitioned = FALSE;
PartEntry->UnpartitionedOffset = 0ULL;
PartEntry->UnpartitionedLength = 0ULL;
}
else
{
/*
* FIXME:
* Insert new 'new (unformatted)' entry before the
* current entry and adjust offsets and sizes.
*/
}
DPRINT1 ("Partition size: %I64u bytes\n", PartSize);
PopupError ("Entered valid partition size!\n"
"\n"
" * Press any key to continue.",
NULL);
ConInKey (Ir);
#if 0
PartEntry->PartType = PARTITION_ENTRY_UNUSED;
PartEntry->Used = TRUE;
PartDataValid = GetSelectedPartition(PartList,
&PartData);
if (PartDataValid)
{
PartData.CreatePartition = TRUE;
PartData.NewPartSize = PartSize;
ActivePartitionValid = GetActiveBootPartition(PartList,
&ActivePartition);
RtlFreeUnicodeString(&DestinationRootPath);
swprintf(PathBuffer,
L"\\Device\\Harddisk%lu\\Partition%lu",
DiskEntry->DiskNumber,
PartData.PartNumber);
RtlCreateUnicodeString(&DestinationRootPath,
PathBuffer);
RtlFreeUnicodeString(&SystemRootPath);
if (ActivePartitionValid)
{
swprintf(PathBuffer,
L"\\Device\\Harddisk%lu\\Partition%lu",
ActivePartition.DiskNumber,
ActivePartition.PartNumber);
}
else
{
/* We mark the selected partition as bootable */
swprintf(PathBuffer,
L"\\Device\\Harddisk%lu\\Partition%lu",
DiskEntry->DiskNumber,
PartData.PartNumber);
}
RtlCreateUnicodeString(&SystemRootPath,
PathBuffer);
return(SELECT_FILE_SYSTEM_PAGE);
}
else
{
/* FIXME: show an error dialog */
return(SELECT_PARTITION_PAGE);
}
#endif
return SELECT_PARTITION_PAGE; return SELECT_PARTITION_PAGE;
} }
} }
@ -1298,7 +1212,7 @@ DeletePartitionPage (PINPUT_RECORD Ir)
DiskEntry = PartitionList->CurrentDisk; DiskEntry = PartitionList->CurrentDisk;
PartEntry = PartitionList->CurrentPartition; PartEntry = PartitionList->CurrentPartition;
SetTextXY(6, 8, "You have chosen to delete the partition"); SetTextXY (6, 8, "You have chosen to delete the partition");
/* Determine partition type */ /* Determine partition type */
PartType = NULL; PartType = NULL;
@ -1348,7 +1262,6 @@ DeletePartitionPage (PINPUT_RECORD Ir)
if (PartType == NULL) if (PartType == NULL)
{ {
PrintTextXY (6, 10, PrintTextXY (6, 10,
// " %c%c Type %-3lu %6I64u %s",
" %c%c Type %lu %I64u %s", " %c%c Type %lu %I64u %s",
(PartEntry->DriveLetter == 0) ? '-' : PartEntry->DriveLetter, (PartEntry->DriveLetter == 0) ? '-' : PartEntry->DriveLetter,
(PartEntry->DriveLetter == 0) ? '-' : ':', (PartEntry->DriveLetter == 0) ? '-' : ':',
@ -1359,7 +1272,6 @@ DeletePartitionPage (PINPUT_RECORD Ir)
else else
{ {
PrintTextXY (6, 10, PrintTextXY (6, 10,
// " %c%c %-8s %6I64u %s",
" %c%c %s %I64u %s", " %c%c %s %I64u %s",
(PartEntry->DriveLetter == 0) ? '-' : PartEntry->DriveLetter, (PartEntry->DriveLetter == 0) ? '-' : PartEntry->DriveLetter,
(PartEntry->DriveLetter == 0) ? '-' : ':', (PartEntry->DriveLetter == 0) ? '-' : ':',
@ -1407,21 +1319,21 @@ DeletePartitionPage (PINPUT_RECORD Ir)
DiskEntry->Id); DiskEntry->Id);
} }
SetTextXY(8, 18, "\x07 Press D to delete the partition."); SetTextXY (8, 18, "\x07 Press D to delete the partition.");
SetTextXY(11, 19, "WARNING: All data on this partition will be lost!"); SetTextXY (11, 19, "WARNING: All data on this partition will be lost!");
SetTextXY(8, 21, "\x07 Press ESC to cancel."); SetTextXY (8, 21, "\x07 Press ESC to cancel.");
SetStatusText(" D = Delete Partition ESC = Cancel F3 = Quit"); SetStatusText (" D = Delete Partition ESC = Cancel F3 = Quit");
while(TRUE) while (TRUE)
{ {
ConInKey(Ir); ConInKey (Ir);
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) && if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */ (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
{ {
if (ConfirmQuit(Ir) == TRUE) if (ConfirmQuit (Ir) == TRUE)
{ {
return QUIT_PAGE; return QUIT_PAGE;
} }
@ -1433,11 +1345,7 @@ DeletePartitionPage (PINPUT_RECORD Ir)
} }
else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_D) /* D */ else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_D) /* D */
{ {
/* FIXME: delete partition here! */ DeleteCurrentPartition (PartitionList);
#if 0
DeleteSelectedPartition(CurrentPartitionList);
#endif
return SELECT_PARTITION_PAGE; return SELECT_PARTITION_PAGE;
} }
@ -1578,7 +1486,7 @@ SelectFileSystemPage (PINPUT_RECORD Ir)
PartitionList->CurrentPartition == NULL) PartitionList->CurrentPartition == NULL)
{ {
/* FIXME: show an error dialog */ /* FIXME: show an error dialog */
return(QUIT_PAGE); return QUIT_PAGE;
} }
DiskEntry = PartitionList->CurrentDisk; DiskEntry = PartitionList->CurrentDisk;
@ -1674,44 +1582,46 @@ SelectFileSystemPage (PINPUT_RECORD Ir)
DrawFileSystemList (FileSystemList); DrawFileSystemList (FileSystemList);
} }
SetStatusText(" ENTER = Continue ESC = Cancel F3 = Quit"); SetStatusText (" ENTER = Continue ESC = Cancel F3 = Quit");
while(TRUE) while (TRUE)
{ {
ConInKey(Ir); ConInKey (Ir);
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) && if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */ (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
{ {
if (ConfirmQuit(Ir) == TRUE) if (ConfirmQuit(Ir) == TRUE)
return(QUIT_PAGE); {
return QUIT_PAGE;
}
break; break;
} }
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) && else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE)) /* ESC */ (Ir->Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE)) /* ESC */
{ {
DestroyFileSystemList(FileSystemList); DestroyFileSystemList (FileSystemList);
return(SELECT_PARTITION_PAGE); return SELECT_PARTITION_PAGE;
} }
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) && else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */ (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
{ {
ScrollDownFileSystemList(FileSystemList); ScrollDownFileSystemList (FileSystemList);
} }
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) && else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */ (Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
{ {
ScrollUpFileSystemList(FileSystemList); ScrollUpFileSystemList (FileSystemList);
} }
else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RETURN) /* ENTER */ else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RETURN) /* ENTER */
{ {
if (FileSystemList->CurrentFileSystem == FsKeep) if (FileSystemList->CurrentFileSystem == FsKeep)
{ {
return(CHECK_FILE_SYSTEM_PAGE); return CHECK_FILE_SYSTEM_PAGE;
} }
else else
{ {
return(FORMAT_PARTITION_PAGE); return FORMAT_PARTITION_PAGE;
} }
} }
} }