* Write modified partition sectors to disk.

* Enable partition formatting code.

svn path=/trunk/; revision=5653
This commit is contained in:
Eric Kohl 2003-08-18 17:39:26 +00:00
parent c5cce225e2
commit c01dbcf16b
6 changed files with 234 additions and 269 deletions

View file

@ -922,8 +922,8 @@ CHECKPOINT1;
NTSTATUS NTSTATUS
InstallMBRBootCodeToDisk(PWSTR SrcPath, InstallMbrCodeToDisk (PWSTR SrcPath,
PWSTR RootPath) PWSTR RootPath)
{ {
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock; IO_STATUS_BLOCK IoStatusBlock;
@ -1030,7 +1030,9 @@ InstallMBRBootCodeToDisk(PWSTR SrcPath,
} }
/* Copy partition table from old MBR to new */ /* Copy partition table from old MBR to new */
memcpy((NewBootSector + 446), (OrigBootSector + 446), 4*16 /* Length of partition table */); memcpy((NewBootSector + 446),
(OrigBootSector + 446),
4*16 /* Length of partition table */);
/* Free the original boot sector */ /* Free the original boot sector */
RtlFreeHeap(ProcessHeap, 0, OrigBootSector); RtlFreeHeap(ProcessHeap, 0, OrigBootSector);

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: bootsup.h,v 1.4 2003/04/05 15:36:34 chorns Exp $ /* $Id: bootsup.h,v 1.5 2003/08/18 17:39:26 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/bootsup.h * FILE: subsys/system/usetup/bootsup.h
@ -55,7 +55,7 @@ InstallFat32BootCodeToFile(PWSTR SrcPath,
NTSTATUS NTSTATUS
InstallMBRBootCodeToDisk(PWSTR SrcPath, InstallMBRBootCodeToDisk(PWSTR SrcPath,
PWSTR RootPath); PWSTR RootPath);
NTSTATUS NTSTATUS
InstallFat16BootCodeToDisk(PWSTR SrcPath, InstallFat16BootCodeToDisk(PWSTR SrcPath,

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: format.c,v 1.1 2003/04/28 19:44:13 chorns Exp $ /* $Id: format.c,v 1.2 2003/08/18 17:39:26 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/format.c * FILE: subsys/system/usetup/format.c
@ -41,13 +41,13 @@ FormatPartition(PUNICODE_STRING DriveRoot)
VfatInitialize(); VfatInitialize();
Status = VfatFormat(DriveRoot, Status = VfatFormat (DriveRoot,
0, // MediaFlag 0, // MediaFlag
NULL, // Label NULL, // Label
TRUE, // QuickFormat TRUE, // QuickFormat
0, // ClusterSize 0, // ClusterSize
NULL); // Callback NULL); // Callback
DPRINT("VfatFormat() status 0x%.08x\n", Status); DPRINT1("VfatFormat() status 0x%.08x\n", Status);
VfatCleanup(); VfatCleanup();

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.17 2003/08/12 15:56:21 ekohl Exp $ /* $Id: partlist.c,v 1.18 2003/08/18 17:39:26 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,33 +47,28 @@ GetDriverName (PDISKENTRY DiskEntry)
WCHAR KeyName[32]; WCHAR KeyName[32];
NTSTATUS Status; NTSTATUS Status;
#if 0 RtlInitUnicodeString (&DiskEntry->DriverName,
RtlCreateUnicodeString (&DiskEntry->DriverName, NULL);
L"atapi");
#endif
RtlInitUnicodeString(&DiskEntry->DriverName, swprintf (KeyName,
NULL); L"\\Scsi\\Scsi Port %lu",
DiskEntry->Port);
swprintf(KeyName, RtlZeroMemory (&QueryTable,
L"\\Scsi\\Scsi Port %lu", sizeof(QueryTable));
DiskEntry->Port);
RtlZeroMemory(&QueryTable,
sizeof(QueryTable));
QueryTable[0].Name = L"Driver"; QueryTable[0].Name = L"Driver";
QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT; QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
QueryTable[0].EntryContext = &DiskEntry->DriverName; QueryTable[0].EntryContext = &DiskEntry->DriverName;
Status = RtlQueryRegistryValues(RTL_REGISTRY_DEVICEMAP, Status = RtlQueryRegistryValues (RTL_REGISTRY_DEVICEMAP,
KeyName, KeyName,
QueryTable, QueryTable,
NULL, NULL,
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS (Status))
{ {
DPRINT1("RtlQueryRegistryValues() failed (Status %lx)\n", Status); DPRINT1 ("RtlQueryRegistryValues() failed (Status %lx)\n", Status);
} }
} }
@ -104,9 +99,9 @@ AssignDriverLetters (PPARTLIST List)
PartEntry->DriveLetter = 0; PartEntry->DriveLetter = 0;
if (PartEntry->Unpartitioned == FALSE && if (PartEntry->Unpartitioned == FALSE &&
!IsContainerPartition(PartEntry->PartInfo[0].PartitionType)) !IsContainerPartition (PartEntry->PartInfo[0].PartitionType))
{ {
if (IsRecognizedPartition(PartEntry->PartInfo[0].PartitionType) || if (IsRecognizedPartition (PartEntry->PartInfo[0].PartitionType) ||
(PartEntry->PartInfo[0].PartitionType == PARTITION_ENTRY_UNUSED && (PartEntry->PartInfo[0].PartitionType == PARTITION_ENTRY_UNUSED &&
PartEntry->PartInfo[0].PartitionLength.QuadPart != 0LL)) PartEntry->PartInfo[0].PartitionLength.QuadPart != 0LL))
{ {
@ -142,9 +137,9 @@ AssignDriverLetters (PPARTLIST List)
PartEntry->DriveLetter = 0; PartEntry->DriveLetter = 0;
if (PartEntry->Unpartitioned == FALSE && if (PartEntry->Unpartitioned == FALSE &&
!IsContainerPartition(PartEntry->PartInfo[0].PartitionType)) !IsContainerPartition (PartEntry->PartInfo[0].PartitionType))
{ {
if (IsRecognizedPartition(PartEntry->PartInfo[0].PartitionType) || if (IsRecognizedPartition (PartEntry->PartInfo[0].PartitionType) ||
(PartEntry->PartInfo[0].PartitionType == PARTITION_ENTRY_UNUSED && (PartEntry->PartInfo[0].PartitionType == PARTITION_ENTRY_UNUSED &&
PartEntry->PartInfo[0].PartitionLength.QuadPart != 0LL)) PartEntry->PartInfo[0].PartitionLength.QuadPart != 0LL))
{ {
@ -192,7 +187,7 @@ UpdatePartitionNumbers (PDISKENTRY DiskEntry)
{ {
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (IsContainerPartition(PartEntry->PartInfo[i].PartitionType)) if (IsContainerPartition (PartEntry->PartInfo[i].PartitionType))
{ {
PartEntry->PartInfo[i].PartitionNumber = 0; PartEntry->PartInfo[i].PartitionNumber = 0;
} }
@ -297,7 +292,7 @@ ScanForUnpartitionedDiskSpace (PDISKENTRY DiskEntry)
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
{ {
if ((!IsContainerPartition(PartEntry->PartInfo[j].PartitionType)) && if ((!IsContainerPartition (PartEntry->PartInfo[j].PartitionType)) &&
(PartEntry->PartInfo[j].PartitionType != PARTITION_ENTRY_UNUSED || (PartEntry->PartInfo[j].PartitionType != PARTITION_ENTRY_UNUSED ||
PartEntry->PartInfo[j].PartitionLength.QuadPart != 0LL)) PartEntry->PartInfo[j].PartitionLength.QuadPart != 0LL))
{ {
@ -394,7 +389,7 @@ AddDiskToList (HANDLE FileHandle,
0, 0,
&DiskGeometry, &DiskGeometry,
sizeof(DISK_GEOMETRY)); sizeof(DISK_GEOMETRY));
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS (Status))
{ {
return; return;
} }
@ -434,10 +429,10 @@ AddDiskToList (HANDLE FileHandle,
DiskEntry->SectorsPerTrack = DiskGeometry.SectorsPerTrack; DiskEntry->SectorsPerTrack = DiskGeometry.SectorsPerTrack;
DiskEntry->BytesPerSector = DiskGeometry.BytesPerSector; DiskEntry->BytesPerSector = DiskGeometry.BytesPerSector;
DPRINT("Cylinders %d\n", DiskEntry->Cylinders); DPRINT ("Cylinders %d\n", DiskEntry->Cylinders);
DPRINT("TracksPerCylinder %d\n", DiskEntry->TracksPerCylinder); DPRINT ("TracksPerCylinder %d\n", DiskEntry->TracksPerCylinder);
DPRINT("SectorsPerTrack %d\n", DiskEntry->SectorsPerTrack); DPRINT ("SectorsPerTrack %d\n", DiskEntry->SectorsPerTrack);
DPRINT("BytesPerSector %d\n", DiskEntry->BytesPerSector); DPRINT ("BytesPerSector %d\n", DiskEntry->BytesPerSector);
DiskEntry->DiskSize = DiskEntry->DiskSize =
DiskGeometry.Cylinders.QuadPart * DiskGeometry.Cylinders.QuadPart *
@ -521,10 +516,6 @@ CreatePartitionList (SHORT Left,
if (List == NULL) if (List == NULL)
return NULL; return NULL;
// List->Left = 0;
// List->Top = 0;
// List->Right = 0;
// List->Bottom = 0;
List->Left = Left; List->Left = Left;
List->Top = Top; List->Top = Top;
List->Right = Right; List->Right = Right;
@ -621,26 +612,6 @@ DestroyPartitionList (PPARTLIST List)
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
PLIST_ENTRY Entry; PLIST_ENTRY Entry;
#if 0
COORD coPos;
USHORT Width;
/* clear occupied screen area */
coPos.X = List->Left;
Width = List->Right - List->Left + 1;
for (coPos.Y = List->Top; coPos.Y <= List->Bottom; coPos.Y++)
{
FillConsoleOutputAttribute(0x17,
Width,
coPos,
&i);
FillConsoleOutputCharacter(' ',
Width,
coPos,
&i);
}
#endif
/* Release disk and partition info */ /* Release disk and partition info */
while (!IsListEmpty (&List->DiskListHead)) while (!IsListEmpty (&List->DiskListHead))
@ -748,14 +719,13 @@ PrintPartitionData (PPARTLIST List,
Unit = "KB"; Unit = "KB";
} }
sprintf(LineBuffer, sprintf (LineBuffer,
" Unpartitioned space %6I64u %s", " Unpartitioned space %6I64u %s",
PartSize, PartSize,
Unit); Unit);
} }
else else
{ {
/* Determine partition type */ /* Determine partition type */
PartType = NULL; PartType = NULL;
if (PartEntry->New == TRUE) if (PartEntry->New == TRUE)
@ -826,23 +796,23 @@ PrintPartitionData (PPARTLIST List,
Attribute = (List->CurrentDisk == DiskEntry && Attribute = (List->CurrentDisk == DiskEntry &&
List->CurrentPartition == PartEntry) ? 0x71 : 0x17; List->CurrentPartition == PartEntry) ? 0x71 : 0x17;
FillConsoleOutputCharacter(' ', FillConsoleOutputCharacter (' ',
Width, Width,
coPos, coPos,
&Written); &Written);
coPos.X += 4; coPos.X += 4;
Width -= 8; Width -= 8;
FillConsoleOutputAttribute(Attribute, FillConsoleOutputAttribute (Attribute,
Width, Width,
coPos, coPos,
&Written); &Written);
coPos.X++; coPos.X++;
Width -= 2; Width -= 2;
WriteConsoleOutputCharacters(LineBuffer, WriteConsoleOutputCharacters (LineBuffer,
min(strlen(LineBuffer), Width), min (strlen (LineBuffer), Width),
coPos); coPos);
List->Line++; List->Line++;
} }
@ -889,47 +859,47 @@ PrintDiskData (PPARTLIST List,
if (DiskEntry->DriverName.Length > 0) if (DiskEntry->DriverName.Length > 0)
{ {
sprintf(LineBuffer, sprintf (LineBuffer,
"%6I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %wZ", "%6I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %wZ",
DiskSize, DiskSize,
Unit, Unit,
DiskEntry->DiskNumber, DiskEntry->DiskNumber,
DiskEntry->Port, DiskEntry->Port,
DiskEntry->Bus, DiskEntry->Bus,
DiskEntry->Id, DiskEntry->Id,
&DiskEntry->DriverName); &DiskEntry->DriverName);
} }
else else
{ {
sprintf(LineBuffer, sprintf (LineBuffer,
"%6I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu)", "%6I64u %s Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu)",
DiskSize, DiskSize,
Unit, Unit,
DiskEntry->DiskNumber, DiskEntry->DiskNumber,
DiskEntry->Port, DiskEntry->Port,
DiskEntry->Bus, DiskEntry->Bus,
DiskEntry->Id); DiskEntry->Id);
} }
FillConsoleOutputAttribute(0x17, FillConsoleOutputAttribute (0x17,
Width, Width,
coPos, coPos,
&Written); &Written);
FillConsoleOutputCharacter(' ', FillConsoleOutputCharacter (' ',
Width, Width,
coPos, coPos,
&Written); &Written);
coPos.X++; coPos.X++;
WriteConsoleOutputCharacters(LineBuffer, WriteConsoleOutputCharacters (LineBuffer,
min(strlen(LineBuffer), Width - 2), min (strlen (LineBuffer), Width - 2),
coPos); coPos);
List->Line++; List->Line++;
/* Print separator line */ /* Print separator line */
PrintEmptyLine(List); PrintEmptyLine (List);
/* Print partition lines*/ /* Print partition lines*/
Entry = DiskEntry->PartListHead.Flink; Entry = DiskEntry->PartListHead.Flink;
@ -946,7 +916,7 @@ PrintDiskData (PPARTLIST List,
} }
/* Print separator line */ /* Print separator line */
PrintEmptyLine(List); PrintEmptyLine (List);
} }
@ -964,67 +934,67 @@ DrawPartitionList (PPARTLIST List)
/* draw upper left corner */ /* draw upper left corner */
coPos.X = List->Left; coPos.X = List->Left;
coPos.Y = List->Top; coPos.Y = List->Top;
FillConsoleOutputCharacter(0xDA, // '+', FillConsoleOutputCharacter (0xDA, // '+',
1, 1,
coPos, coPos,
&Written); &Written);
/* draw upper edge */ /* draw upper edge */
coPos.X = List->Left + 1; coPos.X = List->Left + 1;
coPos.Y = List->Top; coPos.Y = List->Top;
FillConsoleOutputCharacter(0xC4, // '-', FillConsoleOutputCharacter (0xC4, // '-',
List->Right - List->Left - 1, List->Right - List->Left - 1,
coPos, coPos,
&Written); &Written);
/* draw upper right corner */ /* draw upper right corner */
coPos.X = List->Right; coPos.X = List->Right;
coPos.Y = List->Top; coPos.Y = List->Top;
FillConsoleOutputCharacter(0xBF, // '+', FillConsoleOutputCharacter (0xBF, // '+',
1, 1,
coPos, coPos,
&Written); &Written);
/* draw left and right edge */ /* draw left and right edge */
for (i = List->Top + 1; i < List->Bottom; i++) for (i = List->Top + 1; i < List->Bottom; i++)
{ {
coPos.X = List->Left; coPos.X = List->Left;
coPos.Y = i; coPos.Y = i;
FillConsoleOutputCharacter(0xB3, // '|', FillConsoleOutputCharacter (0xB3, // '|',
1, 1,
coPos, coPos,
&Written); &Written);
coPos.X = List->Right; coPos.X = List->Right;
FillConsoleOutputCharacter(0xB3, //'|', FillConsoleOutputCharacter (0xB3, //'|',
1, 1,
coPos, coPos,
&Written); &Written);
} }
/* draw lower left corner */ /* draw lower left corner */
coPos.X = List->Left; coPos.X = List->Left;
coPos.Y = List->Bottom; coPos.Y = List->Bottom;
FillConsoleOutputCharacter(0xC0, // '+', FillConsoleOutputCharacter (0xC0, // '+',
1, 1,
coPos, coPos,
&Written); &Written);
/* draw lower edge */ /* draw lower edge */
coPos.X = List->Left + 1; coPos.X = List->Left + 1;
coPos.Y = List->Bottom; coPos.Y = List->Bottom;
FillConsoleOutputCharacter(0xC4, // '-', FillConsoleOutputCharacter (0xC4, // '-',
List->Right - List->Left - 1, List->Right - List->Left - 1,
coPos, coPos,
&Written); &Written);
/* draw lower right corner */ /* draw lower right corner */
coPos.X = List->Right; coPos.X = List->Right;
coPos.Y = List->Bottom; coPos.Y = List->Bottom;
FillConsoleOutputCharacter(0xD9, // '+', FillConsoleOutputCharacter (0xD9, // '+',
1, 1,
coPos, coPos,
&Written); &Written);
/* print list entries */ /* print list entries */
List->Line = 0; List->Line = 0;
@ -1166,45 +1136,49 @@ ScrollUpPartitionList (PPARTLIST List)
VOID VOID
GetActiveBootPartition (PPARTLIST List, SetActiveBootPartition (PPARTLIST List)
PDISKENTRY *DiskEntry,
PPARTENTRY *PartEntry)
{ {
PDISKENTRY LocalDiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY LocalPartEntry; PPARTENTRY PartEntry;
PLIST_ENTRY Entry;
ULONG i;
*DiskEntry = NULL;
*PartEntry = NULL;
/* Check for empty disk list */ /* Check for empty disk list */
if (IsListEmpty (&List->DiskListHead)) if (IsListEmpty (&List->DiskListHead))
return; {
List->ActiveBootDisk = NULL;
List->ActiveBootPartition = NULL;
return;
}
/* Get first disk entry from the disk list */ DiskEntry = CONTAINING_RECORD (List->DiskListHead.Flink,
Entry = List->DiskListHead.Flink; DISKENTRY,
LocalDiskEntry = CONTAINING_RECORD (Entry, DISKENTRY, ListEntry); ListEntry);
/* Check for empty partition list */ /* Check for empty partition list */
if (IsListEmpty (&LocalDiskEntry->PartListHead)) if (IsListEmpty (&DiskEntry->PartListHead))
return;
/* Search for active partition */
Entry = LocalDiskEntry->PartListHead.Flink;
while (Entry != &LocalDiskEntry->PartListHead)
{ {
LocalPartEntry = CONTAINING_RECORD (Entry, PARTENTRY, ListEntry); List->ActiveBootDisk = NULL;
List->ActiveBootPartition = NULL;
if (LocalPartEntry->PartInfo[0].BootIndicator) return;
{
*DiskEntry = LocalDiskEntry;
*PartEntry = LocalPartEntry;
return;
}
Entry = Entry->Flink;
} }
PartEntry = CONTAINING_RECORD (DiskEntry->PartListHead.Flink,
PARTENTRY,
ListEntry);
/* Set active boot partition 1 */
if (PartEntry->PartInfo[0].BootIndicator == FALSE &&
PartEntry->PartInfo[1].BootIndicator == FALSE &&
PartEntry->PartInfo[2].BootIndicator == FALSE &&
PartEntry->PartInfo[3].BootIndicator == FALSE)
{
PartEntry->PartInfo[0].BootIndicator == TRUE;
PartEntry->PartInfo[0].RewritePartition == TRUE;
DiskEntry->Modified = TRUE;
}
/* FIXME: Might be incorrect if partitions were created by Linux FDISK */
List->ActiveBootDisk = DiskEntry;
List->ActiveBootPartition = PartEntry;
} }
@ -1661,7 +1635,6 @@ DeleteCurrentPartition (PPARTLIST List)
BOOLEAN BOOLEAN
WritePartitionsToDisk (PPARTLIST List) WritePartitionsToDisk (PPARTLIST List)
{ {
#if 0
PDRIVE_LAYOUT_INFORMATION DriveLayout; PDRIVE_LAYOUT_INFORMATION DriveLayout;
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK Iosb; IO_STATUS_BLOCK Iosb;
@ -1776,22 +1749,25 @@ WritePartitionsToDisk (PPARTLIST List)
DriveLayoutSize, DriveLayoutSize,
NULL, NULL,
0); 0);
NtClose (FileHandle);
if (!NT_SUCCESS (Status)) if (!NT_SUCCESS (Status))
{ {
DPRINT1 ("NtDeviceIoControlFile() failed (Status %lx)\n", Status); DPRINT1 ("NtDeviceIoControlFile() failed (Status %lx)\n", Status);
NtClose (FileHandle);
return FALSE; return FALSE;
} }
RtlFreeHeap (ProcessHeap, RtlFreeHeap (ProcessHeap,
0, 0,
DriveLayout); DriveLayout);
/* FIXME: Install MBR code */
NtClose (FileHandle);
} }
} }
Entry1 = Entry1->Flink; Entry1 = Entry1->Flink;
} }
#endif
return TRUE; return TRUE;
} }

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.17 2003/08/12 15:56:21 ekohl Exp $ /* $Id: partlist.h,v 1.18 2003/08/18 17:39:26 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
@ -103,11 +103,8 @@ typedef struct _PARTLIST
PDISKENTRY CurrentDisk; PDISKENTRY CurrentDisk;
PPARTENTRY CurrentPartition; PPARTENTRY CurrentPartition;
#if 0
/* Not used yet! */
PDISKENTRY ActiveBootDisk; PDISKENTRY ActiveBootDisk;
PPARTENTRY ActiveBootPartition; PPARTENTRY ActiveBootPartition;
#endif
LIST_ENTRY DiskListHead; LIST_ENTRY DiskListHead;
@ -134,9 +131,7 @@ VOID
ScrollUpPartitionList (PPARTLIST List); ScrollUpPartitionList (PPARTLIST List);
VOID VOID
GetActiveBootPartition(PPARTLIST List, SetActiveBootPartition (PPARTLIST List);
PDISKENTRY *DiskEntry,
PPARTENTRY *PartEntry);
VOID VOID
CreateNewPartition (PPARTLIST List, CreateNewPartition (PPARTLIST List,

View file

@ -94,9 +94,6 @@ UNICODE_STRING SourceRootPath;
static PPARTLIST PartitionList = NULL; static PPARTLIST PartitionList = NULL;
static PDISKENTRY ActiveBootDisk = NULL;
static PPARTENTRY ActiveBootPartition = NULL;
static PFILE_SYSTEM_LIST FileSystemList = NULL; static PFILE_SYSTEM_LIST FileSystemList = NULL;
@ -677,7 +674,6 @@ InstallIntroPage(PINPUT_RECORD Ir)
static PAGE_NUMBER static PAGE_NUMBER
SelectPartitionPage(PINPUT_RECORD Ir) SelectPartitionPage(PINPUT_RECORD Ir)
{ {
WCHAR PathBuffer[MAX_PATH];
SHORT xScreen; SHORT xScreen;
SHORT yScreen; SHORT yScreen;
@ -691,9 +687,6 @@ SelectPartitionPage(PINPUT_RECORD Ir)
SetStatusText(" Please wait..."); SetStatusText(" Please wait...");
RtlFreeUnicodeString(&DestinationPath);
RtlFreeUnicodeString(&DestinationRootPath);
GetScreenSize(&xScreen, &yScreen); GetScreenSize(&xScreen, &yScreen);
if (PartitionList == NULL) if (PartitionList == NULL)
@ -755,54 +748,9 @@ SelectPartitionPage(PINPUT_RECORD Ir)
CreateNewPartition (PartitionList, CreateNewPartition (PartitionList,
0ULL, 0ULL,
TRUE); TRUE);
/* FIXME: Update drive letters and partition numbers */
return SELECT_FILE_SYSTEM_PAGE;
} }
else
{
RtlFreeUnicodeString (&DestinationRootPath);
swprintf (PathBuffer,
L"\\Device\\Harddisk%lu\\Partition%lu",
PartitionList->CurrentDisk->DiskNumber,
PartitionList->CurrentPartition->PartInfo[0].PartitionNumber);
RtlCreateUnicodeString (&DestinationRootPath,
PathBuffer);
GetActiveBootPartition (PartitionList, return SELECT_FILE_SYSTEM_PAGE;
&ActiveBootDisk,
&ActiveBootPartition);
RtlFreeUnicodeString (&SystemRootPath);
if (ActiveBootDisk != NULL && ActiveBootPartition != NULL)
{
swprintf (PathBuffer,
L"\\Device\\Harddisk%lu\\Partition%lu",
ActiveBootDisk->DiskNumber,
ActiveBootPartition->PartInfo[0].PartitionNumber);
}
else
{
/*
* FIXME:
* Check whether partition can be activated.
* We may have to force Disk0\Partition1.
* Mark partition active.
*/
swprintf (PathBuffer,
L"\\Device\\Harddisk%lu\\Partition%lu",
PartitionList->CurrentDisk->DiskNumber,
PartitionList->CurrentPartition->PartInfo[0].PartitionNumber);
}
RtlCreateUnicodeString (&SystemRootPath,
PathBuffer);
DPRINT ("DestinationRootPath: %wZ\n", &DestinationRootPath);
DPRINT ("SystemRootPath: %wZ\n", &SystemRootPath);
return SELECT_FILE_SYSTEM_PAGE;
}
} }
else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_C) /* C */ else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_C) /* C */
{ {
@ -1347,7 +1295,6 @@ SelectFileSystemPage (PINPUT_RECORD Ir)
{ {
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
// BOOLEAN ForceFormat;
ULONGLONG DiskSize; ULONGLONG DiskSize;
ULONGLONG PartSize; ULONGLONG PartSize;
PCHAR DiskUnit; PCHAR DiskUnit;
@ -1488,11 +1435,8 @@ SelectFileSystemPage (PINPUT_RECORD Ir)
SetTextXY(8, 21, "\x07 Press ENTER to format the partition."); SetTextXY(8, 21, "\x07 Press ENTER to format the partition.");
SetTextXY(8, 23, "\x07 Press ESC to select another partition."); SetTextXY(8, 23, "\x07 Press ESC to select another partition.");
// ForceFormat = (PartEntry->PartInfo[0].PartitionType == PARTITION_ENTRY_UNUSED);
if (FileSystemList == NULL) if (FileSystemList == NULL)
{ {
// FileSystemList = CreateFileSystemList (6, 26, ForceFormat, FsFat);
FileSystemList = CreateFileSystemList (6, 26, PartEntry->New, FsFat); FileSystemList = CreateFileSystemList (6, 26, PartEntry->New, FsFat);
if (FileSystemList == NULL) if (FileSystemList == NULL)
{ {
@ -1536,7 +1480,6 @@ SelectFileSystemPage (PINPUT_RECORD Ir)
} }
else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RETURN) /* ENTER */ else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RETURN) /* ENTER */
{ {
#if 0
if (FileSystemList->CurrentFileSystem == FsKeep) if (FileSystemList->CurrentFileSystem == FsKeep)
{ {
return CHECK_FILE_SYSTEM_PAGE; return CHECK_FILE_SYSTEM_PAGE;
@ -1545,8 +1488,6 @@ SelectFileSystemPage (PINPUT_RECORD Ir)
{ {
return FORMAT_PARTITION_PAGE; return FORMAT_PARTITION_PAGE;
} }
#endif
return FORMAT_PARTITION_PAGE;
} }
} }
@ -1557,14 +1498,16 @@ SelectFileSystemPage (PINPUT_RECORD Ir)
static ULONG static ULONG
FormatPartitionPage (PINPUT_RECORD Ir) FormatPartitionPage (PINPUT_RECORD Ir)
{ {
WCHAR PathBuffer[MAX_PATH];
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
PLIST_ENTRY Entry; PLIST_ENTRY Entry;
// NTSTATUS Status; NTSTATUS Status;
//#ifndef NDEBUG
ULONG Line; ULONG Line;
ULONG i; ULONG i;
//#endif
SetTextXY(6, 8, "Format partition"); SetTextXY(6, 8, "Format partition");
@ -1637,7 +1580,7 @@ FormatPartitionPage (PINPUT_RECORD Ir)
return QUIT_PAGE; return QUIT_PAGE;
} }
//#if 0 //#ifndef NDEBUG
PrintTextXY (6, 12, PrintTextXY (6, 12,
"Disk: %I64u Cylinder: %I64u Track: %I64u", "Disk: %I64u Cylinder: %I64u Track: %I64u",
DiskEntry->DiskSize, DiskEntry->DiskSize,
@ -1675,6 +1618,8 @@ FormatPartitionPage (PINPUT_RECORD Ir)
} }
//#endif //#endif
SetActiveBootPartition (PartitionList);
if (WritePartitionsToDisk (PartitionList) == FALSE) if (WritePartitionsToDisk (PartitionList) == FALSE)
{ {
DPRINT ("WritePartitionsToDisk() failed\n"); DPRINT ("WritePartitionsToDisk() failed\n");
@ -1693,17 +1638,36 @@ FormatPartitionPage (PINPUT_RECORD Ir)
} }
} }
SetStatusText (" Press any key ...");
ConInKey(Ir);
#if 0 /* Set DestinationRootPath */
RtlFreeUnicodeString (&DestinationRootPath);
swprintf (PathBuffer,
L"\\Device\\Harddisk%lu\\Partition%lu",
PartitionList->CurrentDisk->DiskNumber,
PartitionList->CurrentPartition->PartInfo[0].PartitionNumber);
RtlCreateUnicodeString (&DestinationRootPath,
PathBuffer);
DPRINT1 ("DestinationRootPath: %wZ\n", &DestinationRootPath);
/* Set SystemRootPath */
RtlFreeUnicodeString (&SystemRootPath);
swprintf (PathBuffer,
L"\\Device\\Harddisk%lu\\Partition%lu",
PartitionList->ActiveBootDisk->DiskNumber,
PartitionList->ActiveBootPartition->PartInfo[0].PartitionNumber);
RtlCreateUnicodeString (&SystemRootPath,
PathBuffer);
DPRINT1 ("SystemRootPath: %wZ\n", &SystemRootPath);
switch (FileSystemList->CurrentFileSystem) switch (FileSystemList->CurrentFileSystem)
{ {
case FsFat: case FsFat:
Status = FormatPartition (&DestinationRootPath); Status = FormatPartition (&DestinationRootPath);
if (!NT_SUCCESS (Status)) if (!NT_SUCCESS (Status))
{ {
DPRINT1("FormatPartition() failed with status 0x%.08x\n", Status); DPRINT1 ("FormatPartition() failed with status 0x%.08x\n", Status);
/* FIXME: show an error dialog */ /* FIXME: show an error dialog */
return QUIT_PAGE; return QUIT_PAGE;
} }
@ -1716,6 +1680,10 @@ FormatPartitionPage (PINPUT_RECORD Ir)
return QUIT_PAGE; return QUIT_PAGE;
} }
SetStatusText (" Done. Press any key ...");
ConInKey(Ir);
#if 0
return INSTALL_DIRECTORY_PAGE; return INSTALL_DIRECTORY_PAGE;
#endif #endif
@ -1730,6 +1698,8 @@ FormatPartitionPage (PINPUT_RECORD Ir)
static ULONG static ULONG
CheckFileSystemPage(PINPUT_RECORD Ir) CheckFileSystemPage(PINPUT_RECORD Ir)
{ {
WCHAR PathBuffer[MAX_PATH];
SetTextXY(6, 8, "Check file system"); SetTextXY(6, 8, "Check file system");
SetTextXY(6, 10, "At present, ReactOS can not check file systems."); SetTextXY(6, 10, "At present, ReactOS can not check file systems.");
@ -1739,6 +1709,28 @@ CheckFileSystemPage(PINPUT_RECORD Ir)
SetStatusText(" ENTER = Continue F3 = Quit"); SetStatusText(" ENTER = Continue F3 = Quit");
/* Set DestinationRootPath */
RtlFreeUnicodeString (&DestinationRootPath);
swprintf (PathBuffer,
L"\\Device\\Harddisk%lu\\Partition%lu",
PartitionList->CurrentDisk->DiskNumber,
PartitionList->CurrentPartition->PartInfo[0].PartitionNumber);
RtlCreateUnicodeString (&DestinationRootPath,
PathBuffer);
DPRINT1 ("DestinationRootPath: %wZ\n", &DestinationRootPath);
/* Set SystemRootPath */
RtlFreeUnicodeString (&SystemRootPath);
swprintf (PathBuffer,
L"\\Device\\Harddisk%lu\\Partition%lu",
PartitionList->ActiveBootDisk->DiskNumber,
PartitionList->ActiveBootPartition->PartInfo[0].PartitionNumber);
RtlCreateUnicodeString (&SystemRootPath,
PathBuffer);
DPRINT1 ("SystemRootPath: %wZ\n", &SystemRootPath);
while(TRUE) while(TRUE)
{ {
ConInKey(Ir); ConInKey(Ir);
@ -2367,7 +2359,7 @@ BootLoaderPage(PINPUT_RECORD Ir)
} }
#endif #endif
if (ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_ENTRY_UNUSED) if (PartitionList->ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_ENTRY_UNUSED)
{ {
DPRINT1("Error: active partition invalid (unused)\n"); DPRINT1("Error: active partition invalid (unused)\n");
PopupError("The active partition is unused (invalid).\n", PopupError("The active partition is unused (invalid).\n",
@ -2384,7 +2376,7 @@ BootLoaderPage(PINPUT_RECORD Ir)
} }
} }
if (ActiveBootPartition->PartInfo[0].PartitionType == 0x0A) if (PartitionList->ActiveBootPartition->PartInfo[0].PartitionType == 0x0A)
{ {
/* OS/2 boot manager partition */ /* OS/2 boot manager partition */
DPRINT1("Found OS/2 boot manager partition\n"); DPRINT1("Found OS/2 boot manager partition\n");
@ -2402,7 +2394,7 @@ BootLoaderPage(PINPUT_RECORD Ir)
} }
} }
} }
else if (ActiveBootPartition->PartInfo[0].PartitionType == 0x83) else if (PartitionList->ActiveBootPartition->PartInfo[0].PartitionType == 0x83)
{ {
/* Linux ext2 partition */ /* Linux ext2 partition */
DPRINT1("Found Linux ext2 partition\n"); DPRINT1("Found Linux ext2 partition\n");
@ -2420,7 +2412,7 @@ BootLoaderPage(PINPUT_RECORD Ir)
} }
} }
} }
else if (ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_IFS) else if (PartitionList->ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_IFS)
{ {
/* NTFS partition */ /* NTFS partition */
DPRINT1("Found NTFS partition\n"); DPRINT1("Found NTFS partition\n");
@ -2438,12 +2430,12 @@ BootLoaderPage(PINPUT_RECORD Ir)
} }
} }
} }
else if ((ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_FAT_12) || else if ((PartitionList->ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_FAT_12) ||
(ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_FAT_16) || (PartitionList->ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_FAT_16) ||
(ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_HUGE) || (PartitionList->ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_HUGE) ||
(ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_XINT13) || (PartitionList->ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_XINT13) ||
(ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_FAT32) || (PartitionList->ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_FAT32) ||
(ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_FAT32_XINT13)) (PartitionList->ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_FAT32_XINT13))
{ {
/* FAT or FAT32 partition */ /* FAT or FAT32 partition */
DPRINT1("System path: '%wZ'\n", &SystemRootPath); DPRINT1("System path: '%wZ'\n", &SystemRootPath);
@ -2507,8 +2499,8 @@ BootLoaderPage(PINPUT_RECORD Ir)
} }
/* Install new bootcode */ /* Install new bootcode */
if ((ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_FAT32) || if ((PartitionList->ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_FAT32) ||
(ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_FAT32_XINT13)) (PartitionList->ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_FAT32_XINT13))
{ {
/* Install FAT32 bootcode */ /* Install FAT32 bootcode */
wcscpy(SrcPath, SourceRootPath.Buffer); wcscpy(SrcPath, SourceRootPath.Buffer);
@ -2703,8 +2695,8 @@ BootLoaderPage(PINPUT_RECORD Ir)
} }
/* Install new bootsector */ /* Install new bootsector */
if ((ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_FAT32) || if ((PartitionList->ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_FAT32) ||
(ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_FAT32_XINT13)) (PartitionList->ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_FAT32_XINT13))
{ {
wcscpy(SrcPath, SourceRootPath.Buffer); wcscpy(SrcPath, SourceRootPath.Buffer);
wcscat(SrcPath, L"\\loader\\fat32.bin"); wcscat(SrcPath, L"\\loader\\fat32.bin");
@ -2864,8 +2856,8 @@ BootLoaderPage(PINPUT_RECORD Ir)
} }
/* Install new bootsector */ /* Install new bootsector */
if ((ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_FAT32) || if ((PartitionList->ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_FAT32) ||
(ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_FAT32_XINT13)) (PartitionList->ActiveBootPartition->PartInfo[0].PartitionType == PARTITION_FAT32_XINT13))
{ {
wcscpy(SrcPath, SourceRootPath.Buffer); wcscpy(SrcPath, SourceRootPath.Buffer);
wcscat(SrcPath, L"\\loader\\fat32.bin"); wcscat(SrcPath, L"\\loader\\fat32.bin");