- Add a new property to the disk entry: NoMbr flag. It's set, if MBR's first two bytes are zero (same algorithm is used by our cdrom bootsector).

- If this flag is set for a boot disk, ReactOS MBR code will be installed on it.
See issue #4355 for more details.

svn path=/trunk/; revision=40437
This commit is contained in:
Aleksey Bragin 2009-04-10 10:37:08 +00:00
parent 6b245eee92
commit b3c86c2ac0
3 changed files with 35 additions and 4 deletions

View file

@ -2380,6 +2380,28 @@ FormatPartitionPage (PINPUT_RECORD Ir)
CheckActiveBootPartition(PartitionList);
}
/* Install MBR if necessary */
if (DiskEntry->NoMbr &&
DiskEntry->BiosDiskNumber == 0)
{
wcscpy(PathBuffer, SourceRootPath.Buffer);
wcscat(PathBuffer, L"\\loader\\dosmbr.bin");
DPRINT("Install MBR bootcode: %S ==> %S\n",
PathBuffer, DestinationRootPath.Buffer);
/* Install MBR bootcode */
Status = InstallMbrBootCodeToDisk(PathBuffer, DestinationRootPath.Buffer);
if (!NT_SUCCESS (Status))
{
DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
Status);
return FALSE;
}
DiskEntry->NoMbr = FALSE;
}
if (wcscmp(FileSystemList->Selected->FileSystem, L"FAT") == 0)
{
/* FIXME: Install boot code. This is a hack! */

View file

@ -775,10 +775,6 @@ AddDiskToList (HANDLE FileHandle,
}
Checksum = ~Checksum + 1;
RtlFreeHeap (ProcessHeap,
0,
Mbr);
swprintf(Identifier, L"%08x-%08x-A", Checksum, Signature);
DPRINT("Identifier: %S\n", Identifier);
@ -799,6 +795,17 @@ AddDiskToList (HANDLE FileHandle,
}
DiskEntry->BiosFound = FALSE;
/* Check if this disk has a valid MBR */
if (Mbr->BootCode[0] == 0 && Mbr->BootCode[1] == 0)
DiskEntry->NoMbr = TRUE;
else
DiskEntry->NoMbr = FALSE;
/* Free Mbr sector buffer */
RtlFreeHeap (ProcessHeap,
0,
Mbr);
ListEntry = List->BiosDiskListHead.Flink;
while(ListEntry != &List->BiosDiskListHead)
{
@ -2672,6 +2679,7 @@ WritePartitionsToDisk (PPARTLIST List)
}
DiskEntry1->NewDisk = FALSE;
DiskEntry1->NoMbr = FALSE;
}
}

View file

@ -109,6 +109,7 @@ typedef struct _DISKENTRY
BOOLEAN Modified;
BOOLEAN NewDisk;
BOOLEAN NoMbr; /* MBR is absent */
UNICODE_STRING DriverName;