mirror of
https://github.com/reactos/reactos.git
synced 2024-09-04 09:39:07 +00:00
Added some cosmetical fixes.
Fixed size of trailing unused disk space. Create partition page adds partition to internal list. No on-disk changes yet. svn path=/trunk/; revision=5425
This commit is contained in:
parent
0c3a60aa71
commit
5f3ceed713
|
@ -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.13 2003/08/04 15:54:05 ekohl Exp $
|
/* $Id: partlist.c,v 1.14 2003/08/05 20:39:24 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
|
||||||
|
@ -47,6 +47,11 @@ GetDriverName(PDISKENTRY DiskEntry)
|
||||||
WCHAR KeyName[32];
|
WCHAR KeyName[32];
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
RtlCreateUnicodeString (&DiskEntry->DriverName,
|
||||||
|
L"atapi");
|
||||||
|
#endif
|
||||||
|
|
||||||
RtlInitUnicodeString(&DiskEntry->DriverName,
|
RtlInitUnicodeString(&DiskEntry->DriverName,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
@ -203,8 +208,15 @@ ScanForUnpartitionedDiskSpace (PDISKENTRY DiskEntry)
|
||||||
/* Check for trailing unpartitioned disk space */
|
/* Check for trailing unpartitioned disk space */
|
||||||
if (DiskEntry->DiskSize > (LastStartingOffset + LastPartitionLength))
|
if (DiskEntry->DiskSize > (LastStartingOffset + LastPartitionLength))
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
LastUnusedPartitionLength =
|
LastUnusedPartitionLength =
|
||||||
DiskEntry->DiskSize - (LastStartingOffset + LastPartitionLength);
|
DiskEntry->DiskSize - (LastStartingOffset + LastPartitionLength);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* FIXME: Round-down to cylinder size */
|
||||||
|
LastUnusedPartitionLength =
|
||||||
|
ROUND_DOWN (DiskEntry->DiskSize - (LastStartingOffset + LastPartitionLength),
|
||||||
|
DiskEntry->CylinderSize);
|
||||||
|
|
||||||
if (LastUnusedPartitionLength >= DiskEntry->CylinderSize)
|
if (LastUnusedPartitionLength >= DiskEntry->CylinderSize)
|
||||||
{
|
{
|
||||||
|
@ -370,9 +382,11 @@ InitializePartitionList(VOID)
|
||||||
UNICODE_STRING Name;
|
UNICODE_STRING Name;
|
||||||
HANDLE FileHandle;
|
HANDLE FileHandle;
|
||||||
|
|
||||||
List = (PPARTLIST)RtlAllocateHeap(ProcessHeap, 0, sizeof(PARTLIST));
|
List = (PPARTLIST)RtlAllocateHeap (ProcessHeap,
|
||||||
|
0,
|
||||||
|
sizeof (PARTLIST));
|
||||||
if (List == NULL)
|
if (List == NULL)
|
||||||
return(NULL);
|
return NULL;
|
||||||
|
|
||||||
List->Left = 0;
|
List->Left = 0;
|
||||||
List->Top = 0;
|
List->Top = 0;
|
||||||
|
@ -440,7 +454,10 @@ InitializePartitionList(VOID)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List->CurrentDisk = CONTAINING_RECORD(List->DiskListHead.Flink, DISKENTRY, ListEntry);
|
List->CurrentDisk =
|
||||||
|
CONTAINING_RECORD (List->DiskListHead.Flink,
|
||||||
|
DISKENTRY,
|
||||||
|
ListEntry);
|
||||||
|
|
||||||
if (IsListEmpty (&List->CurrentDisk->PartListHead))
|
if (IsListEmpty (&List->CurrentDisk->PartListHead))
|
||||||
{
|
{
|
||||||
|
@ -448,11 +465,14 @@ InitializePartitionList(VOID)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List->CurrentPartition = CONTAINING_RECORD(List->CurrentDisk->PartListHead.Flink, PARTENTRY, ListEntry);
|
List->CurrentPartition =
|
||||||
|
CONTAINING_RECORD (List->CurrentDisk->PartListHead.Flink,
|
||||||
|
PARTENTRY,
|
||||||
|
ListEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(List);
|
return List;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -466,7 +486,7 @@ CreatePartitionList(SHORT Left,
|
||||||
|
|
||||||
List = InitializePartitionList ();
|
List = InitializePartitionList ();
|
||||||
if (List == NULL)
|
if (List == NULL)
|
||||||
return(NULL);
|
return NULL;
|
||||||
|
|
||||||
List->Left = Left;
|
List->Left = Left;
|
||||||
List->Top = Top;
|
List->Top = Top;
|
||||||
|
@ -475,51 +495,7 @@ CreatePartitionList(SHORT Left,
|
||||||
|
|
||||||
DrawPartitionList (List);
|
DrawPartitionList (List);
|
||||||
|
|
||||||
return(List);
|
return List;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PPARTENTRY
|
|
||||||
GetPartitionInformation(PPARTLIST List,
|
|
||||||
ULONG DiskNumber,
|
|
||||||
ULONG PartitionNumber,
|
|
||||||
PULONG PartEntryNumber)
|
|
||||||
{
|
|
||||||
PPARTENTRY PartEntry;
|
|
||||||
ULONG i;
|
|
||||||
|
|
||||||
if (IsListEmpty(&List->DiskListHead))
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (DiskNumber >= List->DiskCount)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PartitionNumber >= List->DiskArray[DiskNumber].PartCount)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (List->DiskArray[DiskNumber].FixedDisk != TRUE)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < List->DiskArray[DiskNumber].PartCount; i++)
|
|
||||||
{
|
|
||||||
PartEntry = &List->DiskArray[DiskNumber].PartArray[i];
|
|
||||||
if (PartEntry->PartNumber == PartitionNumber)
|
|
||||||
{
|
|
||||||
*PartEntryNumber = i;
|
|
||||||
return PartEntry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -635,8 +611,6 @@ PrintPartitionData(PPARTLIST List,
|
||||||
coPos.X = List->Left + 1;
|
coPos.X = List->Left + 1;
|
||||||
coPos.Y = List->Top + 1 + List->Line;
|
coPos.Y = List->Top + 1 + List->Line;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (PartEntry->Unpartitioned == TRUE)
|
if (PartEntry->Unpartitioned == TRUE)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -668,7 +642,11 @@ PrintPartitionData(PPARTLIST List,
|
||||||
|
|
||||||
/* Determine partition type */
|
/* Determine partition type */
|
||||||
PartType = NULL;
|
PartType = NULL;
|
||||||
if (PartEntry->Unpartitioned == FALSE)
|
if (PartEntry->New == TRUE)
|
||||||
|
{
|
||||||
|
PartType = "New (Unformatted)";
|
||||||
|
}
|
||||||
|
else if (PartEntry->Unpartitioned == FALSE)
|
||||||
{
|
{
|
||||||
if ((PartEntry->PartInfo[0].PartitionType == PARTITION_FAT_12) ||
|
if ((PartEntry->PartInfo[0].PartitionType == PARTITION_FAT_12) ||
|
||||||
(PartEntry->PartInfo[0].PartitionType == PARTITION_FAT_16) ||
|
(PartEntry->PartInfo[0].PartitionType == PARTITION_FAT_16) ||
|
||||||
|
@ -707,13 +685,12 @@ PrintPartitionData(PPARTLIST List,
|
||||||
Unit = "KB";
|
Unit = "KB";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PartEntry->DriveLetter != (CHAR)0)
|
|
||||||
{
|
|
||||||
if (PartType == NULL)
|
if (PartType == NULL)
|
||||||
{
|
{
|
||||||
sprintf (LineBuffer,
|
sprintf (LineBuffer,
|
||||||
"%c: Type %-3lu %6I64u %s",
|
"%c%c Type %-3lu %6I64u %s",
|
||||||
PartEntry->DriveLetter,
|
(PartEntry->DriveLetter == 0) ? '-' : PartEntry->DriveLetter,
|
||||||
|
(PartEntry->DriveLetter == 0) ? '-' : ':',
|
||||||
PartEntry->PartInfo[0].PartitionType,
|
PartEntry->PartInfo[0].PartitionType,
|
||||||
PartSize,
|
PartSize,
|
||||||
Unit);
|
Unit);
|
||||||
|
@ -721,23 +698,14 @@ PrintPartitionData(PPARTLIST List,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf (LineBuffer,
|
sprintf (LineBuffer,
|
||||||
"%c: %-8s %6I64u %s",
|
"%c%c %-24s %6I64u %s",
|
||||||
PartEntry->DriveLetter,
|
(PartEntry->DriveLetter == 0) ? '-' : PartEntry->DriveLetter,
|
||||||
|
(PartEntry->DriveLetter == 0) ? '-' : ':',
|
||||||
PartType,
|
PartType,
|
||||||
PartSize,
|
PartSize,
|
||||||
Unit);
|
Unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
sprintf(LineBuffer,
|
|
||||||
"-- %-8s Type %-3lu %6I64u %s",
|
|
||||||
PartEntry->FileSystemName,
|
|
||||||
PartEntry->PartInfo[0].PartitionType,
|
|
||||||
PartSize,
|
|
||||||
Unit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Attribute = (List->CurrentDisk == DiskEntry &&
|
Attribute = (List->CurrentDisk == DiskEntry &&
|
||||||
List->CurrentPartition == PartEntry) ? 0x71 : 0x17;
|
List->CurrentPartition == PartEntry) ? 0x71 : 0x17;
|
||||||
|
|
|
@ -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.13 2003/08/04 15:54:05 ekohl Exp $
|
/* $Id: partlist.h,v 1.14 2003/08/05 20:39:24 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
|
||||||
|
@ -36,8 +36,12 @@ typedef struct _PARTENTRY
|
||||||
CHAR VolumeLabel[17];
|
CHAR VolumeLabel[17];
|
||||||
CHAR FileSystemName[9];
|
CHAR FileSystemName[9];
|
||||||
|
|
||||||
|
/* Partition is unused disk space */
|
||||||
BOOLEAN Unpartitioned;
|
BOOLEAN Unpartitioned;
|
||||||
|
|
||||||
|
/* Partition is new. Table does not exist on disk yet */
|
||||||
|
BOOLEAN New;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Raw offset and length of the unpartitioned disk space.
|
* Raw offset and length of the unpartitioned disk space.
|
||||||
* Includes the leading, not yet existing, partition table.
|
* Includes the leading, not yet existing, partition table.
|
||||||
|
|
|
@ -869,46 +869,41 @@ DrawInputField(ULONG FieldLength,
|
||||||
memset(buf, '_', sizeof(buf));
|
memset(buf, '_', sizeof(buf));
|
||||||
buf[FieldLength - strlen(FieldContent)] = 0;
|
buf[FieldLength - strlen(FieldContent)] = 0;
|
||||||
strcat(buf, FieldContent);
|
strcat(buf, FieldContent);
|
||||||
|
|
||||||
WriteConsoleOutputCharacters (buf,
|
WriteConsoleOutputCharacters (buf,
|
||||||
strlen (buf),
|
strlen (buf),
|
||||||
coPos);
|
coPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
|
#define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
ShowPartitionSizeInputBox(ULONG MaxSize,
|
ShowPartitionSizeInputBox(SHORT Left,
|
||||||
|
SHORT Top,
|
||||||
|
SHORT Right,
|
||||||
|
SHORT Bottom,
|
||||||
|
ULONG MaxSize,
|
||||||
PCHAR InputBuffer,
|
PCHAR InputBuffer,
|
||||||
PBOOLEAN Quit,
|
PBOOLEAN Quit,
|
||||||
PBOOLEAN Cancel)
|
PBOOLEAN Cancel)
|
||||||
{
|
{
|
||||||
SHORT Left;
|
|
||||||
SHORT Top;
|
|
||||||
SHORT Right;
|
|
||||||
SHORT Bottom;
|
|
||||||
INPUT_RECORD Ir;
|
INPUT_RECORD Ir;
|
||||||
COORD coPos;
|
COORD coPos;
|
||||||
ULONG Written;
|
ULONG Written;
|
||||||
SHORT i;
|
SHORT i;
|
||||||
CHAR buf[100];
|
CHAR Buffer[100];
|
||||||
ULONG index;
|
ULONG Index;
|
||||||
CHAR ch;
|
CHAR ch;
|
||||||
SHORT iLeft;
|
SHORT iLeft;
|
||||||
SHORT iTop;
|
SHORT iTop;
|
||||||
SHORT xScreen;
|
|
||||||
SHORT yScreen;
|
|
||||||
|
|
||||||
if (Quit != NULL)
|
if (Quit != NULL)
|
||||||
*Quit = FALSE;
|
*Quit = FALSE;
|
||||||
|
|
||||||
if (Cancel != NULL)
|
if (Cancel != NULL)
|
||||||
*Cancel = FALSE;
|
*Cancel = FALSE;
|
||||||
|
|
||||||
GetScreenSize(&xScreen, &yScreen);
|
|
||||||
Left = 12;
|
|
||||||
Top = 14;
|
|
||||||
Right = xScreen - 12;
|
|
||||||
Bottom = 17;
|
|
||||||
|
|
||||||
/* draw upper left corner */
|
/* draw upper left corner */
|
||||||
coPos.X = Left;
|
coPos.X = Left;
|
||||||
coPos.Y = Top;
|
coPos.Y = Top;
|
||||||
|
@ -977,33 +972,37 @@ ShowPartitionSizeInputBox(ULONG MaxSize,
|
||||||
/* Print message */
|
/* Print message */
|
||||||
coPos.X = Left + 2;
|
coPos.X = Left + 2;
|
||||||
coPos.Y = Top + 2;
|
coPos.Y = Top + 2;
|
||||||
strcpy(buf, "Size of new partition:");
|
strcpy (Buffer, "Size of new partition:");
|
||||||
iLeft = coPos.X + strlen(buf) + 1;
|
iLeft = coPos.X + strlen (Buffer) + 1;
|
||||||
iTop = coPos.Y;
|
iTop = coPos.Y;
|
||||||
WriteConsoleOutputCharacters(buf,
|
WriteConsoleOutputCharacters (Buffer,
|
||||||
strlen(buf),
|
strlen (Buffer),
|
||||||
coPos);
|
coPos);
|
||||||
|
|
||||||
sprintf(buf, "MB (max. %d MB)", MaxSize / (1024 * 1024));
|
sprintf (Buffer, "MB (max. %d MB)", MaxSize);
|
||||||
coPos.X = iLeft + PARTITION_SIZE_INPUT_FIELD_LENGTH + 1;
|
coPos.X = iLeft + PARTITION_SIZE_INPUT_FIELD_LENGTH + 1;
|
||||||
coPos.Y = iTop;
|
coPos.Y = iTop;
|
||||||
WriteConsoleOutputCharacters(buf,
|
WriteConsoleOutputCharacters (Buffer,
|
||||||
strlen(buf),
|
strlen (Buffer),
|
||||||
coPos);
|
coPos);
|
||||||
|
|
||||||
buf[0] = 0;
|
Buffer[0] = 0;
|
||||||
index = 0;
|
Index = 0;
|
||||||
DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH, iLeft, iTop, buf);
|
DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH,
|
||||||
|
iLeft,
|
||||||
|
iTop,
|
||||||
|
Buffer);
|
||||||
|
|
||||||
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 (Quit != NULL)
|
if (Quit != NULL)
|
||||||
*Quit = TRUE;
|
*Quit = TRUE;
|
||||||
buf[0] = 0;
|
Buffer[0] = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (Ir.Event.KeyEvent.wVirtualKeyCode == VK_RETURN) /* ENTER */
|
else if (Ir.Event.KeyEvent.wVirtualKeyCode == VK_RETURN) /* ENTER */
|
||||||
|
@ -1013,39 +1012,49 @@ ShowPartitionSizeInputBox(ULONG MaxSize,
|
||||||
else if (Ir.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE) /* ESCAPE */
|
else if (Ir.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE) /* ESCAPE */
|
||||||
{
|
{
|
||||||
if (Cancel != NULL)
|
if (Cancel != NULL)
|
||||||
*Cancel = FALSE;
|
*Cancel = TRUE;
|
||||||
buf[0] = 0;
|
Buffer[0] = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if ((Ir.Event.KeyEvent.wVirtualKeyCode == VK_BACK) && (index > 0)) /* BACKSPACE */
|
else if ((Ir.Event.KeyEvent.wVirtualKeyCode == VK_BACK) && /* BACKSPACE */
|
||||||
|
(Index > 0))
|
||||||
{
|
{
|
||||||
index--;
|
Index--;
|
||||||
buf[index] = 0;
|
Buffer[Index] = 0;
|
||||||
DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH, iLeft, iTop, buf);
|
DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH,
|
||||||
|
iLeft,
|
||||||
|
iTop,
|
||||||
|
Buffer);
|
||||||
}
|
}
|
||||||
else if ((Ir.Event.KeyEvent.uChar.AsciiChar != 0x00)
|
else if ((Ir.Event.KeyEvent.uChar.AsciiChar != 0x00) &&
|
||||||
&& (index < PARTITION_SIZE_INPUT_FIELD_LENGTH))
|
(Index < PARTITION_SIZE_INPUT_FIELD_LENGTH))
|
||||||
{
|
{
|
||||||
ch = Ir.Event.KeyEvent.uChar.AsciiChar;
|
ch = Ir.Event.KeyEvent.uChar.AsciiChar;
|
||||||
if ((ch >= '0') && (ch <= '9'))
|
if ((ch >= '0') && (ch <= '9'))
|
||||||
{
|
{
|
||||||
buf[index] = ch;
|
Buffer[Index] = ch;
|
||||||
index++;
|
Index++;
|
||||||
buf[index] = 0;
|
Buffer[Index] = 0;
|
||||||
DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH, iLeft, iTop, buf);
|
DrawInputField (PARTITION_SIZE_INPUT_FIELD_LENGTH,
|
||||||
|
iLeft,
|
||||||
|
iTop,
|
||||||
|
Buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strcpy(InputBuffer, buf);
|
|
||||||
|
strcpy (InputBuffer,
|
||||||
|
Buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static PAGE_NUMBER
|
static PAGE_NUMBER
|
||||||
CreatePartitionPage (PINPUT_RECORD Ir)
|
CreatePartitionPage (PINPUT_RECORD Ir)
|
||||||
{
|
{
|
||||||
BOOLEAN Valid;
|
|
||||||
WCHAR PathBuffer[MAX_PATH];
|
WCHAR PathBuffer[MAX_PATH];
|
||||||
|
PDISKENTRY DiskEntry;
|
||||||
PPARTENTRY PartEntry;
|
PPARTENTRY PartEntry;
|
||||||
|
BOOLEAN Valid;
|
||||||
SHORT xScreen;
|
SHORT xScreen;
|
||||||
SHORT yScreen;
|
SHORT yScreen;
|
||||||
BOOLEAN Quit;
|
BOOLEAN Quit;
|
||||||
|
@ -1054,25 +1063,82 @@ CreatePartitionPage (PINPUT_RECORD Ir)
|
||||||
ULONG MaxSize;
|
ULONG MaxSize;
|
||||||
ULONGLONG PartSize;
|
ULONGLONG PartSize;
|
||||||
|
|
||||||
SetTextXY(6, 8, "You have chosen to create a new partition in the unused disk space.");
|
ULONGLONG DiskSize;
|
||||||
SetTextXY(6, 9, "Please enter the size of the new partition in megabytes.");
|
PCHAR Unit;
|
||||||
|
|
||||||
|
if (PartitionList == NULL ||
|
||||||
|
PartitionList->CurrentDisk == NULL ||
|
||||||
|
PartitionList->CurrentPartition == NULL)
|
||||||
|
{
|
||||||
|
/* FIXME: show an error dialog */
|
||||||
|
return QUIT_PAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DiskEntry = PartitionList->CurrentDisk;
|
||||||
|
PartEntry = PartitionList->CurrentPartition;
|
||||||
|
|
||||||
|
SetStatusText (" Please wait...");
|
||||||
|
|
||||||
|
GetScreenSize (&xScreen, &yScreen);
|
||||||
|
|
||||||
|
SetTextXY (6, 8, "You have chosen to create a new partition on");
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (DiskEntry->DiskSize >= 0x280000000ULL) /* 10 GB */
|
||||||
|
{
|
||||||
|
DiskSize = (DiskEntry->DiskSize + (1 << 29)) >> 30;
|
||||||
|
Unit = "GB";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
DiskSize = (DiskEntry->DiskSize + (1 << 19)) >> 20;
|
||||||
|
if (DiskSize == 0)
|
||||||
|
DiskSize = 1;
|
||||||
|
Unit = "MB";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DiskEntry->DriverName.Length > 0)
|
||||||
|
{
|
||||||
|
PrintTextXY (6, 10,
|
||||||
|
"%I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %wZ.",
|
||||||
|
DiskSize,
|
||||||
|
Unit,
|
||||||
|
DiskEntry->DiskNumber,
|
||||||
|
DiskEntry->Port,
|
||||||
|
DiskEntry->Bus,
|
||||||
|
DiskEntry->Id,
|
||||||
|
&DiskEntry->DriverName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PrintTextXY (6, 10,
|
||||||
|
"%I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu).",
|
||||||
|
DiskSize,
|
||||||
|
Unit,
|
||||||
|
DiskEntry->DiskNumber,
|
||||||
|
DiskEntry->Port,
|
||||||
|
DiskEntry->Bus,
|
||||||
|
DiskEntry->Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SetTextXY (6, 12, "Please enter the size of the new partition in megabytes.");
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
PrintTextXY (8, 10, "Maximum size of the new partition is %I64u MB",
|
PrintTextXY (8, 10, "Maximum size of the new partition is %I64u MB",
|
||||||
PartitionList->CurrentPartition->UnpartitionedLength / (1024*1024));
|
PartitionList->CurrentPartition->UnpartitionedLength / (1024*1024));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetStatusText(" Please wait...");
|
SetStatusText (" ENTER = Create Partition ESC = Cancel F3 = Quit");
|
||||||
|
|
||||||
GetScreenSize(&xScreen, &yScreen);
|
|
||||||
|
|
||||||
SetStatusText(" ENTER = Continue ESC = Cancel F3 = Quit");
|
|
||||||
|
|
||||||
PartEntry = PartitionList->CurrentPartition;
|
PartEntry = PartitionList->CurrentPartition;
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
MaxSize = PartEntry->UnpartitionedLength;
|
// MaxSize = PartEntry->UnpartitionedLength / (1024 * 1024); /* in MBytes */
|
||||||
ShowPartitionSizeInputBox (MaxSize, InputBuffer, &Quit, &Cancel);
|
MaxSize = (PartEntry->UnpartitionedLength + (1 << 19)) >> 20; /* in MBytes (rounded) */
|
||||||
|
ShowPartitionSizeInputBox (12, 14, xScreen - 12, 17, /* left, top, right, bottom */
|
||||||
|
MaxSize, InputBuffer, &Quit, &Cancel);
|
||||||
if (Quit == TRUE)
|
if (Quit == TRUE)
|
||||||
{
|
{
|
||||||
if (ConfirmQuit (Ir) == TRUE)
|
if (ConfirmQuit (Ir) == TRUE)
|
||||||
|
@ -1082,7 +1148,7 @@ CreatePartitionPage (PINPUT_RECORD Ir)
|
||||||
}
|
}
|
||||||
else if (Cancel == TRUE)
|
else if (Cancel == TRUE)
|
||||||
{
|
{
|
||||||
break;
|
return SELECT_PARTITION_PAGE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1093,14 +1159,66 @@ CreatePartitionPage (PINPUT_RECORD Ir)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert to bytes */
|
if (PartSize > MaxSize)
|
||||||
PartSize *= 1024 * 1024;
|
|
||||||
|
|
||||||
if (PartSize > PartEntry->UnpartitionedLength)
|
|
||||||
{
|
{
|
||||||
/* Too large */
|
/* Too large */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Convert to bytes */
|
||||||
|
if (PartSize == MaxSize)
|
||||||
|
{
|
||||||
|
/* Use all of the unpartitioned disk space */
|
||||||
|
PartSize = PartEntry->UnpartitionedLength;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Round-up by cylinder size */
|
||||||
|
PartSize = ROUND_UP (PartSize * 1024 * 1024,
|
||||||
|
DiskEntry->CylinderSize);
|
||||||
|
|
||||||
|
/* But never get larger than the unpartitioned disk space */
|
||||||
|
if (PartSize > PartEntry->UnpartitionedLength)
|
||||||
|
PartSize = PartEntry->UnpartitionedLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PartSize == PartEntry->UnpartitionedLength)
|
||||||
|
{
|
||||||
|
/* 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 */
|
||||||
|
|
||||||
|
|
||||||
|
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
|
#if 0
|
||||||
PartEntry->PartType = PARTITION_ENTRY_UNUSED;
|
PartEntry->PartType = PARTITION_ENTRY_UNUSED;
|
||||||
PartEntry->Used = TRUE;
|
PartEntry->Used = TRUE;
|
||||||
|
@ -1118,7 +1236,7 @@ CreatePartitionPage (PINPUT_RECORD Ir)
|
||||||
RtlFreeUnicodeString(&DestinationRootPath);
|
RtlFreeUnicodeString(&DestinationRootPath);
|
||||||
swprintf(PathBuffer,
|
swprintf(PathBuffer,
|
||||||
L"\\Device\\Harddisk%lu\\Partition%lu",
|
L"\\Device\\Harddisk%lu\\Partition%lu",
|
||||||
PartData.DiskNumber,
|
DiskEntry->DiskNumber,
|
||||||
PartData.PartNumber);
|
PartData.PartNumber);
|
||||||
RtlCreateUnicodeString(&DestinationRootPath,
|
RtlCreateUnicodeString(&DestinationRootPath,
|
||||||
PathBuffer);
|
PathBuffer);
|
||||||
|
@ -1137,7 +1255,7 @@ CreatePartitionPage (PINPUT_RECORD Ir)
|
||||||
/* We mark the selected partition as bootable */
|
/* We mark the selected partition as bootable */
|
||||||
swprintf(PathBuffer,
|
swprintf(PathBuffer,
|
||||||
L"\\Device\\Harddisk%lu\\Partition%lu",
|
L"\\Device\\Harddisk%lu\\Partition%lu",
|
||||||
PartData.DiskNumber,
|
DiskEntry->DiskNumber,
|
||||||
PartData.PartNumber);
|
PartData.PartNumber);
|
||||||
}
|
}
|
||||||
RtlCreateUnicodeString(&SystemRootPath,
|
RtlCreateUnicodeString(&SystemRootPath,
|
||||||
|
@ -1155,30 +1273,144 @@ CreatePartitionPage (PINPUT_RECORD Ir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SELECT_PARTITION_PAGE;
|
return CREATE_PARTITION_PAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static PAGE_NUMBER
|
static PAGE_NUMBER
|
||||||
DeletePartitionPage (PINPUT_RECORD Ir)
|
DeletePartitionPage (PINPUT_RECORD Ir)
|
||||||
{
|
{
|
||||||
|
PDISKENTRY DiskEntry;
|
||||||
|
PPARTENTRY PartEntry;
|
||||||
|
ULONGLONG DiskSize;
|
||||||
|
ULONGLONG PartSize;
|
||||||
|
PCHAR Unit;
|
||||||
|
PCHAR PartType;
|
||||||
|
|
||||||
SetTextXY(6, 8, "You have chosen to delete the following partition:");
|
if (PartitionList == NULL ||
|
||||||
|
PartitionList->CurrentDisk == NULL ||
|
||||||
|
PartitionList->CurrentPartition == NULL)
|
||||||
|
{
|
||||||
|
/* FIXME: show an error dialog */
|
||||||
|
return QUIT_PAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DiskEntry = PartitionList->CurrentDisk;
|
||||||
|
PartEntry = PartitionList->CurrentPartition;
|
||||||
|
|
||||||
|
SetTextXY(6, 8, "You have chosen to delete the partition");
|
||||||
|
|
||||||
|
/* Determine partition type */
|
||||||
|
PartType = NULL;
|
||||||
|
if (PartEntry->New == TRUE)
|
||||||
|
{
|
||||||
|
PartType = "New (Unformatted)";
|
||||||
|
}
|
||||||
|
else if (PartEntry->Unpartitioned == FALSE)
|
||||||
|
{
|
||||||
|
if ((PartEntry->PartInfo[0].PartitionType == PARTITION_FAT_12) ||
|
||||||
|
(PartEntry->PartInfo[0].PartitionType == PARTITION_FAT_16) ||
|
||||||
|
(PartEntry->PartInfo[0].PartitionType == PARTITION_HUGE) ||
|
||||||
|
(PartEntry->PartInfo[0].PartitionType == PARTITION_XINT13))
|
||||||
|
{
|
||||||
|
PartType = "FAT";
|
||||||
|
}
|
||||||
|
else if ((PartEntry->PartInfo[0].PartitionType == PARTITION_FAT32) ||
|
||||||
|
(PartEntry->PartInfo[0].PartitionType == PARTITION_FAT32_XINT13))
|
||||||
|
{
|
||||||
|
PartType = "FAT32";
|
||||||
|
}
|
||||||
|
else if (PartEntry->PartInfo[0].PartitionType == PARTITION_IFS)
|
||||||
|
{
|
||||||
|
PartType = "NTFS"; /* FIXME: Not quite correct! */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
SetTextXY(6, 9, "Please enter the size of the new partition in megabytes.");
|
if (PartEntry->PartInfo[0].PartitionLength.QuadPart >= 0x280000000ULL) /* 10 GB */
|
||||||
|
{
|
||||||
PrintTextXY(8, 10, "Maximum size of the new partition is %I64u MB",
|
PartSize = (PartEntry->PartInfo[0].PartitionLength.QuadPart + (1 << 29)) >> 30;
|
||||||
PartitionList->CurrentPartition->UnpartitionedLength / (1024*1024));
|
Unit = "GB";
|
||||||
|
}
|
||||||
|
else
|
||||||
#endif
|
#endif
|
||||||
|
if (PartEntry->PartInfo[0].PartitionLength.QuadPart >= 0xA00000ULL) /* 10 MB */
|
||||||
|
{
|
||||||
|
PartSize = (PartEntry->PartInfo[0].PartitionLength.QuadPart + (1 << 19)) >> 20;
|
||||||
|
Unit = "MB";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PartSize = (PartEntry->PartInfo[0].PartitionLength.QuadPart + (1 << 9)) >> 10;
|
||||||
|
Unit = "KB";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PartType == NULL)
|
||||||
|
{
|
||||||
|
PrintTextXY (6, 10,
|
||||||
|
// " %c%c Type %-3lu %6I64u %s",
|
||||||
|
" %c%c Type %lu %I64u %s",
|
||||||
|
(PartEntry->DriveLetter == 0) ? '-' : PartEntry->DriveLetter,
|
||||||
|
(PartEntry->DriveLetter == 0) ? '-' : ':',
|
||||||
|
PartEntry->PartInfo[0].PartitionType,
|
||||||
|
PartSize,
|
||||||
|
Unit);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PrintTextXY (6, 10,
|
||||||
|
// " %c%c %-8s %6I64u %s",
|
||||||
|
" %c%c %s %I64u %s",
|
||||||
|
(PartEntry->DriveLetter == 0) ? '-' : PartEntry->DriveLetter,
|
||||||
|
(PartEntry->DriveLetter == 0) ? '-' : ':',
|
||||||
|
PartType,
|
||||||
|
PartSize,
|
||||||
|
Unit);
|
||||||
|
}
|
||||||
|
|
||||||
SetTextXY(8, 13, "\x07 Press D to delete the partition.");
|
#if 0
|
||||||
SetTextXY(11, 14, "WARNING: All data on this partition will be lost!");
|
if (DiskEntry->DiskSize >= 0x280000000ULL) /* 10 GB */
|
||||||
|
{
|
||||||
|
DiskSize = (DiskEntry->DiskSize + (1 << 29)) >> 30;
|
||||||
|
Unit = "GB";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
DiskSize = (DiskEntry->DiskSize + (1 << 19)) >> 20;
|
||||||
|
if (DiskSize == 0)
|
||||||
|
DiskSize = 1;
|
||||||
|
Unit = "MB";
|
||||||
|
}
|
||||||
|
|
||||||
SetTextXY(8, 16, "\x07 Press ESC to cancel.");
|
if (DiskEntry->DriverName.Length > 0)
|
||||||
|
{
|
||||||
|
PrintTextXY (6, 12,
|
||||||
|
"on %I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %wZ.",
|
||||||
|
DiskSize,
|
||||||
|
Unit,
|
||||||
|
DiskEntry->DiskNumber,
|
||||||
|
DiskEntry->Port,
|
||||||
|
DiskEntry->Bus,
|
||||||
|
DiskEntry->Id,
|
||||||
|
&DiskEntry->DriverName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PrintTextXY (6, 12,
|
||||||
|
"on %I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu).",
|
||||||
|
DiskSize,
|
||||||
|
Unit,
|
||||||
|
DiskEntry->DiskNumber,
|
||||||
|
DiskEntry->Port,
|
||||||
|
DiskEntry->Bus,
|
||||||
|
DiskEntry->Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
SetTextXY(8, 18, "\x07 Press D to delete the partition.");
|
||||||
|
SetTextXY(11, 19, "WARNING: All data on this partition will be lost!");
|
||||||
|
|
||||||
|
SetTextXY(8, 21, "\x07 Press ESC to cancel.");
|
||||||
|
|
||||||
SetStatusText(" D = Delete Partition ESC = Cancel F3 = Quit");
|
SetStatusText(" D = Delete Partition ESC = Cancel F3 = Quit");
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,11 @@
|
||||||
#define DPRINT(args...)
|
#define DPRINT(args...)
|
||||||
#define CHECKPOINT
|
#define CHECKPOINT
|
||||||
|
|
||||||
|
|
||||||
|
#define ROUND_DOWN(N, S) (((N) / (S)) * (S))
|
||||||
|
#define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
|
||||||
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
FsFat = 0,
|
FsFat = 0,
|
||||||
|
|
Loading…
Reference in a new issue