Author: hpoussin
Date: Tue Sep 22 21:32:35 2009
New Revision: 43113
URL:
http://svn.reactos.org/svn/reactos?rev=43113&view=rev
Log:
[freeldr] Accept to read blocks whose size is not a multiple of device sector size
Modified:
trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c [iso-8859-1] Tue Sep 22
21:32:35 2009
@@ -2,6 +2,7 @@
* FreeLoader
*
* Copyright (C) 2003, 2004 Eric Kohl
+ * Copyright (C) 2009 Hervé Poussineau
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -466,15 +467,16 @@
{
DISKCONTEXT* Context = FsGetDeviceSpecific(FileId);
UCHAR* Ptr = (UCHAR*)Buffer;
- ULONG i;
+ ULONG i, Length;
BOOLEAN ret;
*Count = 0;
- if (N & (Context->SectorSize - 1))
- return EINVAL;
-
- for (i = 0; i < N / Context->SectorSize; i++)
- {
+ i = 0;
+ while (N > 0)
+ {
+ Length = N;
+ if (Length > Context->SectorSize)
+ Length = Context->SectorSize;
ret = MachDiskReadLogicalSectors(
Context->DriveNumber,
Context->SectorNumber + Context->SectorOffset + i,
@@ -482,11 +484,13 @@
(PVOID)DISKREADBUFFER);
if (!ret)
return EIO;
- RtlCopyMemory(Ptr, (PVOID)DISKREADBUFFER, Context->SectorSize);
- Ptr += Context->SectorSize;
- }
-
- *Count = N;
+ RtlCopyMemory(Ptr, (PVOID)DISKREADBUFFER, Length);
+ Ptr += Length;
+ *Count += Length;
+ N -= Length;
+ i++;
+ }
+
return ESUCCESS;
}