--- trunk/reactos/drivers/fs/vfat/direntry.c 2005-01-25 21:13:28 UTC (rev 13283)
+++ trunk/reactos/drivers/fs/vfat/direntry.c 2005-01-25 21:14:57 UTC (rev 13284)
@@ -175,7 +175,8 @@
{
CcUnpinData(*pContext);
}
- if (!CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
+ if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart ||
+ !CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
{
*pContext = NULL;
return STATUS_NO_MORE_ENTRIES;
@@ -204,7 +205,8 @@
{
CcUnpinData(*pContext);
FileOffset.u.LowPart -= PAGE_SIZE;
- if (!CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
+ if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart ||
+ !CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
{
CHECKPOINT;
*pContext = NULL;
@@ -228,7 +230,8 @@
{
CcUnpinData(*pContext);
FileOffset.u.LowPart += PAGE_SIZE;
- if (!CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
+ if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart ||
+ !CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
{
CHECKPOINT;
*pContext = NULL;
@@ -325,7 +328,8 @@
{
CcUnpinData(*pContext);
FileOffset.u.LowPart += PAGE_SIZE;
- if (!CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
+ if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart ||
+ !CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
{
CHECKPOINT;
*pContext = NULL;
@@ -361,7 +365,6 @@
ULONG DirIndex = DirContext->DirIndex;
FileOffset.u.HighPart = 0;
- FileOffset.u.LowPart = ROUND_DOWN(DirContext->DirIndex * sizeof(FATX_DIR_ENTRY), PAGE_SIZE);
if (!vfatFCBIsRoot(pDirFcb))
{
@@ -403,7 +406,9 @@
{
CcUnpinData(*pContext);
}
- if (!CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
+ FileOffset.u.LowPart = ROUND_DOWN(DirIndex * sizeof(FATX_DIR_ENTRY), PAGE_SIZE);
+ if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart ||
+ !CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
{
*pContext = NULL;
return STATUS_NO_MORE_ENTRIES;
@@ -412,33 +417,35 @@
fatxDirEntry = (PFATX_DIR_ENTRY)(*pPage) + DirIndex % FATX_ENTRIES_PER_PAGE;
- DirContext->StartIndex = DirIndex;
+ DirContext->StartIndex = DirContext->DirIndex;
while (TRUE)
{
- if (FATX_ENTRY_END(fatxDirEntry))
- {
- CcUnpinData(*pContext);
- *pContext = NULL;
- return STATUS_NO_MORE_ENTRIES;
- }
+ if (FATX_ENTRY_END(fatxDirEntry))
+ {
+ CcUnpinData(*pContext);
+ *pContext = NULL;
+ return STATUS_NO_MORE_ENTRIES;
+ }
- if (!FATX_ENTRY_DELETED(fatxDirEntry))
- {
- RtlCopyMemory(&DirContext->DirEntry.FatX, fatxDirEntry, sizeof(FATX_DIR_ENTRY));
- break;
+ if (!FATX_ENTRY_DELETED(fatxDirEntry))
+ {
+ RtlCopyMemory(&DirContext->DirEntry.FatX, fatxDirEntry, sizeof(FATX_DIR_ENTRY));
+ break;
}
- DirContext->DirIndex++;
- DirContext->StartIndex++;
- if ((DirContext->DirIndex % FATX_ENTRIES_PER_PAGE) == 0)
+ DirContext->DirIndex++;
+ DirContext->StartIndex++;
+ DirIndex++;
+ if ((DirIndex % FATX_ENTRIES_PER_PAGE) == 0)
{
CcUnpinData(*pContext);
FileOffset.u.LowPart += PAGE_SIZE;
- if (!CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
+ if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart ||
+ !CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage))
{
CHECKPOINT;
- *pContext = NULL;
- return STATUS_NO_MORE_ENTRIES;
+ *pContext = NULL;
+ return STATUS_NO_MORE_ENTRIES;
}
fatxDirEntry = (PFATX_DIR_ENTRY)*pPage;
}