Install FAT16 bootcode on FAT16 partitions.

Don't modify valid partition types when a partiton is formatted.

svn path=/trunk/; revision=5708
This commit is contained in:
Eric Kohl 2003-08-20 16:31:21 +00:00
parent e4b7ecbc70
commit 1926975c01

View file

@ -702,6 +702,8 @@ SelectPartitionPage(PINPUT_RECORD Ir)
} }
} }
CheckActiveBootPartition (PartitionList);
DrawPartitionList (PartitionList); DrawPartitionList (PartitionList);
while(TRUE) while(TRUE)
@ -1545,39 +1547,44 @@ FormatPartitionPage (PINPUT_RECORD Ir)
{ {
SetStatusText (" Please wait ..."); SetStatusText (" Please wait ...");
switch (FileSystemList->CurrentFileSystem) if (PartEntry->PartInfo[0].PartitionType == PARTITION_ENTRY_UNUSED)
{ {
case FsFat: switch (FileSystemList->CurrentFileSystem)
if (DiskEntry->UseLba == FALSE) {
{ case FsFat:
if (PartEntry->PartInfo[0].PartitionLength.QuadPart < (32ULL * 1024ULL * 1024ULL)) if (DiskEntry->UseLba == FALSE)
{ {
/* FAT16 CHS partition (disk is smaller than 32MB) */ if (PartEntry->PartInfo[0].PartitionLength.QuadPart < (32ULL * 1024ULL * 1024ULL))
PartEntry->PartInfo[0].PartitionType = PARTITION_FAT_16; {
/* FAT16 CHS partition (disk is smaller than 32MB) */
PartEntry->PartInfo[0].PartitionType = PARTITION_FAT_16;
}
else
{
/* FAT16 CHS partition (disk is smaller than 8.4GB) */
PartEntry->PartInfo[0].PartitionType = PARTITION_HUGE;
}
}
else if (PartEntry->PartInfo[0].PartitionLength.QuadPart < (2ULL * 1024ULL * 1024ULL * 1024ULL))
{
/* FAT16 LBA partition (partition is smaller than 2GB) */
DPRINT1("%x\n", PartEntry->PartInfo[0].PartitionType);
PartEntry->PartInfo[0].PartitionType = PARTITION_XINT13;
} }
else else
{ {
/* FAT16 CHS partition (disk is smaller than 8.4GB) */ DPRINT1("%x\n", PartEntry->PartInfo[0].PartitionType);
PartEntry->PartInfo[0].PartitionType = PARTITION_HUGE; /* FAT32 LBA partition (partition is at least 2GB) */
PartEntry->PartInfo[0].PartitionType = PARTITION_FAT32_XINT13;
} }
} break;
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: case FsKeep:
break; break;
default: default:
return QUIT_PAGE; return QUIT_PAGE;
}
} }
CheckActiveBootPartition (PartitionList); CheckActiveBootPartition (PartitionList);
@ -1619,6 +1626,9 @@ FormatPartitionPage (PINPUT_RECORD Ir)
Entry = Entry->Flink; Entry = Entry->Flink;
} }
/* Restore the old entry */
PartEntry = PartitionList->CurrentPartition;
//#endif //#endif
if (WritePartitionsToDisk (PartitionList) == FALSE) if (WritePartitionsToDisk (PartitionList) == FALSE)
@ -1673,19 +1683,48 @@ FormatPartitionPage (PINPUT_RECORD Ir)
return QUIT_PAGE; return QUIT_PAGE;
} }
/* FIXME: Install boot code. This is a hack! */ PartEntry->New = FALSE;
wcscpy (PathBuffer, SourceRootPath.Buffer); if (FileSystemList != NULL)
wcscat (PathBuffer, L"\\loader\\fat32.bin");
DPRINT1 ("Install FAT32 bootcode: %S ==> %S\n", PathBuffer,
DestinationRootPath.Buffer);
Status = InstallFat32BootCodeToDisk (PathBuffer,
DestinationRootPath.Buffer);
if (!NT_SUCCESS (Status))
{ {
DPRINT1 ("InstallFat32BootCodeToDisk() failed with status 0x%.08x\n", Status); DestroyFileSystemList (FileSystemList);
/* FIXME: show an error dialog */ FileSystemList = NULL;
return QUIT_PAGE; }
CheckActiveBootPartition (PartitionList);
/* FIXME: Install boot code. This is a hack! */
if ((PartEntry->PartInfo[0].PartitionType == PARTITION_FAT32_XINT13) ||
(PartEntry->PartInfo[0].PartitionType == PARTITION_FAT32))
{
wcscpy (PathBuffer, SourceRootPath.Buffer);
wcscat (PathBuffer, L"\\loader\\fat32.bin");
DPRINT1 ("Install FAT32 bootcode: %S ==> %S\n", PathBuffer,
DestinationRootPath.Buffer);
Status = InstallFat32BootCodeToDisk (PathBuffer,
DestinationRootPath.Buffer);
if (!NT_SUCCESS (Status))
{
DPRINT1 ("InstallFat32BootCodeToDisk() failed with status 0x%.08x\n", Status);
/* FIXME: show an error dialog */
return QUIT_PAGE;
}
}
else
{
wcscpy (PathBuffer, SourceRootPath.Buffer);
wcscat (PathBuffer, L"\\loader\\fat.bin");
DPRINT1 ("Install FAT bootcode: %S ==> %S\n", PathBuffer,
DestinationRootPath.Buffer);
Status = InstallFat16BootCodeToDisk (PathBuffer,
DestinationRootPath.Buffer);
if (!NT_SUCCESS (Status))
{
DPRINT1 ("InstallFat16BootCodeToDisk() failed with status 0x%.08x\n", Status);
/* FIXME: show an error dialog */
return QUIT_PAGE;
}
} }
break; break;