[FREELDR]
authorCameron Gutman <aicommander@gmail.com>
Tue, 27 Apr 2010 22:12:11 +0000 (22:12 +0000)
committerCameron Gutman <aicommander@gmail.com>
Tue, 27 Apr 2010 22:12:11 +0000 (22:12 +0000)
- Set the partition count to 0 for a floppy drive so it can be told apart from a cd-rom drive
- Add a last-chance sector size detection algorithm based on the partition number
- Add the same detection code to the xbox code too (it is essentially the same as what was already there just with more comments)
- Change DiskNormalizeSystemPath so it doesn't try to "normalize" a floppy boot path
- Fixes bug #5233

svn path=/trunk/; revision=47051

reactos/boot/freeldr/freeldr/arch/i386/hardware.c
reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c
reactos/boot/freeldr/freeldr/disk/disk.c
reactos/boot/freeldr/freeldr/reactos/arcname.c

index 1dff167..97577aa 100644 (file)
@@ -452,7 +452,23 @@ static LONG DiskOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
         SectorCount = Geometry.Sectors;
     }
     else
-        return EINVAL;
+    {
+        DPRINTM(DPRINT_HWDETECT, "Using legacy sector size detection\n");
+
+        /* Fall back to legacy detection */
+        if (DrivePartition == 0xff)
+        {
+            /* This is a CD-ROM device */
+            SectorSize = 2048;
+        }
+        else
+        {
+            /* This is either a floppy disk device (DrivePartition == 0) or
+             * a hard disk device (DrivePartition != 0 && DrivePartition != 0xFF) but
+             * it doesn't matter which one because they both have 512 bytes per sector */
+            SectorSize = 512;
+        }
+    }
 
     if (DrivePartition != 0xff && DrivePartition != 0)
     {
index 5c7680b..ff325b3 100644 (file)
@@ -138,7 +138,20 @@ static LONG DiskOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
 
     if (!DissectArcPath(Path, FileName, &DriveNumber, &DrivePartition))
         return EINVAL;
-    SectorSize = (DrivePartition == 0xff ? 2048 : 512);
+
+    if (DrivePartition == 0xff)
+    {
+        /* This is a CD-ROM device */
+        SectorSize = 2048;
+    }
+    else
+    {
+        /* This is either a floppy disk device (DrivePartition == 0) or
+         * a hard disk device (DrivePartition != 0 && DrivePartition != 0xFF) but
+         * it doesn't matter which one because they both have 512 bytes per sector */
+         SectorSize = 512;
+    }
+
     if (DrivePartition != 0xff && DrivePartition != 0)
     {
         if (!XboxDiskGetPartitionEntry(DriveNumber, DrivePartition, &PartitionTableEntry))
index 16ee1be..a5a6510 100644 (file)
@@ -136,7 +136,7 @@ DiskNormalizeSystemPath(char *SystemPath, unsigned Size)
                return FALSE;
        }
     
-       if (0 != PartitionNumber)
+       if (0 != PartitionNumber || DriveNumber < 0x80)
        {
                return TRUE;
        }
index 3ca69fa..3fe1fc6 100644 (file)
@@ -60,7 +60,7 @@ BOOLEAN DissectArcPath(CHAR *ArcPath, CHAR *BootPath, ULONG* BootDrive, ULONG* B
                if (p == NULL)
                        return FALSE;
                p++;
-               *BootPartition = 0xff;
+               *BootPartition = 0;
        }
        else if (_strnicmp(p, "cdrom(", 6) == 0)
        {