diff --git a/reactos/subsys/system/usetup/drivesup.c b/reactos/subsys/system/usetup/drivesup.c index c736374ec50..493e8342844 100644 --- a/reactos/subsys/system/usetup/drivesup.c +++ b/reactos/subsys/system/usetup/drivesup.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: drivesup.c,v 1.2 2002/11/02 23:17:06 ekohl Exp $ +/* $Id: drivesup.c,v 1.3 2003/08/09 16:32:25 ekohl Exp $ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS text-mode setup * FILE: subsys/system/usetup/drivesup.c @@ -94,74 +94,4 @@ GetSourcePaths(PUNICODE_STRING SourcePath, } -CHAR -GetDriveLetter(ULONG DriveNumber, - ULONG PartitionNumber) -{ - OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING LinkName; - WCHAR LinkBuffer[8]; - CHAR Letter; - HANDLE LinkHandle; - UNICODE_STRING TargetName; - PWCHAR TargetBuffer; - PWCHAR DeviceBuffer; - ULONG Length; - NTSTATUS Status; - - wcscpy(LinkBuffer, L"\\??\\A:"); - - RtlInitUnicodeString(&LinkName, - LinkBuffer); - - InitializeObjectAttributes(&ObjectAttributes, - &LinkName, - OBJ_OPENLINK, - NULL, - NULL); - - TargetBuffer = RtlAllocateHeap(ProcessHeap, 0, MAX_PATH * sizeof(WCHAR)); - DeviceBuffer = RtlAllocateHeap(ProcessHeap, 0, MAX_PATH * sizeof(WCHAR)); - - TargetName.Length = 0; - TargetName.MaximumLength = MAX_PATH * sizeof(WCHAR); - TargetName.Buffer = TargetBuffer; - - swprintf(DeviceBuffer, - L"\\Device\\Harddisk%lu\\Partition%lu", - DriveNumber, - PartitionNumber); - - for (Letter = 'C'; Letter <= 'Z'; Letter++) - { - LinkBuffer[4] = (WCHAR)Letter; - TargetName.Length = 0; - - Status = NtOpenSymbolicLinkObject(&LinkHandle, - SYMBOLIC_LINK_ALL_ACCESS, - &ObjectAttributes); - if (NT_SUCCESS(Status)) - { - Status = NtQuerySymbolicLinkObject(LinkHandle, - &TargetName, - &Length); - NtClose(LinkHandle); - if (NT_SUCCESS(Status)) - { - if (_wcsicmp(DeviceBuffer, TargetBuffer) == 0) - { - RtlFreeHeap(ProcessHeap, 0, DeviceBuffer); - RtlFreeHeap(ProcessHeap, 0, TargetBuffer); - return(Letter); - } - } - } - } - - RtlFreeHeap(ProcessHeap, 0, DeviceBuffer); - RtlFreeHeap(ProcessHeap, 0, TargetBuffer); - - return((CHAR)0); -} - /* EOF */ diff --git a/reactos/subsys/system/usetup/drivesup.h b/reactos/subsys/system/usetup/drivesup.h index da9a4881a82..b3cf97affa9 100644 --- a/reactos/subsys/system/usetup/drivesup.h +++ b/reactos/subsys/system/usetup/drivesup.h @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: drivesup.h,v 1.3 2002/11/13 18:25:18 ekohl Exp $ +/* $Id: drivesup.h,v 1.4 2003/08/09 16:32:25 ekohl Exp $ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS text-mode setup * FILE: subsys/system/usetup/drivesup.h @@ -31,11 +31,6 @@ NTSTATUS GetSourcePaths(PUNICODE_STRING SourcePath, PUNICODE_STRING SourceRootPath); -CHAR -GetDriveLetter(ULONG DriveNumber, - ULONG PartitionNumber); - - #endif /* __DRIVESUP_H__ */ /* EOF */ diff --git a/reactos/subsys/system/usetup/fslist.c b/reactos/subsys/system/usetup/fslist.c new file mode 100644 index 00000000000..ac4ff0075b7 --- /dev/null +++ b/reactos/subsys/system/usetup/fslist.c @@ -0,0 +1,164 @@ +/* + * ReactOS kernel + * Copyright (C) 2003 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS text-mode setup + * FILE: subsys/system/usetup/fslist.c + * PURPOSE: Filesystem list functions + * PROGRAMMER: Eric Kohl + * Casper S. Hornstrup (chorns@users.sourceforge.net) + */ + +#include +#include + +#include + +//#include + +#include "usetup.h" +#include "console.h" +#include "fslist.h" + + +/* FUNCTIONS ****************************************************************/ + +PFILE_SYSTEM_LIST +CreateFileSystemList (SHORT Left, + SHORT Top, + BOOLEAN ForceFormat, + FILE_SYSTEM ForceFileSystem) +{ + PFILE_SYSTEM_LIST List; + + List = (PFILE_SYSTEM_LIST)RtlAllocateHeap (ProcessHeap, 0, sizeof(FILE_SYSTEM_LIST)); + if (List == NULL) + return NULL; + + List->Left = Left; + List->Top = Top; + + List->ForceFormat = ForceFormat; + List->FileSystemCount = 1; + if (ForceFormat) + { + List->CurrentFileSystem = ForceFileSystem; + } + else + { + List->FileSystemCount++; + List->CurrentFileSystem = FsKeep; + } + + return List; +} + + +VOID +DestroyFileSystemList (PFILE_SYSTEM_LIST List) +{ + RtlFreeHeap (ProcessHeap, 0, List); +} + + +VOID +DrawFileSystemList (PFILE_SYSTEM_LIST List) +{ + COORD coPos; + ULONG Written; + ULONG Index; + + Index = 0; + + coPos.X = List->Left; + coPos.Y = List->Top + Index; + FillConsoleOutputAttribute (0x17, + 50, + coPos, + &Written); + FillConsoleOutputCharacter (' ', + 50, + coPos, + &Written); + + if (List->CurrentFileSystem == FsFat) + { + SetInvertedTextXY (List->Left, + List->Top + Index, + " Format partition as FAT file system "); + } + else + { + SetTextXY (List->Left, + List->Top + Index, + " Format partition as FAT file system "); + } + Index++; + + if (List->ForceFormat == FALSE) + { + coPos.X = List->Left; + coPos.Y = List->Top + Index; + FillConsoleOutputAttribute (0x17, + 50, + coPos, + &Written); + FillConsoleOutputCharacter (' ', + 50, + coPos, + &Written); + + if (List->CurrentFileSystem == FsKeep) + { + SetInvertedTextXY (List->Left, + List->Top + Index, + " Keep current file system (no changes) "); + } + else + { + SetTextXY (List->Left, + List->Top + Index, + " Keep current file system (no changes) "); + } + } +} + + +VOID +ScrollDownFileSystemList (PFILE_SYSTEM_LIST List) +{ + if ((ULONG) List->CurrentFileSystem < List->FileSystemCount - 1) + { + (ULONG) List->CurrentFileSystem++; + DrawFileSystemList (List); + } +} + + +VOID +ScrollUpFileSystemList (PFILE_SYSTEM_LIST List) +{ + if ((ULONG) List->CurrentFileSystem > 0) + { + (ULONG) List->CurrentFileSystem--; + DrawFileSystemList (List); + } +} + +/* EOF */ diff --git a/reactos/subsys/system/usetup/fslist.h b/reactos/subsys/system/usetup/fslist.h new file mode 100644 index 00000000000..371bf3ce73a --- /dev/null +++ b/reactos/subsys/system/usetup/fslist.h @@ -0,0 +1,67 @@ +/* + * ReactOS kernel + * Copyright (C) 2003 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: fslist.h,v 1.1 2003/08/09 16:32:25 ekohl Exp $ + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS text-mode setup + * FILE: subsys/system/usetup/fslist.h + * PURPOSE: Filesystem list functions + * PROGRAMMER: Eric Kohl + * Casper S. Hornstrup (chorns@users.sourceforge.net) + */ + +#ifndef __FSLIST_H__ +#define __FSLIST_H__ + +typedef enum +{ + FsFat = 0, + FsKeep = 1 +} FILE_SYSTEM; + +typedef struct _FILE_SYSTEM_LIST +{ + SHORT Left; + SHORT Top; + BOOLEAN ForceFormat; + FILE_SYSTEM CurrentFileSystem; + ULONG FileSystemCount; +} FILE_SYSTEM_LIST, *PFILE_SYSTEM_LIST; + + +PFILE_SYSTEM_LIST +CreateFileSystemList (SHORT Left, + SHORT Top, + BOOLEAN ForceFormat, + FILE_SYSTEM ForceFileSystem); + +VOID +DestroyFileSystemList (PFILE_SYSTEM_LIST List); + +VOID +DrawFileSystemList (PFILE_SYSTEM_LIST List); + +VOID +ScrollDownFileSystemList (PFILE_SYSTEM_LIST List); + +VOID +ScrollUpFileSystemList (PFILE_SYSTEM_LIST List); + +#endif /* __FSLIST_H__ */ + +/* EOF */ diff --git a/reactos/subsys/system/usetup/makefile b/reactos/subsys/system/usetup/makefile index a3a1002a87c..fab9b362eb4 100644 --- a/reactos/subsys/system/usetup/makefile +++ b/reactos/subsys/system/usetup/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.11 2003/04/28 19:44:13 chorns Exp $ +# $Id: makefile,v 1.12 2003/08/09 16:32:25 ekohl Exp $ PATH_TO_TOP = ../../.. @@ -19,8 +19,8 @@ TARGET_INSTALLDIR = system32 TARGET_CFLAGS = -D__NTAPP__ TARGET_OBJECTS = $(TARGET_NAME).o bootsup.o console.o drivesup.o filequeue.o \ - filesup.o format.o infcache.o inicache.o partlist.o progress.o \ - registry.o + filesup.o format.o fslist.o infcache.o inicache.o partlist.o \ + progress.o registry.o include $(PATH_TO_TOP)/rules.mak diff --git a/reactos/subsys/system/usetup/partlist.c b/reactos/subsys/system/usetup/partlist.c index ad4aded4d37..9bcac91f50e 100644 --- a/reactos/subsys/system/usetup/partlist.c +++ b/reactos/subsys/system/usetup/partlist.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: partlist.c,v 1.15 2003/08/06 16:37:46 ekohl Exp $ +/* $Id: partlist.c,v 1.16 2003/08/09 16:32:25 ekohl Exp $ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS text-mode setup * FILE: subsys/system/usetup/partlist.c @@ -78,6 +78,142 @@ GetDriverName(PDISKENTRY DiskEntry) } +static VOID +AssignDriverLetters (PPARTLIST List) +{ + PDISKENTRY DiskEntry; + PPARTENTRY PartEntry; + PLIST_ENTRY Entry1; + PLIST_ENTRY Entry2; + CHAR Letter; + + Letter = 'C'; + + /* Assign drive letters to primary partitions */ + Entry1 = List->DiskListHead.Flink; + while (Entry1 != &List->DiskListHead) + { + DiskEntry = CONTAINING_RECORD (Entry1, DISKENTRY, ListEntry); + + if (!IsListEmpty (&DiskEntry->PartListHead)) + { + PartEntry = CONTAINING_RECORD (DiskEntry->PartListHead.Flink, + PARTENTRY, + ListEntry); + + PartEntry->DriveLetter = 0; + + if (PartEntry->Unpartitioned == FALSE && + !IsContainerPartition(PartEntry->PartInfo[0].PartitionType)) + { + if (IsRecognizedPartition(PartEntry->PartInfo[0].PartitionType) || + (PartEntry->PartInfo[0].PartitionType == PARTITION_ENTRY_UNUSED && + PartEntry->PartInfo[0].PartitionLength.QuadPart != 0LL)) + { + if (Letter <= 'Z') + { + PartEntry->DriveLetter = Letter; + Letter++; + } + } + } + } + + Entry1 = Entry1->Flink; + } + + + /* Assign drive letters to logical drives */ + Entry1 = List->DiskListHead.Flink; + while (Entry1 != &List->DiskListHead) + { + DiskEntry = CONTAINING_RECORD (Entry1, DISKENTRY, ListEntry); + + Entry2 = DiskEntry->PartListHead.Flink; + if (Entry2 != &DiskEntry->PartListHead) + { + Entry2 = Entry2->Flink; + while (Entry2 != &DiskEntry->PartListHead) + { + PartEntry = CONTAINING_RECORD (Entry2, + PARTENTRY, + ListEntry); + + PartEntry->DriveLetter = 0; + + if (PartEntry->Unpartitioned == FALSE && + !IsContainerPartition(PartEntry->PartInfo[0].PartitionType)) + { + if (IsRecognizedPartition(PartEntry->PartInfo[0].PartitionType) || + (PartEntry->PartInfo[0].PartitionType == PARTITION_ENTRY_UNUSED && + PartEntry->PartInfo[0].PartitionLength.QuadPart != 0LL)) + { + if (Letter <= 'Z') + { + PartEntry->DriveLetter = Letter; + Letter++; + } + } + } + + Entry2 = Entry2->Flink; + } + } + + Entry1 = Entry1->Flink; + } +} + + +static VOID +UpdatePartitionNumbers (PDISKENTRY DiskEntry) +{ + PPARTENTRY PartEntry; + PLIST_ENTRY Entry; + ULONG PartNumber; + ULONG i; + + PartNumber = 1; + Entry = DiskEntry->PartListHead.Flink; + while (Entry != &DiskEntry->PartListHead) + { + PartEntry = CONTAINING_RECORD (Entry, + PARTENTRY, + ListEntry); + + if (PartEntry->Unpartitioned == TRUE) + { + for (i = 0; i < 4; i++) + { + PartEntry->PartInfo[i].PartitionNumber = 0; + } + } + else + { + for (i = 0; i < 4; i++) + { + if (IsContainerPartition(PartEntry->PartInfo[i].PartitionType)) + { + PartEntry->PartInfo[i].PartitionNumber = 0; + } + else if (PartEntry->PartInfo[i].PartitionType == PARTITION_ENTRY_UNUSED && + PartEntry->PartInfo[i].PartitionLength.QuadPart == 0ULL) + { + PartEntry->PartInfo[i].PartitionNumber = 0; + } + else + { + PartEntry->PartInfo[i].PartitionNumber = PartNumber; + PartNumber++; + } + } + } + + Entry = Entry->Flink; + } +} + + static VOID AddPartitionToList (ULONG DiskNumber, PDISKENTRY DiskEntry, @@ -100,9 +236,6 @@ AddPartitionToList (ULONG DiskNumber, RtlZeroMemory (PartEntry, sizeof(PARTENTRY)); - PartEntry->DriveLetter = GetDriveLetter(DiskNumber, - LayoutBuffer->PartitionEntry[i].PartitionNumber); - PartEntry->Unpartitioned = FALSE; for (j = 0; j < 4; j++) @@ -208,12 +341,7 @@ ScanForUnpartitionedDiskSpace (PDISKENTRY DiskEntry) /* Check for trailing unpartitioned disk space */ if (DiskEntry->DiskSize > (LastStartingOffset + LastPartitionLength)) { -#if 0 - LastUnusedPartitionLength = - DiskEntry->DiskSize - (LastStartingOffset + LastPartitionLength); -#endif - - /* FIXME: Round-down to cylinder size */ + /* Round-down to cylinder size */ LastUnusedPartitionLength = ROUND_DOWN (DiskEntry->DiskSize - (LastStartingOffset + LastPartitionLength), DiskEntry->CylinderSize); @@ -329,6 +457,8 @@ AddDiskToList (HANDLE FileHandle, DiskEntry->Bus = ScsiAddress.PathId; DiskEntry->Id = ScsiAddress.TargetId; + DiskEntry->UseLba = (DiskEntry->DiskSize > (1024ULL * 255ULL * 63ULL * 512ULL)); + GetDriverName (DiskEntry); InsertTailList (&List->DiskListHead, @@ -443,6 +573,8 @@ InitializePartitionList(VOID) } } + AssignDriverLetters (List); + List->TopDisk = 0; List->TopPartition = 0; @@ -1094,7 +1226,8 @@ GetActiveBootPartition(PPARTLIST List, VOID CreateNewPartition (PPARTLIST List, - ULONGLONG PartitionSize) + ULONGLONG PartitionSize, + BOOLEAN AutoCreate) { PDISKENTRY DiskEntry; PPARTENTRY PartEntry; @@ -1113,7 +1246,8 @@ CreateNewPartition (PPARTLIST List, DiskEntry = List->CurrentDisk; PartEntry = List->CurrentPartition; - if (PartitionSize == PartEntry->UnpartitionedLength) + if (AutoCreate == TRUE || + PartitionSize == PartEntry->UnpartitionedLength) { /* Convert current entry to 'new (unformatted)' */ PartEntry->PartInfo[0].StartingOffset.QuadPart = @@ -1137,6 +1271,7 @@ CreateNewPartition (PPARTLIST List, } + PartEntry->AutoCreate = AutoCreate; PartEntry->New = TRUE; PartEntry->Unpartitioned = FALSE; PartEntry->UnpartitionedOffset = 0ULL; @@ -1177,8 +1312,9 @@ CreateNewPartition (PPARTLIST List, DiskEntry->Modified = TRUE; - /* FIXME: Update partition numbers and drive letters */ + UpdatePartitionNumbers (DiskEntry); + AssignDriverLetters (List); } @@ -1305,8 +1441,9 @@ DeleteCurrentPartition (PPARTLIST List) DiskEntry->Modified = TRUE; - /* FIXME: Update partition numbers and drive letters */ + UpdatePartitionNumbers (DiskEntry); + AssignDriverLetters (List); } /* EOF */ diff --git a/reactos/subsys/system/usetup/partlist.h b/reactos/subsys/system/usetup/partlist.h index d5644b3dd10..8aa40a9585a 100644 --- a/reactos/subsys/system/usetup/partlist.h +++ b/reactos/subsys/system/usetup/partlist.h @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: partlist.h,v 1.15 2003/08/06 16:37:46 ekohl Exp $ +/* $Id: partlist.h,v 1.16 2003/08/09 16:32:25 ekohl Exp $ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS text-mode setup * FILE: subsys/system/usetup/partlist.h @@ -42,6 +42,9 @@ typedef struct _PARTENTRY /* Partition is new. Table does not exist on disk yet */ BOOLEAN New; + /* Partition was created automatically. */ + BOOLEAN AutoCreate; + /* * Raw offset and length of the unpartitioned disk space. * Includes the leading, not yet existing, partition table. @@ -72,6 +75,9 @@ typedef struct _DISKENTRY USHORT Bus; USHORT Id; + /* Use LBA or CHS? */ + BOOLEAN UseLba; + /* Has the partition list been modified? */ BOOLEAN Modified; @@ -134,7 +140,8 @@ GetActiveBootPartition(PPARTLIST List, VOID CreateNewPartition (PPARTLIST List, - ULONGLONG PartitionSize); + ULONGLONG PartitionSize, + BOOLEAN AutoCreate); VOID DeleteCurrentPartition (PPARTLIST List); diff --git a/reactos/subsys/system/usetup/usetup.c b/reactos/subsys/system/usetup/usetup.c index 83d282871aa..262d5288f02 100644 --- a/reactos/subsys/system/usetup/usetup.c +++ b/reactos/subsys/system/usetup/usetup.c @@ -41,10 +41,12 @@ #include "bootsup.h" #include "registry.h" #include "format.h" +#include "fslist.h" #define NDEBUG #include + typedef enum _PAGE_NUMBER { START_PAGE, @@ -717,10 +719,7 @@ SelectPartitionPage(PINPUT_RECORD Ir) if (PartitionList->CurrentPartition == NULL || PartitionList->CurrentPartition->Unpartitioned == TRUE) { -#if 0 SetStatusText (" ENTER = Install C = Create Partition F3 = Quit"); -#endif - SetStatusText (" C = Create Partition F3 = Quit"); } else { @@ -755,14 +754,13 @@ SelectPartitionPage(PINPUT_RECORD Ir) if (PartitionList->CurrentPartition == NULL || PartitionList->CurrentPartition->Unpartitioned == TRUE) { - PopupError ("You can not install ReactOS on\n" - "unpartitioned disk space!\n" - "\n" - " * Press any key to select an other partition.", - NULL); - ConInKey (Ir); + CreateNewPartition (PartitionList, + 0ULL, + TRUE); - return SELECT_PARTITION_PAGE; + /* FIXME: Update drive letters and partition numbers */ + + return SELECT_FILE_SYSTEM_PAGE; } else { @@ -805,16 +803,6 @@ SelectPartitionPage(PINPUT_RECORD Ir) DPRINT ("DestinationRootPath: %wZ\n", &DestinationRootPath); DPRINT ("SystemRootPath: %wZ\n", &SystemRootPath); -#if 0 - PopupError ("You chose to install ReactOS on\n" - "a valid Partition.\n" - "\n" - " * Press any key to continue.", - NULL); - ConInKey (Ir); - - return SELECT_PARTITION_PAGE; -#endif return SELECT_FILE_SYSTEM_PAGE; } } @@ -1181,7 +1169,8 @@ CreatePartitionPage (PINPUT_RECORD Ir) DPRINT ("Partition size: %I64u bytes\n", PartSize); CreateNewPartition (PartitionList, - PartSize); + PartSize, + FALSE); return SELECT_PARTITION_PAGE; } @@ -1355,126 +1344,12 @@ DeletePartitionPage (PINPUT_RECORD Ir) } -static PFILE_SYSTEM_LIST -CreateFileSystemList(SHORT Left, - SHORT Top, - BOOLEAN ForceFormat, - FILE_SYSTEM ForceFileSystem) -{ - PFILE_SYSTEM_LIST List; - - List = (PFILE_SYSTEM_LIST)RtlAllocateHeap(ProcessHeap, 0, sizeof(FILE_SYSTEM_LIST)); - if (List == NULL) - return(NULL); - - List->Left = Left; - List->Top = Top; - - List->ForceFormat = ForceFormat; - List->FileSystemCount = 1; - if (ForceFormat) - { - List->CurrentFileSystem = ForceFileSystem; - } - else - { - List->FileSystemCount++; - List->CurrentFileSystem = FsKeep; - } - return(List); -} - - -static VOID -DestroyFileSystemList(PFILE_SYSTEM_LIST List) -{ - RtlFreeHeap(ProcessHeap, 0, List); -} - - -static VOID -DrawFileSystemList(PFILE_SYSTEM_LIST List) -{ - COORD coPos; - ULONG Written; - ULONG index; - - index = 0; - - coPos.X = List->Left; - coPos.Y = List->Top + index; - FillConsoleOutputAttribute(0x17, - 50, - coPos, - &Written); - FillConsoleOutputCharacter(' ', - 50, - coPos, - &Written); - - if (List->CurrentFileSystem == FsFat) - { - SetInvertedTextXY(List->Left, List->Top + index, " Format partition as FAT file system "); - } - else - { - SetTextXY(List->Left, List->Top + index, " Format partition as FAT file system "); - } - index++; - - if (!List->ForceFormat) - { - coPos.X = List->Left; - coPos.Y = List->Top + index; - FillConsoleOutputAttribute(0x17, - 50, - coPos, - &Written); - FillConsoleOutputCharacter(' ', - 50, - coPos, - &Written); - - if (List->CurrentFileSystem == FsKeep) - { - SetInvertedTextXY(List->Left, List->Top + index, " Keep current file system (no changes) "); - } - else - { - SetTextXY(List->Left, List->Top + index, " Keep current file system (no changes) "); - } - } -} - - -static VOID -ScrollDownFileSystemList(PFILE_SYSTEM_LIST List) -{ - if ((ULONG) List->CurrentFileSystem < List->FileSystemCount - 1) - { - (ULONG) List->CurrentFileSystem++; - DrawFileSystemList(List); - } -} - - -static VOID -ScrollUpFileSystemList(PFILE_SYSTEM_LIST List) -{ - if ((ULONG) List->CurrentFileSystem > 0) - { - (ULONG) List->CurrentFileSystem--; - DrawFileSystemList(List); - } -} - - static PAGE_NUMBER SelectFileSystemPage (PINPUT_RECORD Ir) { PDISKENTRY DiskEntry; PPARTENTRY PartEntry; - BOOLEAN ForceFormat; +// BOOLEAN ForceFormat; ULONGLONG DiskSize; ULONGLONG PartSize; PCHAR DiskUnit; @@ -1542,15 +1417,19 @@ SelectFileSystemPage (PINPUT_RECORD Ir) PartType = "Unknown"; } - SetTextXY(6, 8, "Setup will install ReactOS on"); + if (PartEntry->AutoCreate == TRUE) + { + SetTextXY(6, 8, "Setup created a new partition on"); +#if 0 PrintTextXY(8, 10, "Partition %lu (%I64u %s) %s of", PartEntry->PartInfo[0].PartitionNumber, PartSize, PartUnit, PartType); +#endif - PrintTextXY(8, 12, "Harddisk %lu (%I64u %s), Port=%hu, Bus=%hu, Id=%hu (%wZ).", + PrintTextXY(8, 10, "Harddisk %lu (%I64u %s), Port=%hu, Bus=%hu, Id=%hu (%wZ).", DiskEntry->DiskNumber, DiskSize, DiskUnit, @@ -1559,28 +1438,73 @@ SelectFileSystemPage (PINPUT_RECORD Ir) DiskEntry->Id, &DiskEntry->DriverName); + SetTextXY(6, 12, "This Partition will be formatted next."); - SetTextXY(6, 17, "Select a file system for the partition from the list below."); + + PartEntry->AutoCreate = FALSE; + } + else if (PartEntry->New == TRUE) + { + SetTextXY(6, 8, "You chose to install ReactOS on a new or unformatted Partition."); + SetTextXY(6, 10, "This Partition will be formatted next."); + } + else + { + SetTextXY(6, 8, "Setup install ReactOS onto Partition"); + + if (PartType == NULL) + { + PrintTextXY (8, 10, + "%c%c Type %lu %I64u %s", + (PartEntry->DriveLetter == 0) ? '-' : PartEntry->DriveLetter, + (PartEntry->DriveLetter == 0) ? '-' : ':', + PartEntry->PartInfo[0].PartitionType, + PartSize, + PartUnit); + } + else + { + PrintTextXY (8, 10, + "%c%c %s %I64u %s", + (PartEntry->DriveLetter == 0) ? '-' : PartEntry->DriveLetter, + (PartEntry->DriveLetter == 0) ? '-' : ':', + PartType, + PartSize, + PartUnit); + } + + PrintTextXY(6, 12, "on Harddisk %lu (%I64u %s), Port=%hu, Bus=%hu, Id=%hu (%wZ).", + DiskEntry->DiskNumber, + DiskSize, + DiskUnit, + DiskEntry->Port, + DiskEntry->Bus, + DiskEntry->Id, + &DiskEntry->DriverName); + } + + + SetTextXY(6, 17, "Select a file system from the list below."); SetTextXY(8, 19, "\x07 Press UP or DOWN to select a file system."); SetTextXY(8, 21, "\x07 Press ENTER to format the partition."); SetTextXY(8, 23, "\x07 Press ESC to select another partition."); - ForceFormat = (PartEntry->PartInfo[0].PartitionType == PARTITION_ENTRY_UNUSED); +// ForceFormat = (PartEntry->PartInfo[0].PartitionType == PARTITION_ENTRY_UNUSED); if (FileSystemList == NULL) { - FileSystemList = CreateFileSystemList (6, 26, ForceFormat, FsFat); +// FileSystemList = CreateFileSystemList (6, 26, ForceFormat, FsFat); + FileSystemList = CreateFileSystemList (6, 26, PartEntry->New, FsFat); if (FileSystemList == NULL) { /* FIXME: show an error dialog */ return QUIT_PAGE; } + + /* FIXME: Add file systems to list */ } - else - { - DrawFileSystemList (FileSystemList); - } + DrawFileSystemList (FileSystemList); SetStatusText (" ENTER = Continue ESC = Cancel F3 = Quit"); @@ -1591,7 +1515,7 @@ SelectFileSystemPage (PINPUT_RECORD Ir) if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) && (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */ { - if (ConfirmQuit(Ir) == TRUE) + if (ConfirmQuit (Ir) == TRUE) { return QUIT_PAGE; } @@ -1600,7 +1524,6 @@ SelectFileSystemPage (PINPUT_RECORD Ir) else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) && (Ir->Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE)) /* ESC */ { - DestroyFileSystemList (FileSystemList); return SELECT_PARTITION_PAGE; } else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) && @@ -1615,6 +1538,7 @@ SelectFileSystemPage (PINPUT_RECORD Ir) } else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RETURN) /* ENTER */ { +#if 0 if (FileSystemList->CurrentFileSystem == FsKeep) { return CHECK_FILE_SYSTEM_PAGE; @@ -1623,6 +1547,8 @@ SelectFileSystemPage (PINPUT_RECORD Ir) { return FORMAT_PARTITION_PAGE; } +#endif + return FORMAT_PARTITION_PAGE; } } @@ -1631,11 +1557,18 @@ SelectFileSystemPage (PINPUT_RECORD Ir) static ULONG -FormatPartitionPage(PINPUT_RECORD Ir) +FormatPartitionPage (PINPUT_RECORD Ir) { - NTSTATUS Status; - ULONG PartType; - BOOLEAN Valid; + PDISKENTRY DiskEntry; + PPARTENTRY PartEntry; + PLIST_ENTRY Entry; +// NTSTATUS Status; +// BOOLEAN Valid; + + + ULONG Line; + ULONG i; + SetTextXY(6, 8, "Format partition"); @@ -1643,6 +1576,18 @@ FormatPartitionPage(PINPUT_RECORD Ir) SetStatusText(" ENTER = Continue F3 = Quit"); + + if (PartitionList == NULL || + PartitionList->CurrentDisk == NULL || + PartitionList->CurrentPartition == NULL) + { + /* FIXME: show an error dialog */ + return QUIT_PAGE; + } + + DiskEntry = PartitionList->CurrentDisk; + PartEntry = PartitionList->CurrentPartition; + while(TRUE) { ConInKey(Ir); @@ -1650,20 +1595,34 @@ FormatPartitionPage(PINPUT_RECORD Ir) if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) && (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */ { - if (ConfirmQuit(Ir) == TRUE) + if (ConfirmQuit (Ir) == TRUE) { - return(QUIT_PAGE); + return QUIT_PAGE; } break; } else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RETURN) /* ENTER */ { - SetStatusText(" Please wait ..."); + SetStatusText (" Please wait ..."); switch (FileSystemList->CurrentFileSystem) { case FsFat: - PartType = PARTITION_FAT32_XINT13; + if (DiskEntry->UseLba == FALSE) + { + /* FAT16 CHS partition (disk is smaller than 8.4GB) */ + PartEntry->PartInfo[0].PartitionType = PARTITION_FAT_16; + } + else if (PartEntry->PartInfo[0].PartitionLength.QuadPart < (2ULL * 1024ULL * 1024ULL * 1024ULL)) + { + /* FAT16 LBA partition (partition is smaller than 2GB) */ + PartEntry->PartInfo[0].PartitionType = PARTITION_XINT13; + } + else + { + /* FAT32 LBA partition (partition is at least 2GB) */ + PartEntry->PartInfo[0].PartitionType = PARTITION_FAT32_XINT13; + } break; case FsKeep: @@ -1673,6 +1632,45 @@ FormatPartitionPage(PINPUT_RECORD Ir) return QUIT_PAGE; } +//#if 0 + PrintTextXY (6, 12, + "Disk: %I64u Cylinder: %I64u Track: %I64u", + DiskEntry->DiskSize, + DiskEntry->CylinderSize, + DiskEntry->TrackSize); + + Line = 13; + DiskEntry = PartitionList->CurrentDisk; + Entry = DiskEntry->PartListHead.Flink; + while (Entry != &DiskEntry->PartListHead) + { + PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry); + + if (PartEntry->Unpartitioned == FALSE) + { + + for (i = 0; i < 4; i++) + { + PrintTextXY (6, Line, + "%u: %u %12I64u %12I64u %u", + i, + PartEntry->PartInfo[i].PartitionNumber, + PartEntry->PartInfo[i].StartingOffset.QuadPart, + PartEntry->PartInfo[i].PartitionLength.QuadPart, + PartEntry->PartInfo[i].PartitionType); + + + Line++; + } + + Line++; + } + + Entry = Entry->Flink; + } +//#endif + + #if 0 if (PartData.CreatePartition) { @@ -1686,6 +1684,10 @@ FormatPartitionPage(PINPUT_RECORD Ir) } #endif + SetStatusText (" Press any key ..."); + ConInKey(Ir); + +#if 0 switch (FileSystemList->CurrentFileSystem) { case FsFat: @@ -1706,10 +1708,13 @@ FormatPartitionPage(PINPUT_RECORD Ir) } return INSTALL_DIRECTORY_PAGE; +#endif + + return SELECT_PARTITION_PAGE; } } - return INSTALL_DIRECTORY_PAGE; + return FORMAT_PARTITION_PAGE; } diff --git a/reactos/subsys/system/usetup/usetup.h b/reactos/subsys/system/usetup/usetup.h index b56f246c9ae..b408858a656 100644 --- a/reactos/subsys/system/usetup/usetup.h +++ b/reactos/subsys/system/usetup/usetup.h @@ -43,21 +43,6 @@ #define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S)) -typedef enum -{ - FsFat = 0, - FsKeep = 1 -} FILE_SYSTEM; - -typedef struct _FILE_SYSTEM_LIST -{ - SHORT Left; - SHORT Top; - BOOLEAN ForceFormat; - FILE_SYSTEM CurrentFileSystem; - ULONG FileSystemCount; -} FILE_SYSTEM_LIST, *PFILE_SYSTEM_LIST; - extern HANDLE ProcessHeap; extern UNICODE_STRING SourceRootPath;