diff --git a/reactos/boot/freeldr/freeldr/arch/i386/machpc.c b/reactos/boot/freeldr/freeldr/arch/i386/machpc.c index 74f3e22ee4c..1b985f28c4d 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/machpc.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/machpc.c @@ -45,7 +45,6 @@ PcMachInit(const char *CmdLine) MachVtbl.PrepareForReactOS = PcPrepareForReactOS; MachVtbl.GetMemoryMap = PcMemGetMemoryMap; MachVtbl.DiskGetBootPath = DiskGetBootPath; - MachVtbl.DiskNormalizeSystemPath = DiskNormalizeSystemPath; MachVtbl.DiskReadLogicalSectors = PcDiskReadLogicalSectors; MachVtbl.DiskGetDriveGeometry = PcDiskGetDriveGeometry; MachVtbl.DiskGetCacheableBlockCount = PcDiskGetCacheableBlockCount; diff --git a/reactos/boot/freeldr/freeldr/arch/i386/machxbox.c b/reactos/boot/freeldr/freeldr/arch/i386/machxbox.c index 442c7be2f1d..704a7ae91cc 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/machxbox.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/machxbox.c @@ -48,7 +48,6 @@ XboxMachInit(const char *CmdLine) MachVtbl.PrepareForReactOS = XboxPrepareForReactOS; MachVtbl.GetMemoryMap = XboxMemGetMemoryMap; MachVtbl.DiskGetBootPath = DiskGetBootPath; - MachVtbl.DiskNormalizeSystemPath = DiskNormalizeSystemPath; MachVtbl.DiskReadLogicalSectors = XboxDiskReadLogicalSectors; MachVtbl.DiskGetDriveGeometry = XboxDiskGetDriveGeometry; MachVtbl.DiskGetCacheableBlockCount = XboxDiskGetCacheableBlockCount; diff --git a/reactos/boot/freeldr/freeldr/arch/i386/miscboot.c b/reactos/boot/freeldr/freeldr/arch/i386/miscboot.c index e0aa98cfd50..1f30141ce7f 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/miscboot.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/miscboot.c @@ -44,12 +44,6 @@ VOID LoadAndBootBootSector(PCSTR OperatingSystemName) return; } - if (!MachDiskNormalizeSystemPath(FileName, sizeof(FileName))) - { - UiMessageBox("Invalid path to boot sector file"); - return; - } - FilePointer = FsOpenFile(FileName); if (!FilePointer) { diff --git a/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c b/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c index 57cacd27675..9abd56bca53 100644 --- a/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c +++ b/reactos/boot/freeldr/freeldr/arch/powerpc/mach.c @@ -440,7 +440,6 @@ void PpcDefaultMachVtbl() MachVtbl.GetMemoryMap = PpcGetMemoryMap; - MachVtbl.DiskNormalizeSystemPath = DiskNormalizeSystemPath; MachVtbl.DiskGetBootPath = PpcDiskGetBootPath; MachVtbl.DiskReadLogicalSectors = PpcDiskReadLogicalSectors; MachVtbl.DiskGetDriveGeometry = PpcDiskGetDriveGeometry; diff --git a/reactos/boot/freeldr/freeldr/disk/disk.c b/reactos/boot/freeldr/freeldr/disk/disk.c index a5a65103aac..b7ce3295497 100644 --- a/reactos/boot/freeldr/freeldr/disk/disk.c +++ b/reactos/boot/freeldr/freeldr/disk/disk.c @@ -107,62 +107,80 @@ DiskGetBootPath(char *BootPath, unsigned Size) { static char Path[] = "multi(0)disk(0)"; char Device[4]; - - _itoa(BootDrive, Device, 10); - if (Size <= sizeof(Path) + 6 + strlen(Device)) + char Partition[4]; + PARTITION_TABLE_ENTRY PartitionEntry; + MASTER_BOOT_RECORD MasterBootRecord; + + if (BootDrive < 0x80) { - return FALSE; + /* This is a floppy */ + + if (Size <= sizeof(Path) + 7 + strlen(Device)) + { + return FALSE; + } + + strcpy(BootPath, Path); + + strcat(BootPath, "fdisk"); + + _itoa(BootDrive, Device, 10); + strcat(BootPath, "("); + strcat(BootPath, Device); + strcat(BootPath, ")"); } - strcpy(BootPath, Path); - strcat(BootPath, BootDrive < 0x80 ? "fdisk" : "cdrom"); - strcat(strcat(strcat(BootPath, "("), Device), ")"); - - if (strcmp(BootPath, "multi(0)disk(0)cdrom(128)") == 0) - strcpy(BootPath, "multi(0)disk(0)rdisk(0)partition(1)"); + /* FIXME */ + else if (DiskReadBootRecord(BootDrive, 0, &MasterBootRecord)) + { + /* This is a hard disk */ + + if (!DiskGetActivePartitionEntry(BootDrive, &PartitionEntry, &BootPartition)) + { + DbgPrint("Invalid active partition information\n"); + return FALSE; + } + + if (Size <= sizeof(Path) + 18 + strlen(Device) + strlen(Partition)) + { + return FALSE; + } + + strcpy(BootPath, Path); + + strcat(BootPath, "rdisk"); + + _itoa(BootDrive - 0x80, Device, 10); + strcat(BootPath, "("); + strcat(BootPath, Device); + strcat(BootPath, ")"); + + _itoa(BootPartition, Partition, 10); + strcat(BootPath, "partition("); + strcat(BootPath, Partition); + strcat(BootPath, ")"); + } + else + { + /* This is a CD-ROM drive */ + + if (Size <= sizeof(Path) + 7 + strlen(Device)) + { + return FALSE; + } + + strcpy(BootPath, Path); + + strcat(BootPath, "cdrom"); + + _itoa(BootDrive - 0x80, Device, 10); + strcat(BootPath, "("); + strcat(BootPath, Device); + strcat(BootPath, ")"); + } + return TRUE; } -BOOLEAN -DiskNormalizeSystemPath(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 || DriveNumber < 0x80) - { - 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; -} - - // This function is in arch/i386/i386disk.c //VOID DiskStopFloppyMotor(VOID) diff --git a/reactos/boot/freeldr/freeldr/disk/partition.c b/reactos/boot/freeldr/freeldr/disk/partition.c index 8966e67187a..b93b2e17b2a 100644 --- a/reactos/boot/freeldr/freeldr/disk/partition.c +++ b/reactos/boot/freeldr/freeldr/disk/partition.c @@ -197,7 +197,6 @@ BOOLEAN DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, BOOLEAN DiskReadBootRecord(ULONG DriveNumber, ULONGLONG LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord) { - char ErrMsg[64]; ULONG Index; // Read master boot record @@ -231,9 +230,6 @@ BOOLEAN DiskReadBootRecord(ULONG DriveNumber, ULONGLONG LogicalSectorNumber, PMA // Check the partition table magic value if (BootRecord->MasterBootRecordMagic != 0xaa55) { - sprintf(ErrMsg, "Invalid partition table magic 0x%x found on drive 0x%lx", - BootRecord->MasterBootRecordMagic, DriveNumber); - DiskError(ErrMsg, 0); return FALSE; } diff --git a/reactos/boot/freeldr/freeldr/include/disk.h b/reactos/boot/freeldr/freeldr/include/disk.h index daaaa495e55..191ee1215d6 100644 --- a/reactos/boot/freeldr/freeldr/include/disk.h +++ b/reactos/boot/freeldr/freeldr/include/disk.h @@ -127,7 +127,6 @@ extern ULONG BootDrive; extern ULONG BootPartition; BOOLEAN DiskGetBootPath(char *BootPath, unsigned Size); -BOOLEAN DiskNormalizeSystemPath(char *SystemPath, unsigned Size); /////////////////////////////////////////////////////////////////////////////////////// diff --git a/reactos/boot/freeldr/freeldr/include/machine.h b/reactos/boot/freeldr/freeldr/include/machine.h index 0c0076f4760..65952056faa 100644 --- a/reactos/boot/freeldr/freeldr/include/machine.h +++ b/reactos/boot/freeldr/freeldr/include/machine.h @@ -62,7 +62,6 @@ typedef struct tagMACHVTBL ULONG (*GetMemoryMap)(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize); BOOLEAN (*DiskGetBootPath)(char *BootPath, unsigned Size); - BOOLEAN (*DiskNormalizeSystemPath)(char *SystemPath, unsigned Size); BOOLEAN (*DiskReadLogicalSectors)(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer); BOOLEAN (*DiskGetDriveGeometry)(ULONG DriveNumber, PGEOMETRY DriveGeometry); ULONG (*DiskGetCacheableBlockCount)(ULONG DriveNumber); diff --git a/reactos/boot/freeldr/freeldr/linuxboot.c b/reactos/boot/freeldr/freeldr/linuxboot.c index 10c2017eb0c..5aea40c2427 100644 --- a/reactos/boot/freeldr/freeldr/linuxboot.c +++ b/reactos/boot/freeldr/freeldr/linuxboot.c @@ -97,13 +97,6 @@ VOID LoadAndBootLinux(PCSTR OperatingSystemName, PCSTR Description) goto LinuxBootFailed; } - // Open the boot volume - if (!MachDiskNormalizeSystemPath(LinuxBootPath, sizeof(LinuxBootPath))) - { - UiMessageBox("Invalid boot path"); - goto LinuxBootFailed; - } - // Open the kernel LinuxKernel = FsOpenFile(LinuxKernelName); if (!LinuxKernel) diff --git a/reactos/boot/freeldr/freeldr/machine.c b/reactos/boot/freeldr/freeldr/machine.c index 9021a7c57a7..c898bf49430 100644 --- a/reactos/boot/freeldr/freeldr/machine.c +++ b/reactos/boot/freeldr/freeldr/machine.c @@ -37,7 +37,6 @@ #undef MachBeep #undef MachPrepareForReactOS #undef MachDiskGetBootPath -#undef MachDiskNormalizeSystemPath #undef MachDiskReadLogicalSectors #undef MachDiskGetDriveGeometry #undef MachDiskGetCacheableBlockCount @@ -152,12 +151,6 @@ MachDiskGetBootPath(char *BootPath, unsigned Size) return MachVtbl.DiskGetBootPath(BootPath, Size); } -BOOLEAN -MachDiskNormalizeSystemPath(char *SystemPath, unsigned Size) -{ - return MachVtbl.DiskNormalizeSystemPath(SystemPath, Size); -} - BOOLEAN MachDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer) { diff --git a/reactos/boot/freeldr/freeldr/reactos/arcname.c b/reactos/boot/freeldr/freeldr/reactos/arcname.c index 3fe1fc6bd26..4b7f97addb6 100644 --- a/reactos/boot/freeldr/freeldr/reactos/arcname.c +++ b/reactos/boot/freeldr/freeldr/reactos/arcname.c @@ -69,7 +69,7 @@ BOOLEAN DissectArcPath(CHAR *ArcPath, CHAR *BootPath, ULONG* BootDrive, ULONG* B * multi(0)disk(0)cdrom(x)\path */ p = p + 6; - *BootDrive = atoi(p); + *BootDrive = atoi(p) + 0x80; p = strchr(p, ')'); if (p == NULL) return FALSE; diff --git a/reactos/boot/freeldr/freeldr/reactos/reactos.c b/reactos/boot/freeldr/freeldr/reactos/reactos.c index 12c8c6647e4..81b654b84b9 100644 --- a/reactos/boot/freeldr/freeldr/reactos/reactos.c +++ b/reactos/boot/freeldr/freeldr/reactos/reactos.c @@ -718,12 +718,6 @@ LoadAndBootReactOS(PCSTR OperatingSystemName) } else { - if (! MachDiskNormalizeSystemPath(SystemPath, - sizeof(SystemPath))) - { - UiMessageBox("Invalid system path"); - return; - } /* copy system path into kernel command line */ strcpy(reactos_kernel_cmdline, SystemPath); }