[USETUP][SETUPLIB] Continue hiding the FAT32 format in the format list, but take it into account anyway later on.

The formatter will select it anyway as soon as the partition size
permits it. We make it available internally however so as to "emulate"
FMIFS functionality.

Now rely on the partition filesystem for InstallVBRToPartition() instead
of the unreliable and deprecated partition type.
This commit is contained in:
Hermès Bélusca-Maïto 2020-10-19 23:49:26 +02:00
parent 593bcce999
commit 08924c1850
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
6 changed files with 97 additions and 59 deletions

View file

@ -794,7 +794,7 @@ InstallFatBootcodeToPartition(
IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SystemRootPath,
IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING SourceRootPath,
IN PUNICODE_STRING DestinationArcPath, IN PUNICODE_STRING DestinationArcPath,
IN UCHAR PartitionType) IN PCWSTR FileSystemName)
{ {
NTSTATUS Status; NTSTATUS Status;
BOOLEAN DoesFreeLdrExist; BOOLEAN DoesFreeLdrExist;
@ -856,8 +856,7 @@ InstallFatBootcodeToPartition(
/* Install new bootcode into a file */ /* Install new bootcode into a file */
CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"bootsect.ros"); CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"bootsect.ros");
if (PartitionType == PARTITION_FAT32 || if (wcsicmp(FileSystemName, L"FAT32") == 0)
PartitionType == PARTITION_FAT32_XINT13)
{ {
/* Install FAT32 bootcode */ /* Install FAT32 bootcode */
CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat32.bin"); CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat32.bin");
@ -872,7 +871,7 @@ InstallFatBootcodeToPartition(
return Status; return Status;
} }
} }
else else // if (wcsicmp(FileSystemName, L"FAT") == 0)
{ {
/* Install FAT16 bootcode */ /* Install FAT16 bootcode */
CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat.bin"); CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat.bin");
@ -1070,8 +1069,7 @@ InstallFatBootcodeToPartition(
} }
/* Install new bootsector on the disk */ /* Install new bootsector on the disk */
if (PartitionType == PARTITION_FAT32 || if (wcsicmp(FileSystemName, L"FAT32") == 0)
PartitionType == PARTITION_FAT32_XINT13)
{ {
/* Install FAT32 bootcode */ /* Install FAT32 bootcode */
CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat32.bin"); CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat32.bin");
@ -1084,7 +1082,7 @@ InstallFatBootcodeToPartition(
return Status; return Status;
} }
} }
else else // if (wcsicmp(FileSystemName, L"FAT") == 0)
{ {
/* Install FAT16 bootcode */ /* Install FAT16 bootcode */
CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat.bin"); CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat.bin");
@ -1212,40 +1210,46 @@ InstallVBRToPartition(
IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SystemRootPath,
IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING SourceRootPath,
IN PUNICODE_STRING DestinationArcPath, IN PUNICODE_STRING DestinationArcPath,
IN UCHAR PartitionType) IN PCWSTR FileSystemName)
{ {
switch (PartitionType) if (wcsicmp(FileSystemName, L"FAT") == 0 ||
{ wcsicmp(FileSystemName, L"FAT32") == 0)
case PARTITION_FAT_12:
case PARTITION_FAT_16:
case PARTITION_HUGE:
case PARTITION_XINT13:
case PARTITION_FAT32:
case PARTITION_FAT32_XINT13:
{ {
return InstallFatBootcodeToPartition(SystemRootPath, return InstallFatBootcodeToPartition(SystemRootPath,
SourceRootPath, SourceRootPath,
DestinationArcPath, DestinationArcPath,
PartitionType); FileSystemName);
} }
/*
case PARTITION_LINUX: else if (wcsicmp(FileSystemName, L"NTFS") == 0)
{
DPRINT1("Partitions of type NTFS or HPFS are not supported yet!\n");
return STATUS_NOT_SUPPORTED;
}
*/
else if (wcsicmp(FileSystemName, L"BTRFS") == 0)
{ {
return InstallBtrfsBootcodeToPartition(SystemRootPath, return InstallBtrfsBootcodeToPartition(SystemRootPath,
SourceRootPath, SourceRootPath,
DestinationArcPath); DestinationArcPath);
} }
/*
case PARTITION_IFS: else if (wcsicmp(FileSystemName, L"EXT2") == 0 ||
DPRINT1("Partitions of type NTFS or HPFS are not supported yet!\n"); wcsicmp(FileSystemName, L"EXT3") == 0 ||
break; wcsicmp(FileSystemName, L"EXT4") == 0 ||
wcsicmp(FileSystemName, L"FFS") == 0 ||
default: wcsicmp(FileSystemName, L"REISERFS") == 0)
DPRINT1("PartitionType 0x%02X unknown!\n", PartitionType); {
break; return STATUS_NOT_SUPPORTED;
}
*/
else
{
/* Unknown file system */
DPRINT1("Unknown file system '%S'\n", FileSystemName);
} }
return STATUS_UNSUCCESSFUL; return STATUS_NOT_SUPPORTED;
} }

View file

@ -37,7 +37,7 @@ InstallVBRToPartition(
IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SystemRootPath,
IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING SourceRootPath,
IN PUNICODE_STRING DestinationArcPath, IN PUNICODE_STRING DestinationArcPath,
IN UCHAR PartitionType); IN PCWSTR FileSystemName);
NTSTATUS NTSTATUS
InstallFatBootcodeToFloppy( InstallFatBootcodeToFloppy(

View file

@ -129,11 +129,11 @@ typedef struct _FILE_SYSTEM
/* The list of file systems on which we can install ReactOS */ /* The list of file systems on which we can install ReactOS */
static FILE_SYSTEM RegisteredFileSystems[] = static FILE_SYSTEM RegisteredFileSystems[] =
{ {
/* NOTE: The FAT formatter automatically determines /* NOTE: The FAT formatter will automatically
* whether it will use FAT-16 or FAT-32. */ * determine whether to use FAT12/16 or FAT32. */
{ L"FAT" , VfatFormat, VfatChkdsk }, { L"FAT" , VfatFormat, VfatChkdsk },
{ L"FAT32", VfatFormat, VfatChkdsk },
#if 0 #if 0
{ L"FAT32", VfatFormat, VfatChkdsk }, // Do we support specific FAT sub-formats specifications?
{ L"FATX" , VfatxFormat, VfatxChkdsk }, { L"FATX" , VfatxFormat, VfatxChkdsk },
{ L"NTFS" , NtfsFormat, NtfsChkdsk }, { L"NTFS" , NtfsFormat, NtfsChkdsk },
#endif #endif
@ -180,9 +180,7 @@ GetFileSystemByName(
{ {
Item = CONTAINING_RECORD(ListEntry, FILE_SYSTEM_ITEM, ListEntry); Item = CONTAINING_RECORD(ListEntry, FILE_SYSTEM_ITEM, ListEntry);
if (Item->FileSystemName && if (Item->FileSystemName &&
(wcsicmp(FileSystemName, Item->FileSystemName) == 0 || (wcsicmp(FileSystemName, Item->FileSystemName) == 0))
/* Map FAT32 back to FAT */
(wcsicmp(FileSystemName, L"FAT32") == 0 && wcsicmp(Item->FileSystemName, L"FAT") == 0)))
{ {
return Item; return Item;
} }
@ -200,9 +198,7 @@ GetFileSystemByName(
while (Count--) while (Count--)
{ {
if (FileSystems->FileSystemName && if (FileSystems->FileSystemName &&
(wcsicmp(FileSystemName, FileSystems->FileSystemName) == 0 || (wcsicmp(FileSystemName, FileSystems->FileSystemName) == 0))
/* Map FAT32 back to FAT */
(wcsicmp(FileSystemName, L"FAT32") == 0 && wcsicmp(FileSystems->FileSystemName, L"FAT") == 0)))
{ {
return FileSystems; return FileSystems;
} }
@ -330,7 +326,7 @@ FormatFileSystem(
// //
NTSTATUS NTSTATUS
InstallFat1216BootCode( InstallFatBootCode(
IN PCWSTR SrcPath, // FAT12/16 bootsector source file (on the installation medium) IN PCWSTR SrcPath, // FAT12/16 bootsector source file (on the installation medium)
IN HANDLE DstPath, // Where to save the bootsector built from the source + partition information IN HANDLE DstPath, // Where to save the bootsector built from the source + partition information
IN HANDLE RootPartition) // Partition holding the (old) FAT12/16 information IN HANDLE RootPartition) // Partition holding the (old) FAT12/16 information
@ -645,6 +641,19 @@ PreparePartitionForFormatting(
SetPartitionType(PartEntry, PartitionType); SetPartitionType(PartEntry, PartitionType);
/*
* Adjust the filesystem name in case of FAT vs. FAT32, according to
* the type of partition set by FileSystemToPartitionType().
*/
if (wcsicmp(FileSystemName, L"FAT") == 0)
{
if ((/*PartEntry->*/PartitionType == PARTITION_FAT32) ||
(/*PartEntry->*/PartitionType == PARTITION_FAT32_XINT13))
{
FileSystemName = L"FAT32";
}
}
// //
// FIXME: Do this now, or after the partition was actually formatted?? // FIXME: Do this now, or after the partition was actually formatted??
// //

View file

@ -76,13 +76,13 @@ typedef NTSTATUS
IN HANDLE RootPartition); // Partition holding the (old) bootsector data information IN HANDLE RootPartition); // Partition holding the (old) bootsector data information
NTSTATUS NTSTATUS
InstallFat1216BootCode( InstallFatBootCode(
IN PCWSTR SrcPath, IN PCWSTR SrcPath,
IN HANDLE DstPath, IN HANDLE DstPath,
IN HANDLE RootPartition); IN HANDLE RootPartition);
#define InstallFat12BootCode InstallFat1216BootCode #define InstallFat12BootCode InstallFatBootCode
#define InstallFat16BootCode InstallFat1216BootCode #define InstallFat16BootCode InstallFatBootCode
NTSTATUS NTSTATUS
InstallFat32BootCode( InstallFat32BootCode(

View file

@ -29,6 +29,9 @@
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
/* Enable this define to hide FAT32 choice in case FAT is already present */
#define HIDE_FAT32_CHOICE
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
static VOID static VOID
@ -60,14 +63,38 @@ AddProvider(
static VOID static VOID
InitializeFileSystemList( InitializeFileSystemList(
IN PFILE_SYSTEM_LIST List, IN OUT PFILE_SYSTEM_LIST List,
IN BOOLEAN ForceFormat) IN BOOLEAN ForceFormat)
{ {
ULONG Index = 0;
PCWSTR FileSystemName; PCWSTR FileSystemName;
ULONG Index;
#ifdef HIDE_FAT32_CHOICE
BOOLEAN FatPresent = FALSE;
/* Check whether the FAT filesystem is present */
Index = 0;
while (GetRegisteredFileSystems(Index++, &FileSystemName)) while (GetRegisteredFileSystems(Index++, &FileSystemName))
{ {
if (wcsicmp(FileSystemName, L"FAT") == 0)
{
FatPresent = TRUE;
break;
}
}
#endif
Index = 0;
while (GetRegisteredFileSystems(Index++, &FileSystemName))
{
#ifdef HIDE_FAT32_CHOICE
/* USETUP only: If the FAT filesystem is present, show it, but
* don't display FAT32. The FAT formatter will automatically
* determine whether to use FAT12/16 or FAT32. */
if (FatPresent && wcsicmp(FileSystemName, L"FAT32") == 0)
continue;
#endif
AddProvider(List, FileSystemName); AddProvider(List, FileSystemName);
} }

View file

@ -3510,7 +3510,7 @@ FormatPartitionPage(PINPUT_RECORD Ir)
/* Format the partition */ /* Format the partition */
Status = FormatPartition(&PartitionRootPath, Status = FormatPartition(&PartitionRootPath,
SelectedFileSystem->FileSystem, PartEntry->FileSystem,
SelectedFileSystem->QuickFormat); SelectedFileSystem->QuickFormat);
if (Status == STATUS_NOT_SUPPORTED) if (Status == STATUS_NOT_SUPPORTED)
{ {
@ -3519,7 +3519,7 @@ FormatPartitionPage(PINPUT_RECORD Ir)
"\n" "\n"
" \x07 Press ENTER to continue Setup.\n" " \x07 Press ENTER to continue Setup.\n"
" \x07 Press F3 to quit Setup.", " \x07 Press F3 to quit Setup.",
SelectedFileSystem->FileSystem); PartEntry->FileSystem);
PopupError(Buffer, PopupError(Buffer,
MUIGetString(STRING_QUITCONTINUE), MUIGetString(STRING_QUITCONTINUE),
@ -4612,11 +4612,10 @@ BootLoaderHarddiskVbrPage(PINPUT_RECORD Ir)
{ {
NTSTATUS Status; NTSTATUS Status;
// FIXME! We must not use the partition type, but instead use the partition FileSystem!!
Status = InstallVBRToPartition(&USetupData.SystemRootPath, Status = InstallVBRToPartition(&USetupData.SystemRootPath,
&USetupData.SourceRootPath, &USetupData.SourceRootPath,
&USetupData.DestinationArcPath, &USetupData.DestinationArcPath,
SystemPartition->PartitionType); SystemPartition->FileSystem);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
MUIDisplayError(ERROR_WRITE_BOOT, Ir, POPUP_WAIT_ENTER, MUIDisplayError(ERROR_WRITE_BOOT, Ir, POPUP_WAIT_ENTER,
@ -4649,11 +4648,10 @@ BootLoaderHarddiskMbrPage(PINPUT_RECORD Ir)
WCHAR DestinationDevicePathBuffer[MAX_PATH]; WCHAR DestinationDevicePathBuffer[MAX_PATH];
/* Step 1: Write the VBR */ /* Step 1: Write the VBR */
// FIXME! We must not use the partition type, but instead use the partition FileSystem!!
Status = InstallVBRToPartition(&USetupData.SystemRootPath, Status = InstallVBRToPartition(&USetupData.SystemRootPath,
&USetupData.SourceRootPath, &USetupData.SourceRootPath,
&USetupData.DestinationArcPath, &USetupData.DestinationArcPath,
SystemPartition->PartitionType); SystemPartition->FileSystem);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
MUIDisplayError(ERROR_WRITE_BOOT, Ir, POPUP_WAIT_ENTER, MUIDisplayError(ERROR_WRITE_BOOT, Ir, POPUP_WAIT_ENTER,