From 3874d4ff4e65bea3cece017935e66508f13ea89f Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 16 Feb 2010 20:32:58 +0000 Subject: [PATCH 1/1] - Fix incorrect sector size detection which caused seeking to fail when booting from a floppy - FreeLoader can load from a floppy disk now svn path=/trunk/; revision=45602 --- .../boot/freeldr/freeldr/arch/i386/hardware.c | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/arch/i386/hardware.c b/reactos/boot/freeldr/freeldr/arch/i386/hardware.c index 6b3d7a4dcc4..d4654ccd138 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/hardware.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/hardware.c @@ -433,11 +433,27 @@ static LONG DiskOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId) ULONGLONG SectorOffset = 0; ULONGLONG SectorCount = 0; PARTITION_TABLE_ENTRY PartitionTableEntry; + GEOMETRY Geometry; + EXTENDED_GEOMETRY ExtGeometry; CHAR FileName[1]; if (!DissectArcPath(Path, FileName, &DriveNumber, &DrivePartition)) return EINVAL; - SectorSize = (DrivePartition == 0xff ? 2048 : 512); + + ExtGeometry.Size = sizeof(EXTENDED_GEOMETRY); + if (DiskGetExtendedDriveParameters(DriveNumber, &ExtGeometry, ExtGeometry.Size)) + { + SectorSize = ExtGeometry.BytesPerSector; + SectorCount = ExtGeometry.Sectors; + } + else if (MachDiskGetDriveGeometry(DriveNumber, &Geometry)) + { + SectorSize = Geometry.BytesPerSector; + SectorCount = Geometry.Sectors; + } + else + return EINVAL; + if (DrivePartition != 0xff && DrivePartition != 0) { if (!DiskGetPartitionEntry(DriveNumber, DrivePartition, &PartitionTableEntry)) @@ -445,10 +461,6 @@ static LONG DiskOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId) SectorOffset = PartitionTableEntry.SectorCountBeforePartition; SectorCount = PartitionTableEntry.PartitionSectorCount; } - else - { - SectorCount = 0; /* FIXME */ - } Context = MmHeapAlloc(sizeof(DISKCONTEXT)); if (!Context) -- 2.17.1