mirror of
https://github.com/reactos/reactos.git
synced 2025-04-28 01:11:35 +00:00
Translate partition 0 to active partition. Fixes bug 181.
svn path=/trunk/; revision=17736
This commit is contained in:
parent
659c21724b
commit
f2854a8641
12 changed files with 86 additions and 10 deletions
|
@ -34,6 +34,7 @@ extern BOOL i386DiskGetSystemVolume(char *SystemPath, char *RemainingPath,
|
||||||
extern BOOL i386DiskGetBootPath(char *BootPath, unsigned Size);
|
extern BOOL i386DiskGetBootPath(char *BootPath, unsigned Size);
|
||||||
extern VOID i386DiskGetBootDevice(PULONG BootDevice);
|
extern VOID i386DiskGetBootDevice(PULONG BootDevice);
|
||||||
extern BOOL i386DiskBootingFromFloppy(VOID);
|
extern BOOL i386DiskBootingFromFloppy(VOID);
|
||||||
|
extern BOOL i386DiskNormalizeSystemPath(char *SystemPath, unsigned Size);
|
||||||
|
|
||||||
#endif /* __I386_I386_H_ */
|
#endif /* __I386_I386_H_ */
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,7 @@ BOOL DiskGetExtendedDriveParameters(ULONG DriveNumber, PVOID Buffer, USHORT Buff
|
||||||
|
|
||||||
memcpy(Buffer, Ptr, BufferSize);
|
memcpy(Buffer, Ptr, BufferSize);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
DbgPrint((DPRINT_DISK, "size of buffer: %x\n", Ptr[0]));
|
DbgPrint((DPRINT_DISK, "size of buffer: %x\n", Ptr[0]));
|
||||||
DbgPrint((DPRINT_DISK, "information flags: %x\n", Ptr[1]));
|
DbgPrint((DPRINT_DISK, "information flags: %x\n", Ptr[1]));
|
||||||
DbgPrint((DPRINT_DISK, "number of physical cylinders on drive: %u\n", *(PULONG)&Ptr[2]));
|
DbgPrint((DPRINT_DISK, "number of physical cylinders on drive: %u\n", *(PULONG)&Ptr[2]));
|
||||||
|
@ -194,6 +195,7 @@ BOOL DiskGetExtendedDriveParameters(ULONG DriveNumber, PVOID Buffer, USHORT Buff
|
||||||
{
|
{
|
||||||
DbgPrint((DPRINT_HB, "signature: %x\n", Ptr[15]));
|
DbgPrint((DPRINT_HB, "signature: %x\n", Ptr[15]));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -202,6 +204,7 @@ BOOL i386DiskGetBootVolume(PULONG DriveNumber, PULONGLONG StartSector, PULONGLON
|
||||||
{
|
{
|
||||||
PARTITION_TABLE_ENTRY PartitionTableEntry;
|
PARTITION_TABLE_ENTRY PartitionTableEntry;
|
||||||
UCHAR VolumeType;
|
UCHAR VolumeType;
|
||||||
|
ULONG ActivePartition;
|
||||||
|
|
||||||
DbgPrint((DPRINT_FILESYSTEM, "FsOpenVolume() DriveNumber: 0x%x PartitionNumber: 0x%x\n", i386BootDrive, i386BootPartition));
|
DbgPrint((DPRINT_FILESYSTEM, "FsOpenVolume() DriveNumber: 0x%x PartitionNumber: 0x%x\n", i386BootDrive, i386BootPartition));
|
||||||
|
|
||||||
|
@ -234,7 +237,7 @@ BOOL i386DiskGetBootVolume(PULONG DriveNumber, PULONGLONG StartSector, PULONGLON
|
||||||
if (i386BootPartition == 0)
|
if (i386BootPartition == 0)
|
||||||
{
|
{
|
||||||
// Partition requested was zero which means the boot partition
|
// Partition requested was zero which means the boot partition
|
||||||
if (! DiskGetActivePartitionEntry(i386BootDrive, &PartitionTableEntry))
|
if (! DiskGetActivePartitionEntry(i386BootDrive, &PartitionTableEntry, &ActivePartition))
|
||||||
{
|
{
|
||||||
/* Try partition-less disk */
|
/* Try partition-less disk */
|
||||||
*StartSector = 0;
|
*StartSector = 0;
|
||||||
|
@ -460,6 +463,46 @@ i386DiskGetBootPath(char *BootPath, unsigned Size)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL
|
||||||
|
i386DiskNormalizeSystemPath(char *SystemPath, unsigned Size)
|
||||||
|
{
|
||||||
|
CHAR BootPath[256];
|
||||||
|
ULONG PartitionNumber;
|
||||||
|
ULONG DriveNumber;
|
||||||
|
PARTITION_TABLE_ENTRY PartEntry;
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
if (!DissectArcPath(SystemPath, BootPath, &DriveNumber, &PartitionNumber))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 != PartitionNumber)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! DiskGetActivePartitionEntry(DriveNumber,
|
||||||
|
&PartEntry,
|
||||||
|
&PartitionNumber) ||
|
||||||
|
PartitionNumber < 1 || 9 < PartitionNumber)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = SystemPath;
|
||||||
|
while ('\0' != *p && 0 != strnicmp(p, "partition(", 10)) {
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
p = strchr(p, ')');
|
||||||
|
if (NULL == p || '0' != *(p - 1)) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
*(p - 1) = '0' + PartitionNumber;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* defined __i386__ */
|
#endif /* defined __i386__ */
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -54,6 +54,7 @@ PcMachInit(char *CmdLine)
|
||||||
MachVtbl.DiskGetBootPath = i386DiskGetBootPath;
|
MachVtbl.DiskGetBootPath = i386DiskGetBootPath;
|
||||||
MachVtbl.DiskGetBootDevice = i386DiskGetBootDevice;
|
MachVtbl.DiskGetBootDevice = i386DiskGetBootDevice;
|
||||||
MachVtbl.DiskBootingFromFloppy = i386DiskBootingFromFloppy;
|
MachVtbl.DiskBootingFromFloppy = i386DiskBootingFromFloppy;
|
||||||
|
MachVtbl.DiskNormalizeSystemPath = i386DiskNormalizeSystemPath;
|
||||||
MachVtbl.DiskReadLogicalSectors = PcDiskReadLogicalSectors;
|
MachVtbl.DiskReadLogicalSectors = PcDiskReadLogicalSectors;
|
||||||
MachVtbl.DiskGetPartitionEntry = PcDiskGetPartitionEntry;
|
MachVtbl.DiskGetPartitionEntry = PcDiskGetPartitionEntry;
|
||||||
MachVtbl.DiskGetDriveGeometry = PcDiskGetDriveGeometry;
|
MachVtbl.DiskGetDriveGeometry = PcDiskGetDriveGeometry;
|
||||||
|
|
|
@ -52,6 +52,7 @@ XboxMachInit(char *CmdLine)
|
||||||
MachVtbl.DiskGetBootPath = i386DiskGetBootPath;
|
MachVtbl.DiskGetBootPath = i386DiskGetBootPath;
|
||||||
MachVtbl.DiskGetBootDevice = i386DiskGetBootDevice;
|
MachVtbl.DiskGetBootDevice = i386DiskGetBootDevice;
|
||||||
MachVtbl.DiskBootingFromFloppy = i386DiskBootingFromFloppy;
|
MachVtbl.DiskBootingFromFloppy = i386DiskBootingFromFloppy;
|
||||||
|
MachVtbl.DiskNormalizeSystemPath = i386DiskNormalizeSystemPath;
|
||||||
MachVtbl.DiskReadLogicalSectors = XboxDiskReadLogicalSectors;
|
MachVtbl.DiskReadLogicalSectors = XboxDiskReadLogicalSectors;
|
||||||
MachVtbl.DiskGetPartitionEntry = XboxDiskGetPartitionEntry;
|
MachVtbl.DiskGetPartitionEntry = XboxDiskGetPartitionEntry;
|
||||||
MachVtbl.DiskGetDriveGeometry = XboxDiskGetDriveGeometry;
|
MachVtbl.DiskGetDriveGeometry = XboxDiskGetDriveGeometry;
|
||||||
|
|
|
@ -26,12 +26,14 @@
|
||||||
#include <machine.h>
|
#include <machine.h>
|
||||||
|
|
||||||
|
|
||||||
BOOL DiskGetActivePartitionEntry(ULONG DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
|
BOOL DiskGetActivePartitionEntry(ULONG DriveNumber,
|
||||||
|
PPARTITION_TABLE_ENTRY PartitionTableEntry,
|
||||||
|
ULONG *ActivePartition)
|
||||||
{
|
{
|
||||||
ULONG BootablePartitionCount = 0;
|
ULONG BootablePartitionCount = 0;
|
||||||
ULONG ActivePartition = 0;
|
|
||||||
MASTER_BOOT_RECORD MasterBootRecord;
|
MASTER_BOOT_RECORD MasterBootRecord;
|
||||||
|
|
||||||
|
*ActivePartition = 0;
|
||||||
// Read master boot record
|
// Read master boot record
|
||||||
if (!DiskReadBootRecord(DriveNumber, 0, &MasterBootRecord))
|
if (!DiskReadBootRecord(DriveNumber, 0, &MasterBootRecord))
|
||||||
{
|
{
|
||||||
|
@ -42,22 +44,22 @@ BOOL DiskGetActivePartitionEntry(ULONG DriveNumber, PPARTITION_TABLE_ENTRY Parti
|
||||||
if (MasterBootRecord.PartitionTable[0].BootIndicator == 0x80)
|
if (MasterBootRecord.PartitionTable[0].BootIndicator == 0x80)
|
||||||
{
|
{
|
||||||
BootablePartitionCount++;
|
BootablePartitionCount++;
|
||||||
ActivePartition = 0;
|
*ActivePartition = 1;
|
||||||
}
|
}
|
||||||
if (MasterBootRecord.PartitionTable[1].BootIndicator == 0x80)
|
if (MasterBootRecord.PartitionTable[1].BootIndicator == 0x80)
|
||||||
{
|
{
|
||||||
BootablePartitionCount++;
|
BootablePartitionCount++;
|
||||||
ActivePartition = 1;
|
*ActivePartition = 2;
|
||||||
}
|
}
|
||||||
if (MasterBootRecord.PartitionTable[2].BootIndicator == 0x80)
|
if (MasterBootRecord.PartitionTable[2].BootIndicator == 0x80)
|
||||||
{
|
{
|
||||||
BootablePartitionCount++;
|
BootablePartitionCount++;
|
||||||
ActivePartition = 2;
|
*ActivePartition = 3;
|
||||||
}
|
}
|
||||||
if (MasterBootRecord.PartitionTable[3].BootIndicator == 0x80)
|
if (MasterBootRecord.PartitionTable[3].BootIndicator == 0x80)
|
||||||
{
|
{
|
||||||
BootablePartitionCount++;
|
BootablePartitionCount++;
|
||||||
ActivePartition = 3;
|
*ActivePartition = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure there was only one bootable partition
|
// Make sure there was only one bootable partition
|
||||||
|
@ -73,7 +75,9 @@ BOOL DiskGetActivePartitionEntry(ULONG DriveNumber, PPARTITION_TABLE_ENTRY Parti
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the partition table entry
|
// Copy the partition table entry
|
||||||
RtlCopyMemory(PartitionTableEntry, &MasterBootRecord.PartitionTable[ActivePartition], sizeof(PARTITION_TABLE_ENTRY));
|
RtlCopyMemory(PartitionTableEntry,
|
||||||
|
&MasterBootRecord.PartitionTable[*ActivePartition - 1],
|
||||||
|
sizeof(PARTITION_TABLE_ENTRY));
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ VOID DiskStopFloppyMotor(VOID); // Implemented in i386disk.c
|
||||||
// Fixed Disk Partition Management Functions
|
// Fixed Disk Partition Management Functions
|
||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////
|
||||||
BOOL DiskGetActivePartitionEntry(ULONG DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
|
BOOL DiskGetActivePartitionEntry(ULONG DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry, ULONG *ActivePartition);
|
||||||
BOOL DiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
|
BOOL DiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
|
||||||
BOOL DiskGetFirstPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry);
|
BOOL DiskGetFirstPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry);
|
||||||
BOOL DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry);
|
BOOL DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry);
|
||||||
|
|
|
@ -61,6 +61,7 @@ typedef struct tagMACHVTBL
|
||||||
BOOL (*DiskGetBootPath)(char *BootPath, unsigned Size);
|
BOOL (*DiskGetBootPath)(char *BootPath, unsigned Size);
|
||||||
VOID (*DiskGetBootDevice)(PULONG BootDevice);
|
VOID (*DiskGetBootDevice)(PULONG BootDevice);
|
||||||
BOOL (*DiskBootingFromFloppy)(VOID);
|
BOOL (*DiskBootingFromFloppy)(VOID);
|
||||||
|
BOOL (*DiskNormalizeSystemPath)(char *SystemPath, unsigned Size);
|
||||||
BOOL (*DiskReadLogicalSectors)(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer);
|
BOOL (*DiskReadLogicalSectors)(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer);
|
||||||
BOOL (*DiskGetPartitionEntry)(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
|
BOOL (*DiskGetPartitionEntry)(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
|
||||||
BOOL (*DiskGetDriveGeometry)(ULONG DriveNumber, PGEOMETRY DriveGeometry);
|
BOOL (*DiskGetDriveGeometry)(ULONG DriveNumber, PGEOMETRY DriveGeometry);
|
||||||
|
@ -97,6 +98,7 @@ extern MACHVTBL MachVtbl;
|
||||||
#define MachDiskGetBootPath(Path, Size) MachVtbl.DiskGetBootPath((Path), (Size))
|
#define MachDiskGetBootPath(Path, Size) MachVtbl.DiskGetBootPath((Path), (Size))
|
||||||
#define MachDiskGetBootDevice(BootDevice) MachVtbl.DiskGetBootDevice(BootDevice)
|
#define MachDiskGetBootDevice(BootDevice) MachVtbl.DiskGetBootDevice(BootDevice)
|
||||||
#define MachDiskBootingFromFloppy() MachVtbl.DiskBootingFromFloppy()
|
#define MachDiskBootingFromFloppy() MachVtbl.DiskBootingFromFloppy()
|
||||||
|
#define MachDiskNormalizeSystemPath(Path, Size) MachVtbl.DiskNormalizeSystemPath((Path), (Size))
|
||||||
#define MachDiskReadLogicalSectors(Drive, Start, Count, Buf) MachVtbl.DiskReadLogicalSectors((Drive), (Start), (Count), (Buf))
|
#define MachDiskReadLogicalSectors(Drive, Start, Count, Buf) MachVtbl.DiskReadLogicalSectors((Drive), (Start), (Count), (Buf))
|
||||||
#define MachDiskGetPartitionEntry(Drive, Part, Entry) MachVtbl.DiskGetPartitionEntry((Drive), (Part), (Entry))
|
#define MachDiskGetPartitionEntry(Drive, Part, Entry) MachVtbl.DiskGetPartitionEntry((Drive), (Part), (Entry))
|
||||||
#define MachDiskGetDriveGeometry(Drive, Geom) MachVtbl.DiskGetDriveGeometry((Drive), (Geom))
|
#define MachDiskGetDriveGeometry(Drive, Geom) MachVtbl.DiskGetDriveGeometry((Drive), (Geom))
|
||||||
|
|
|
@ -81,6 +81,11 @@ VOID LoadAndBootLinux(PCHAR OperatingSystemName, PCHAR Description)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open the boot volume
|
// Open the boot volume
|
||||||
|
if (!MachDiskNormalizeSystemPath(LinuxBootPath, sizeof(LinuxBootPath)))
|
||||||
|
{
|
||||||
|
UiMessageBox("Invalid boot path");
|
||||||
|
goto LinuxBootFailed;
|
||||||
|
}
|
||||||
if (!FsOpenSystemVolume(LinuxBootPath, NULL, NULL))
|
if (!FsOpenSystemVolume(LinuxBootPath, NULL, NULL))
|
||||||
{
|
{
|
||||||
UiMessageBox("Failed to open boot drive.");
|
UiMessageBox("Failed to open boot drive.");
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#undef MachDiskGetBootPath
|
#undef MachDiskGetBootPath
|
||||||
#undef MachDiskGetBootDevice
|
#undef MachDiskGetBootDevice
|
||||||
#undef MachDiskBootingFromFloppy
|
#undef MachDiskBootingFromFloppy
|
||||||
|
#undef MachDiskNormalizeSystemPath
|
||||||
#undef MachDiskReadLogicalSectors
|
#undef MachDiskReadLogicalSectors
|
||||||
#undef MachDiskGetPartitionEntry
|
#undef MachDiskGetPartitionEntry
|
||||||
#undef MachDiskGetDriveGeometry
|
#undef MachDiskGetDriveGeometry
|
||||||
|
@ -191,6 +192,12 @@ MachDiskBootingFromFloppy()
|
||||||
return MachVtbl.DiskBootingFromFloppy();
|
return MachVtbl.DiskBootingFromFloppy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL
|
||||||
|
MachDiskNormalizeSystemPath(char *SystemPath, unsigned Size)
|
||||||
|
{
|
||||||
|
return MachVtbl.DiskNormalizeSystemPath(SystemPath, Size);
|
||||||
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
MachDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
|
MachDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
|
||||||
{
|
{
|
||||||
|
|
|
@ -54,6 +54,12 @@ VOID LoadAndBootBootSector(PCHAR OperatingSystemName)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!MachDiskNormalizeSystemPath(FileName, sizeof(FileName)))
|
||||||
|
{
|
||||||
|
UiMessageBox("Invalid path to boot sector file");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!FsOpenSystemVolume(FileName, FileName, NULL))
|
if (!FsOpenSystemVolume(FileName, FileName, NULL))
|
||||||
{
|
{
|
||||||
UiMessageBox("Failed to open boot drive.");
|
UiMessageBox("Failed to open boot drive.");
|
||||||
|
|
|
@ -73,7 +73,7 @@ BOOL DissectArcPath(CHAR *ArcPath, CHAR *BootPath, ULONG* BootDrive, ULONG* Boot
|
||||||
p = p + 11;
|
p = p + 11;
|
||||||
*BootPartition = atoi(p);
|
*BootPartition = atoi(p);
|
||||||
p = strchr(p, ')');
|
p = strchr(p, ')');
|
||||||
if ((p == NULL) || (*BootPartition == 0))
|
if (p == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -671,6 +671,12 @@ LoadAndBootReactOS(PCHAR OperatingSystemName)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (! MachDiskNormalizeSystemPath(SystemPath,
|
||||||
|
sizeof(SystemPath)))
|
||||||
|
{
|
||||||
|
UiMessageBox("Invalid system path");
|
||||||
|
return;
|
||||||
|
}
|
||||||
/* copy system path into kernel command line */
|
/* copy system path into kernel command line */
|
||||||
strcpy(reactos_kernel_cmdline, SystemPath);
|
strcpy(reactos_kernel_cmdline, SystemPath);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue