mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[FASTFAT]
- Properly handle errors in CcInitializeCacheMap, CcCopyRead and CcCopyWrite CORE-8410 svn path=/trunk/; revision=63928
This commit is contained in:
parent
2e0d75e093
commit
b82e2bf972
5 changed files with 90 additions and 39 deletions
|
@ -26,6 +26,7 @@ list(APPEND SOURCE
|
|||
add_library(fastfat SHARED ${SOURCE} vfatfs.rc)
|
||||
|
||||
set_module_type(fastfat kernelmodedriver)
|
||||
target_link_libraries(fastfat ${PSEH_LIB})
|
||||
add_importlibs(fastfat ntoskrnl hal)
|
||||
|
||||
add_pch(fastfat vfat.h SOURCE)
|
||||
|
|
|
@ -340,12 +340,14 @@ vfatFCBInitializeCacheFromVolume(
|
|||
{
|
||||
PFILE_OBJECT fileObject;
|
||||
PVFATCCB newCCB;
|
||||
NTSTATUS status;
|
||||
|
||||
fileObject = IoCreateStreamFileObject (NULL, vcb->StorageDevice);
|
||||
|
||||
newCCB = ExAllocateFromNPagedLookasideList(&VfatGlobalData->CcbLookasideList);
|
||||
if (newCCB == NULL)
|
||||
{
|
||||
ObDereferenceObject(fileObject);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
RtlZeroMemory(newCCB, sizeof (VFATCCB));
|
||||
|
@ -356,11 +358,24 @@ vfatFCBInitializeCacheFromVolume(
|
|||
fcb->FileObject = fileObject;
|
||||
fcb->RefCount++;
|
||||
|
||||
CcInitializeCacheMap(fileObject,
|
||||
(PCC_FILE_SIZES)(&fcb->RFCB.AllocationSize),
|
||||
TRUE,
|
||||
&VfatGlobalData->CacheMgrCallbacks,
|
||||
fcb);
|
||||
_SEH2_TRY
|
||||
{
|
||||
CcInitializeCacheMap(fileObject,
|
||||
(PCC_FILE_SIZES)(&fcb->RFCB.AllocationSize),
|
||||
TRUE,
|
||||
&VfatGlobalData->CacheMgrCallbacks,
|
||||
fcb);
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
status = _SEH2_GetExceptionCode();
|
||||
fcb->RefCount--;
|
||||
fcb->FileObject = NULL;
|
||||
ExFreeToNPagedLookasideList(&VfatGlobalData->CcbLookasideList, newCCB);
|
||||
ObDereferenceObject(fileObject);
|
||||
return status;
|
||||
}
|
||||
_SEH2_END;
|
||||
|
||||
fcb->Flags |= FCB_CACHE_INITIALIZED;
|
||||
return STATUS_SUCCESS;
|
||||
|
|
|
@ -550,11 +550,20 @@ VfatMount(
|
|||
Fcb->RFCB.ValidDataLength = Fcb->RFCB.FileSize;
|
||||
Fcb->RFCB.AllocationSize = Fcb->RFCB.FileSize;
|
||||
|
||||
CcInitializeCacheMap(DeviceExt->FATFileObject,
|
||||
(PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
|
||||
TRUE,
|
||||
&VfatGlobalData->CacheMgrCallbacks,
|
||||
Fcb);
|
||||
_SEH2_TRY
|
||||
{
|
||||
CcInitializeCacheMap(DeviceExt->FATFileObject,
|
||||
(PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
|
||||
TRUE,
|
||||
&VfatGlobalData->CacheMgrCallbacks,
|
||||
Fcb);
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
goto ByeBye;
|
||||
}
|
||||
_SEH2_END;
|
||||
|
||||
DeviceExt->LastAvailableCluster = 2;
|
||||
ExInitializeResourceLite(&DeviceExt->FatResource);
|
||||
|
|
|
@ -673,22 +673,35 @@ VfatRead(
|
|||
Status = /*STATUS_END_OF_FILE*/STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (IrpContext->FileObject->PrivateCacheMap == NULL)
|
||||
_SEH2_TRY
|
||||
{
|
||||
CcInitializeCacheMap(IrpContext->FileObject,
|
||||
(PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
|
||||
FALSE,
|
||||
&(VfatGlobalData->CacheMgrCallbacks),
|
||||
Fcb);
|
||||
}
|
||||
if (IrpContext->FileObject->PrivateCacheMap == NULL)
|
||||
{
|
||||
CcInitializeCacheMap(IrpContext->FileObject,
|
||||
(PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
|
||||
FALSE,
|
||||
&(VfatGlobalData->CacheMgrCallbacks),
|
||||
Fcb);
|
||||
}
|
||||
|
||||
if (!CcCopyRead(IrpContext->FileObject, &ByteOffset, Length,
|
||||
(BOOLEAN)(IrpContext->Flags & IRPCONTEXT_CANWAIT), Buffer,
|
||||
&IrpContext->Irp->IoStatus))
|
||||
if (!CcCopyRead(IrpContext->FileObject,
|
||||
&ByteOffset,
|
||||
Length,
|
||||
(IrpContext->Flags & IRPCONTEXT_CANWAIT) != 0,
|
||||
Buffer,
|
||||
&IrpContext->Irp->IoStatus))
|
||||
{
|
||||
ASSERT((IrpContext->Flags & IRPCONTEXT_CANWAIT) == 0);
|
||||
Status = STATUS_PENDING;
|
||||
goto ByeBye;
|
||||
}
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
Status = STATUS_PENDING;
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
goto ByeBye;
|
||||
}
|
||||
_SEH2_END;
|
||||
|
||||
if (!NT_SUCCESS(IrpContext->Irp->IoStatus.Status))
|
||||
{
|
||||
|
@ -947,30 +960,42 @@ VfatWrite(
|
|||
{
|
||||
// cached write
|
||||
|
||||
if (IrpContext->FileObject->PrivateCacheMap == NULL)
|
||||
_SEH2_TRY
|
||||
{
|
||||
CcInitializeCacheMap(IrpContext->FileObject,
|
||||
(PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
|
||||
FALSE,
|
||||
&VfatGlobalData->CacheMgrCallbacks,
|
||||
Fcb);
|
||||
}
|
||||
if (IrpContext->FileObject->PrivateCacheMap == NULL)
|
||||
{
|
||||
CcInitializeCacheMap(IrpContext->FileObject,
|
||||
(PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize),
|
||||
FALSE,
|
||||
&VfatGlobalData->CacheMgrCallbacks,
|
||||
Fcb);
|
||||
}
|
||||
|
||||
if (ByteOffset.QuadPart > OldFileSize.QuadPart)
|
||||
{
|
||||
CcZeroData(IrpContext->FileObject, &OldFileSize, &ByteOffset, TRUE);
|
||||
}
|
||||
if (ByteOffset.QuadPart > OldFileSize.QuadPart)
|
||||
{
|
||||
CcZeroData(IrpContext->FileObject, &OldFileSize, &ByteOffset, TRUE);
|
||||
}
|
||||
|
||||
if (CcCopyWrite(IrpContext->FileObject, &ByteOffset, Length,
|
||||
1 /*IrpContext->Flags & IRPCONTEXT_CANWAIT*/, Buffer))
|
||||
{
|
||||
IrpContext->Irp->IoStatus.Information = Length;
|
||||
Status = STATUS_SUCCESS;
|
||||
if (CcCopyWrite(IrpContext->FileObject,
|
||||
&ByteOffset,
|
||||
Length,
|
||||
TRUE /*(IrpContext->Flags & IRPCONTEXT_CANWAIT) != 0*/,
|
||||
Buffer))
|
||||
{
|
||||
IrpContext->Irp->IoStatus.Information = Length;
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(FALSE /*(IrpContext->Flags & IRPCONTEXT_CANWAIT) == 0*/);
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
}
|
||||
else
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
}
|
||||
_SEH2_END;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <ntifs.h>
|
||||
#include <ntdddisk.h>
|
||||
#include <dos.h>
|
||||
#include <pseh/pseh2.h>
|
||||
|
||||
#define USE_ROS_CC_AND_FS
|
||||
|
||||
|
|
Loading…
Reference in a new issue