mirror of
https://github.com/reactos/reactos.git
synced 2025-05-21 01:54:21 +00:00
[FREELDR]
Finally commit the patch to improve freeldr disk performance by Carlo Bramini. Obviously someone wants to read 0 bytes and that should not fail. svn path=/trunk/; revision=57283
This commit is contained in:
parent
f9201cb0dd
commit
a466b50b71
1 changed files with 27 additions and 13 deletions
|
@ -114,31 +114,45 @@ 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, Length;
|
ULONG Length, TotalSectors, MaxSectors, ReadSectors;
|
||||||
BOOLEAN ret;
|
BOOLEAN ret;
|
||||||
|
ULONGLONG SectorOffset;
|
||||||
|
|
||||||
*Count = 0;
|
TotalSectors = (N + Context->SectorSize - 1) / Context->SectorSize;
|
||||||
i = 0;
|
MaxSectors = DISKREADBUFFER_SIZE / Context->SectorSize;
|
||||||
while (N > 0)
|
SectorOffset = Context->SectorNumber + Context->SectorOffset;
|
||||||
|
|
||||||
|
ret = 1;
|
||||||
|
|
||||||
|
while (TotalSectors)
|
||||||
{
|
{
|
||||||
Length = N;
|
ReadSectors = TotalSectors;
|
||||||
if (Length > Context->SectorSize)
|
if (ReadSectors > MaxSectors)
|
||||||
Length = Context->SectorSize;
|
ReadSectors = MaxSectors;
|
||||||
|
|
||||||
ret = MachDiskReadLogicalSectors(
|
ret = MachDiskReadLogicalSectors(
|
||||||
Context->DriveNumber,
|
Context->DriveNumber,
|
||||||
Context->SectorNumber + Context->SectorOffset + i,
|
SectorOffset,
|
||||||
1,
|
ReadSectors,
|
||||||
(PVOID)DISKREADBUFFER);
|
(PVOID)DISKREADBUFFER);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return EIO;
|
break;
|
||||||
|
|
||||||
|
Length = ReadSectors * Context->SectorSize;
|
||||||
|
if (Length > N)
|
||||||
|
Length = N;
|
||||||
|
|
||||||
RtlCopyMemory(Ptr, (PVOID)DISKREADBUFFER, Length);
|
RtlCopyMemory(Ptr, (PVOID)DISKREADBUFFER, Length);
|
||||||
|
|
||||||
Ptr += Length;
|
Ptr += Length;
|
||||||
*Count += Length;
|
|
||||||
N -= Length;
|
N -= Length;
|
||||||
i++;
|
SectorOffset += ReadSectors;
|
||||||
|
TotalSectors -= ReadSectors;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ESUCCESS;
|
*Count = Ptr - (UCHAR *)Buffer;
|
||||||
|
|
||||||
|
return (!ret) ? EIO : ESUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LONG DiskSeek(ULONG FileId, LARGE_INTEGER* Position, SEEKMODE SeekMode)
|
static LONG DiskSeek(ULONG FileId, LARGE_INTEGER* Position, SEEKMODE SeekMode)
|
||||||
|
|
Loading…
Reference in a new issue