mirror of
https://github.com/reactos/reactos.git
synced 2024-10-08 10:24:06 +00:00
[freeldr] Accept to read blocks whose size is not a multiple of device sector size
svn path=/trunk/; revision=43113
This commit is contained in:
parent
f03906b449
commit
16c6a54da7
|
@ -2,6 +2,7 @@
|
||||||
* FreeLoader
|
* FreeLoader
|
||||||
*
|
*
|
||||||
* Copyright (C) 2003, 2004 Eric Kohl
|
* Copyright (C) 2003, 2004 Eric Kohl
|
||||||
|
* Copyright (C) 2009 Hervé Poussineau
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -466,15 +467,16 @@ static LONG DiskRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count)
|
||||||
{
|
{
|
||||||
DISKCONTEXT* Context = FsGetDeviceSpecific(FileId);
|
DISKCONTEXT* Context = FsGetDeviceSpecific(FileId);
|
||||||
UCHAR* Ptr = (UCHAR*)Buffer;
|
UCHAR* Ptr = (UCHAR*)Buffer;
|
||||||
ULONG i;
|
ULONG i, Length;
|
||||||
BOOLEAN ret;
|
BOOLEAN ret;
|
||||||
|
|
||||||
*Count = 0;
|
*Count = 0;
|
||||||
if (N & (Context->SectorSize - 1))
|
i = 0;
|
||||||
return EINVAL;
|
while (N > 0)
|
||||||
|
|
||||||
for (i = 0; i < N / Context->SectorSize; i++)
|
|
||||||
{
|
{
|
||||||
|
Length = N;
|
||||||
|
if (Length > Context->SectorSize)
|
||||||
|
Length = Context->SectorSize;
|
||||||
ret = MachDiskReadLogicalSectors(
|
ret = MachDiskReadLogicalSectors(
|
||||||
Context->DriveNumber,
|
Context->DriveNumber,
|
||||||
Context->SectorNumber + Context->SectorOffset + i,
|
Context->SectorNumber + Context->SectorOffset + i,
|
||||||
|
@ -482,11 +484,13 @@ static LONG DiskRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count)
|
||||||
(PVOID)DISKREADBUFFER);
|
(PVOID)DISKREADBUFFER);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return EIO;
|
return EIO;
|
||||||
RtlCopyMemory(Ptr, (PVOID)DISKREADBUFFER, Context->SectorSize);
|
RtlCopyMemory(Ptr, (PVOID)DISKREADBUFFER, Length);
|
||||||
Ptr += Context->SectorSize;
|
Ptr += Length;
|
||||||
|
*Count += Length;
|
||||||
|
N -= Length;
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
*Count = N;
|
|
||||||
return ESUCCESS;
|
return ESUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue