/* Complete leftovers from previous iteration, if needed */
if (dwIntermediatIndex < FL_SECTOR_SIZE)
{
copyBytes(realBuf, &intermediateBuf[dwIntermediatIndex], dwBytesToUse);
dwIntermediatIndex += dwBytesToUse;
if (dwIntermediatIndex < FL_SECTOR_SIZE)
{
/* The buffer was smamller then sector, advance to next buffer */
continue;
}
/* Intermediate sector reading is complete */
dwSectorsUsed++;
ReleaseMutex (pDisk->globalMutex);
}
/* Read continuous sectors if possible */
if (dwNumOfSect)
{
status = ReadSectors(pDisk, ptrSG, &realBuf[dwBytesToUse],
ptrSG->sr_start+dwSectorsUsed, dwNumOfSect, pBytesReturned);
if (status==flReadFault)
return ptrSG->sr_status;
}
/* Read from sector to a non-complete S/G buffer if needed */
if (dwLeftOverBytes)
{
/* Start using Intermediate buffer, lock */
WaitForSingleObject(pDisk->globalMutex,INFINITE);
status = ReadSectors(pDisk, ptrSG, intermediateBuf,
ptrSG->sr_start+dwNumOfSect+dwSectorsUsed, 1, pBytesReturned);
if (status==flReadFault)
{
ReleaseMutex (pDisk->globalMutex);
return ptrSG->sr_status;
}