mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 19:55:41 +00:00
Adapt usetup to handle more easily additional filesystems
This also prepares ground for the Chkdsk disk page svn path=/trunk/; revision=23974
This commit is contained in:
parent
e6fd23de2c
commit
9243a83d80
6 changed files with 230 additions and 184 deletions
|
@ -84,7 +84,8 @@ FormatCallback(
|
|||
|
||||
NTSTATUS
|
||||
FormatPartition(
|
||||
IN PUNICODE_STRING DriveRoot)
|
||||
IN PUNICODE_STRING DriveRoot,
|
||||
IN PFILE_SYSTEM_ITEM FileSystem)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
|
@ -96,10 +97,10 @@ FormatPartition(
|
|||
|
||||
ProgressSetStepCount(ProgressBar, 100);
|
||||
|
||||
Status = VfatFormat(DriveRoot,
|
||||
Status = FileSystem->FormatFunc(DriveRoot,
|
||||
FMIFS_HARDDISK, /* MediaFlag */
|
||||
NULL, /* Label */
|
||||
TRUE, /* QuickFormat */
|
||||
FileSystem->QuickFormat, /* QuickFormat */
|
||||
0, /* ClusterSize */
|
||||
FormatCallback); /* Callback */
|
||||
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
|
||||
NTSTATUS
|
||||
FormatPartition(
|
||||
IN PUNICODE_STRING DriveRoot);
|
||||
IN PUNICODE_STRING DriveRoot,
|
||||
IN PFILE_SYSTEM_ITEM FileSystem);
|
||||
|
||||
#endif /* __FILESUP_H__ */
|
||||
|
||||
|
|
|
@ -32,14 +32,49 @@
|
|||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
static VOID
|
||||
AddProvider(
|
||||
IN OUT PFILE_SYSTEM_LIST List,
|
||||
IN LPCSTR FileSystem,
|
||||
IN FORMATEX FormatFunc,
|
||||
IN CHKDSKEX ChkdskFunc)
|
||||
{
|
||||
PFILE_SYSTEM_ITEM Item;
|
||||
|
||||
Item = (PFILE_SYSTEM_ITEM)RtlAllocateHeap(ProcessHeap, 0, sizeof(FILE_SYSTEM_ITEM));
|
||||
if (!Item)
|
||||
return;
|
||||
|
||||
Item->FileSystem = FileSystem;
|
||||
Item->FormatFunc = FormatFunc;
|
||||
Item->ChkdskFunc = ChkdskFunc;
|
||||
Item->QuickFormat = FALSE;
|
||||
InsertTailList(&List->ListHead, &Item->ListEntry);
|
||||
|
||||
if (!FormatFunc)
|
||||
return;
|
||||
|
||||
Item = (PFILE_SYSTEM_ITEM)RtlAllocateHeap(ProcessHeap, 0, sizeof(FILE_SYSTEM_ITEM));
|
||||
if (!Item)
|
||||
return;
|
||||
|
||||
Item->FileSystem = FileSystem;
|
||||
Item->FormatFunc = FormatFunc;
|
||||
Item->ChkdskFunc = ChkdskFunc;
|
||||
Item->QuickFormat = TRUE;
|
||||
InsertTailList(&List->ListHead, &Item->ListEntry);
|
||||
}
|
||||
|
||||
PFILE_SYSTEM_LIST
|
||||
CreateFileSystemList(
|
||||
IN SHORT Left,
|
||||
IN SHORT Top,
|
||||
IN BOOLEAN ForceFormat,
|
||||
IN FILE_SYSTEM ForceFileSystem)
|
||||
IN LPCSTR ForceFileSystem)
|
||||
{
|
||||
PFILE_SYSTEM_LIST List;
|
||||
PFILE_SYSTEM_ITEM Item;
|
||||
PLIST_ENTRY ListEntry;
|
||||
|
||||
List = (PFILE_SYSTEM_LIST)RtlAllocateHeap(ProcessHeap, 0, sizeof(FILE_SYSTEM_LIST));
|
||||
if (List == NULL)
|
||||
|
@ -47,18 +82,30 @@ CreateFileSystemList(
|
|||
|
||||
List->Left = Left;
|
||||
List->Top = Top;
|
||||
List->Selected = NULL;
|
||||
InitializeListHead(&List->ListHead);
|
||||
|
||||
List->ForceFormat = ForceFormat;
|
||||
List->FileSystemCount = 1;
|
||||
if (ForceFormat)
|
||||
AddProvider(List, "FAT", VfatFormat, NULL);
|
||||
if (!ForceFormat)
|
||||
{
|
||||
List->CurrentFileSystem = ForceFileSystem;
|
||||
/* Add 'Keep' provider */
|
||||
AddProvider(List, NULL, NULL, NULL);
|
||||
}
|
||||
else
|
||||
|
||||
/* Search for ForceFileSystem in list */
|
||||
ListEntry = List->ListHead.Flink;
|
||||
while (ListEntry != &List->ListHead)
|
||||
{
|
||||
List->FileSystemCount++;
|
||||
List->CurrentFileSystem = FsKeep;
|
||||
Item = CONTAINING_RECORD(ListEntry, FILE_SYSTEM_ITEM, ListEntry);
|
||||
if (Item->FileSystem && strcmp(ForceFileSystem, Item->FileSystem) == 0)
|
||||
{
|
||||
List->Selected = Item;
|
||||
break;
|
||||
}
|
||||
ListEntry = ListEntry->Flink;
|
||||
}
|
||||
if (!List->Selected)
|
||||
List->Selected = CONTAINING_RECORD(List->ListHead.Flink, FILE_SYSTEM_ITEM, ListEntry);
|
||||
|
||||
return List;
|
||||
}
|
||||
|
@ -67,6 +114,19 @@ VOID
|
|||
DestroyFileSystemList(
|
||||
IN PFILE_SYSTEM_LIST List)
|
||||
{
|
||||
PLIST_ENTRY ListEntry = List->ListHead.Flink;
|
||||
PFILE_SYSTEM_ITEM Item;
|
||||
PLIST_ENTRY Next;
|
||||
|
||||
while (ListEntry != &List->ListHead)
|
||||
{
|
||||
Item = CONTAINING_RECORD(ListEntry, FILE_SYSTEM_ITEM, ListEntry);
|
||||
Next = ListEntry->Flink;
|
||||
|
||||
RtlFreeHeap(ProcessHeap, 0, Item);
|
||||
|
||||
ListEntry = Next;
|
||||
}
|
||||
RtlFreeHeap(ProcessHeap, 0, List);
|
||||
}
|
||||
|
||||
|
@ -74,66 +134,51 @@ VOID
|
|||
DrawFileSystemList(
|
||||
IN PFILE_SYSTEM_LIST List)
|
||||
{
|
||||
PLIST_ENTRY ListEntry;
|
||||
PFILE_SYSTEM_ITEM Item;
|
||||
COORD coPos;
|
||||
ULONG Written;
|
||||
ULONG Index;
|
||||
ULONG Index = 0;
|
||||
CHAR Buffer[70];
|
||||
|
||||
Index = 0;
|
||||
ListEntry = List->ListHead.Flink;
|
||||
while (ListEntry != &List->ListHead)
|
||||
{
|
||||
Item = CONTAINING_RECORD(ListEntry, FILE_SYSTEM_ITEM, ListEntry);
|
||||
|
||||
coPos.X = List->Left;
|
||||
coPos.Y = List->Top + Index;
|
||||
FillConsoleOutputAttribute(StdOutput,
|
||||
FOREGROUND_WHITE | BACKGROUND_BLUE,
|
||||
50,
|
||||
sizeof(Buffer),
|
||||
coPos,
|
||||
&Written);
|
||||
FillConsoleOutputCharacterA(StdOutput,
|
||||
' ',
|
||||
50,
|
||||
sizeof(Buffer),
|
||||
coPos,
|
||||
&Written);
|
||||
|
||||
if (List->CurrentFileSystem == FsFat)
|
||||
if (Item->FileSystem)
|
||||
{
|
||||
CONSOLE_SetInvertedTextXY(List->Left,
|
||||
List->Top + Index,
|
||||
" Format partition as FAT file system ");
|
||||
if (Item->QuickFormat)
|
||||
sprintf(Buffer, " Format partition as %s file system (quick format) ", Item->FileSystem);
|
||||
else
|
||||
sprintf(Buffer, " Format partition as %s file system ", Item->FileSystem);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(Buffer, " Keep current file system (no changes) ");
|
||||
|
||||
if (ListEntry == &List->Selected->ListEntry)
|
||||
CONSOLE_SetInvertedTextXY(List->Left,
|
||||
List->Top + Index,
|
||||
Buffer);
|
||||
else
|
||||
CONSOLE_SetTextXY(List->Left,
|
||||
List->Top + Index,
|
||||
" Format partition as FAT file system ");
|
||||
}
|
||||
Buffer);
|
||||
Index++;
|
||||
|
||||
if (List->ForceFormat == FALSE)
|
||||
{
|
||||
coPos.X = List->Left;
|
||||
coPos.Y = List->Top + Index;
|
||||
FillConsoleOutputAttribute(StdOutput,
|
||||
FOREGROUND_WHITE | BACKGROUND_BLUE,
|
||||
50,
|
||||
coPos,
|
||||
&Written);
|
||||
FillConsoleOutputCharacterA(StdOutput,
|
||||
' ',
|
||||
50,
|
||||
coPos,
|
||||
&Written);
|
||||
|
||||
if (List->CurrentFileSystem == FsKeep)
|
||||
{
|
||||
CONSOLE_SetInvertedTextXY(List->Left,
|
||||
List->Top + Index,
|
||||
" Keep current file system (no changes) ");
|
||||
}
|
||||
else
|
||||
{
|
||||
CONSOLE_SetTextXY(List->Left,
|
||||
List->Top + Index,
|
||||
" Keep current file system (no changes) ");
|
||||
}
|
||||
ListEntry = ListEntry->Flink;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,9 +186,9 @@ VOID
|
|||
ScrollDownFileSystemList(
|
||||
IN PFILE_SYSTEM_LIST List)
|
||||
{
|
||||
if ((ULONG)List->CurrentFileSystem < List->FileSystemCount - 1)
|
||||
if (List->Selected->ListEntry.Flink != &List->ListHead)
|
||||
{
|
||||
List->CurrentFileSystem++;
|
||||
List->Selected = CONTAINING_RECORD(List->Selected->ListEntry.Flink, FILE_SYSTEM_ITEM, ListEntry);
|
||||
DrawFileSystemList(List);
|
||||
}
|
||||
}
|
||||
|
@ -152,9 +197,9 @@ VOID
|
|||
ScrollUpFileSystemList(
|
||||
IN PFILE_SYSTEM_LIST List)
|
||||
{
|
||||
if ((ULONG)List->CurrentFileSystem > 0)
|
||||
if (List->Selected->ListEntry.Blink != &List->ListHead)
|
||||
{
|
||||
List->CurrentFileSystem--;
|
||||
List->Selected = CONTAINING_RECORD(List->Selected->ListEntry.Blink, FILE_SYSTEM_ITEM, ListEntry);
|
||||
DrawFileSystemList(List);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,19 +28,21 @@
|
|||
#ifndef __FSLIST_H__
|
||||
#define __FSLIST_H__
|
||||
|
||||
typedef enum
|
||||
typedef struct _FILE_SYSTEM_ITEM
|
||||
{
|
||||
FsFat = 0,
|
||||
FsKeep = 1
|
||||
} FILE_SYSTEM;
|
||||
LIST_ENTRY ListEntry;
|
||||
LPCSTR FileSystem; /* Not owned by the item */
|
||||
FORMATEX FormatFunc;
|
||||
CHKDSKEX ChkdskFunc;
|
||||
BOOLEAN QuickFormat;
|
||||
} FILE_SYSTEM_ITEM, *PFILE_SYSTEM_ITEM;
|
||||
|
||||
typedef struct _FILE_SYSTEM_LIST
|
||||
{
|
||||
SHORT Left;
|
||||
SHORT Top;
|
||||
BOOLEAN ForceFormat;
|
||||
FILE_SYSTEM CurrentFileSystem;
|
||||
ULONG FileSystemCount;
|
||||
PFILE_SYSTEM_ITEM Selected;
|
||||
LIST_ENTRY ListHead; /* List of FILE_SYSTEM_ITEM */
|
||||
} FILE_SYSTEM_LIST, *PFILE_SYSTEM_LIST;
|
||||
|
||||
|
||||
|
@ -49,7 +51,7 @@ CreateFileSystemList(
|
|||
IN SHORT Left,
|
||||
IN SHORT Top,
|
||||
IN BOOLEAN ForceFormat,
|
||||
IN FILE_SYSTEM ForceFileSystem);
|
||||
IN LPCSTR ForceFileSystem);
|
||||
|
||||
VOID
|
||||
DestroyFileSystemList(
|
||||
|
|
|
@ -2099,7 +2099,7 @@ SelectFileSystemPage (PINPUT_RECORD Ir)
|
|||
|
||||
if (FileSystemList == NULL)
|
||||
{
|
||||
FileSystemList = CreateFileSystemList (6, 26, PartEntry->New, FsFat);
|
||||
FileSystemList = CreateFileSystemList (6, 26, PartEntry->New, "FAT");
|
||||
if (FileSystemList == NULL)
|
||||
{
|
||||
/* FIXME: show an error dialog */
|
||||
|
@ -2147,7 +2147,7 @@ SelectFileSystemPage (PINPUT_RECORD Ir)
|
|||
}
|
||||
else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RETURN) /* ENTER */
|
||||
{
|
||||
if (FileSystemList->CurrentFileSystem == FsKeep)
|
||||
if (!FileSystemList->Selected->FormatFunc)
|
||||
{
|
||||
return CHECK_FILE_SYSTEM_PAGE;
|
||||
}
|
||||
|
@ -2214,9 +2214,8 @@ FormatPartitionPage (PINPUT_RECORD Ir)
|
|||
|
||||
if (PartEntry->PartInfo[0].PartitionType == PARTITION_ENTRY_UNUSED)
|
||||
{
|
||||
switch (FileSystemList->CurrentFileSystem)
|
||||
if (strcmp(FileSystemList->Selected->FileSystem, "FAT") == 0)
|
||||
{
|
||||
case FsFat:
|
||||
if (PartEntry->PartInfo[0].PartitionLength.QuadPart < (4200LL * 1024LL))
|
||||
{
|
||||
/* FAT12 CHS partition (disk is smaller than 4.1MB) */
|
||||
|
@ -2258,13 +2257,9 @@ FormatPartitionPage (PINPUT_RECORD Ir)
|
|||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case FsKeep:
|
||||
break;
|
||||
|
||||
default:
|
||||
return QUIT_PAGE;
|
||||
}
|
||||
else if (FileSystemList->Selected->FormatFunc)
|
||||
return QUIT_PAGE;
|
||||
}
|
||||
|
||||
CheckActiveBootPartition (PartitionList);
|
||||
|
@ -2343,66 +2338,66 @@ FormatPartitionPage (PINPUT_RECORD Ir)
|
|||
DPRINT ("SystemRootPath: %wZ\n", &SystemRootPath);
|
||||
|
||||
|
||||
switch (FileSystemList->CurrentFileSystem)
|
||||
if (FileSystemList->Selected->FormatFunc)
|
||||
{
|
||||
case FsFat:
|
||||
Status = FormatPartition (&DestinationRootPath);
|
||||
if (!NT_SUCCESS (Status))
|
||||
Status = FormatPartition(&DestinationRootPath, FileSystemList->Selected);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1 ("FormatPartition() failed with status 0x%.08x\n", Status);
|
||||
DPRINT1("FormatPartition() failed with status 0x%08lx\n", Status);
|
||||
/* FIXME: show an error dialog */
|
||||
return QUIT_PAGE;
|
||||
}
|
||||
|
||||
PartEntry->New = FALSE;
|
||||
if (FileSystemList != NULL)
|
||||
{
|
||||
DestroyFileSystemList (FileSystemList);
|
||||
FileSystemList = NULL;
|
||||
|
||||
CheckActiveBootPartition(PartitionList);
|
||||
}
|
||||
|
||||
CheckActiveBootPartition (PartitionList);
|
||||
|
||||
if (strcmp(FileSystemList->Selected->FileSystem, "FAT") == 0)
|
||||
{
|
||||
/* FIXME: Install boot code. This is a hack! */
|
||||
if ((PartEntry->PartInfo[0].PartitionType == PARTITION_FAT32_XINT13) ||
|
||||
(PartEntry->PartInfo[0].PartitionType == PARTITION_FAT32))
|
||||
if ((PartEntry->PartInfo[0].PartitionType == PARTITION_FAT32_XINT13)
|
||||
|| (PartEntry->PartInfo[0].PartitionType == PARTITION_FAT32))
|
||||
{
|
||||
wcscpy (PathBuffer, SourceRootPath.Buffer);
|
||||
wcscat (PathBuffer, L"\\loader\\fat32.bin");
|
||||
wcscpy(PathBuffer, SourceRootPath.Buffer);
|
||||
wcscat(PathBuffer, L"\\loader\\fat32.bin");
|
||||
|
||||
DPRINT ("Install FAT32 bootcode: %S ==> %S\n", PathBuffer,
|
||||
DPRINT("Install FAT32 bootcode: %S ==> %S\n", PathBuffer,
|
||||
DestinationRootPath.Buffer);
|
||||
Status = InstallFat32BootCodeToDisk (PathBuffer,
|
||||
Status = InstallFat32BootCodeToDisk(PathBuffer,
|
||||
DestinationRootPath.Buffer);
|
||||
if (!NT_SUCCESS (Status))
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1 ("InstallFat32BootCodeToDisk() failed with status 0x%.08x\n", Status);
|
||||
DPRINT1("InstallFat32BootCodeToDisk() failed with status 0x%08lx\n", Status);
|
||||
/* FIXME: show an error dialog */
|
||||
DestroyFileSystemList(FileSystemList);
|
||||
FileSystemList = NULL;
|
||||
return QUIT_PAGE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wcscpy (PathBuffer, SourceRootPath.Buffer);
|
||||
wcscat (PathBuffer, L"\\loader\\fat.bin");
|
||||
wcscpy(PathBuffer, SourceRootPath.Buffer);
|
||||
wcscat(PathBuffer, L"\\loader\\fat.bin");
|
||||
|
||||
DPRINT ("Install FAT bootcode: %S ==> %S\n", PathBuffer,
|
||||
DPRINT("Install FAT bootcode: %S ==> %S\n", PathBuffer,
|
||||
DestinationRootPath.Buffer);
|
||||
Status = InstallFat16BootCodeToDisk (PathBuffer,
|
||||
Status = InstallFat16BootCodeToDisk(PathBuffer,
|
||||
DestinationRootPath.Buffer);
|
||||
if (!NT_SUCCESS (Status))
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1 ("InstallFat16BootCodeToDisk() failed with status 0x%.08x\n", Status);
|
||||
DPRINT1("InstallFat16BootCodeToDisk() failed with status 0x%.08x\n", Status);
|
||||
/* FIXME: show an error dialog */
|
||||
DestroyFileSystemList(FileSystemList);
|
||||
FileSystemList = NULL;
|
||||
return QUIT_PAGE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case FsKeep:
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
else if (FileSystemList->Selected->FormatFunc)
|
||||
{
|
||||
DestroyFileSystemList(FileSystemList);
|
||||
FileSystemList = NULL;
|
||||
return QUIT_PAGE;
|
||||
}
|
||||
|
||||
|
@ -2411,6 +2406,8 @@ FormatPartitionPage (PINPUT_RECORD Ir)
|
|||
CONSOLE_ConInKey(Ir);
|
||||
#endif
|
||||
|
||||
DestroyFileSystemList(FileSystemList);
|
||||
FileSystemList = NULL;
|
||||
return INSTALL_DIRECTORY_PAGE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,8 +64,8 @@
|
|||
#include "bootsup.h"
|
||||
#include "keytrans.h"
|
||||
#include "registry.h"
|
||||
#include "format.h"
|
||||
#include "fslist.h"
|
||||
#include "format.h"
|
||||
#include "cabinet.h"
|
||||
#include "filesup.h"
|
||||
#include "drivesup.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue