Add changes from cc rewrite brunch. The driver still works under the old cc because it makes use of the USE_ROS_CC_AND_FS define.

svn path=/trunk/; revision=25243
This commit is contained in:
Maarten Bosma 2006-12-30 00:37:52 +00:00
parent 8bf9208764
commit f01a075e09
3 changed files with 82 additions and 22 deletions

View file

@ -29,24 +29,50 @@ VfatCleanupFile(PVFAT_IRP_CONTEXT IrpContext)
pFcb = (PVFATFCB) FileObject->FsContext;
if (pFcb)
{
if (!(*pFcb->Attributes & FILE_ATTRIBUTE_DIRECTORY) &&
FsRtlAreThereCurrentFileLocks(&pFcb->FileLock))
{
/* remove all locks this process have on this file */
FsRtlFastUnlockAll(&pFcb->FileLock,
FileObject,
IoGetRequestorProcess(IrpContext->Irp),
NULL);
}
if (pFcb->Flags & FCB_IS_VOLUME)
{
pFcb->OpenHandleCount--;
if (pFcb->Flags & FCB_IS_DIRTY)
{
VfatUpdateEntry (pFcb);
}
if (pFcb->OpenHandleCount != 0)
{
IoRemoveShareAccess(FileObject, &pFcb->FCBShareAccess);
}
}
else
{
if(!ExAcquireResourceExclusiveLite (&pFcb->MainResource,
(BOOLEAN)(IrpContext->Flags & IRPCONTEXT_CANWAIT)))
{
return STATUS_PENDING;
}
if(!ExAcquireResourceExclusiveLite (&pFcb->PagingIoResource,
(BOOLEAN)(IrpContext->Flags & IRPCONTEXT_CANWAIT)))
{
ExReleaseResourceLite (&pFcb->MainResource);
return STATUS_PENDING;
}
pFcb->OpenHandleCount--;
if (pFcb->Flags & FCB_DELETE_PENDING &&
pFcb->OpenHandleCount == 1)
{
if (!(*pFcb->Attributes & FILE_ATTRIBUTE_DIRECTORY) &&
FsRtlAreThereCurrentFileLocks(&pFcb->FileLock))
{
/* remove all locks this process have on this file */
FsRtlFastUnlockAll(&pFcb->FileLock,
FileObject,
IoGetRequestorProcess(IrpContext->Irp),
NULL);
}
if (pFcb->Flags & FCB_IS_DIRTY)
{
VfatUpdateEntry (pFcb);
}
if (pFcb->Flags & FCB_DELETE_PENDING &&
pFcb->OpenHandleCount == 0)
{
DPRINT("'%wZ'\n", &pFcb->PathNameU);
PFILE_OBJECT tmpFileObject;
tmpFileObject = pFcb->FileObject;
if (tmpFileObject != NULL)
@ -71,10 +97,21 @@ VfatCleanupFile(PVFAT_IRP_CONTEXT IrpContext)
#ifdef USE_ROS_CC_AND_FS
CcRosReleaseFileCache (FileObject);
#else
CcUninitializeCacheMap (FileObject, NULL, NULL);
if (FileObject->SectionObjectPointer->SharedCacheMap)
{
CcUninitializeCacheMap (FileObject, &pFcb->RFCB.FileSize, NULL);
}
#endif
pFcb->OpenHandleCount--;
IoRemoveShareAccess(FileObject, &pFcb->FCBShareAccess);
if (pFcb->OpenHandleCount != 0)
{
IoRemoveShareAccess(FileObject, &pFcb->FCBShareAccess);
}
FileObject->Flags |= FO_CLEANUP_COMPLETE;
ExReleaseResourceLite (&pFcb->PagingIoResource);
ExReleaseResourceLite (&pFcb->MainResource);
}
}
return STATUS_SUCCESS;
}
@ -104,6 +141,11 @@ NTSTATUS VfatCleanup (PVFAT_IRP_CONTEXT IrpContext)
ExReleaseResourceLite (&IrpContext->DeviceExt->DirResource);
if (Status == STATUS_PENDING)
{
return VfatQueueRequest(IrpContext);
}
ByeBye:
IrpContext->Irp->IoStatus.Status = Status;
IrpContext->Irp->IoStatus.Information = 0;

View file

@ -30,6 +30,8 @@ VfatCloseFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
pCcb = (PVFATCCB) (FileObject->FsContext2);
pFcb = (PVFATFCB) (FileObject->FsContext);
FileObject->FsContext2 = NULL;
if (pFcb == NULL)
{
return STATUS_SUCCESS;
@ -43,7 +45,7 @@ VfatCloseFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
}
else
{
if (FileObject->DeletePending)
// if (FileObject->DeletePending)
{
if (pFcb->Flags & FCB_DELETE_PENDING)
{
@ -57,7 +59,6 @@ VfatCloseFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
vfatReleaseFCB (DeviceExt, pFcb);
}
FileObject->FsContext2 = NULL;
FileObject->FsContext = NULL;
FileObject->SectionObjectPointer = NULL;

View file

@ -656,7 +656,24 @@ VfatCreateFile ( PDEVICE_OBJECT DeviceObject, PIRP Irp )
VfatCloseFile (DeviceExt, FileObject);
return(STATUS_NOT_A_DIRECTORY);
}
#ifndef USE_ROS_CC_AND_FS
if (!(*pFcb->Attributes & FILE_ATTRIBUTE_DIRECTORY))
{
if (Stack->Parameters.Create.SecurityContext->DesiredAccess & FILE_WRITE_DATA ||
RequestedDisposition == FILE_OVERWRITE ||
RequestedDisposition == FILE_OVERWRITE_IF)
{
if (!MmFlushImageSection(&pFcb->SectionObjectPointers, MmFlushForWrite))
{
DPRINT1("%wZ\n", &pFcb->PathNameU);
DPRINT1("%d %d %d\n", Stack->Parameters.Create.SecurityContext->DesiredAccess & FILE_WRITE_DATA,
RequestedDisposition == FILE_OVERWRITE, RequestedDisposition == FILE_OVERWRITE_IF);
VfatCloseFile (DeviceExt, FileObject);
return STATUS_SHARING_VIOLATION;
}
}
}
#endif
if (PagingFileCreate)
{
/* FIXME: