/* FUNCTIONS ****************************************************************/
static NTSTATUS
-VfatCleanupFile(PDEVICE_EXTENSION DeviceExt,
- PFILE_OBJECT FileObject)
+VfatCleanupFile(PVFAT_IRP_CONTEXT IrpContext)
/*
* FUNCTION: Cleans up after a file has been closed.
*/
{
PVFATCCB pCcb;
PVFATFCB pFcb;
+ PDEVICE_EXTENSION DeviceExt = IrpContext->DeviceExt;
+ PFILE_OBJECT FileObject = IrpContext->FileObject;
DPRINT("VfatCleanupFile(DeviceExt %x, FileObject %x)\n",
DeviceExt, FileObject);
}
pFcb = pCcb->pFcb;
- if (FileObject->FileName.Buffer)
+ if (!(pFcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY) &&
+ FsRtlAreThereCurrentFileLocks(&pFcb->FileLock))
+ {
+ /* remove all locks this process have on this file */
+ FsRtlFastUnlockAll(&pFcb->FileLock,
+ FileObject,
+ IoGetRequestorProcess(IrpContext->Irp),
+ NULL
+ );
+ }
+
+ /* Uninitialize file cache if initialized for this file object. */
+ if (pFcb->RFCB.Bcb != NULL)
{
- if (pFcb->Flags & FCB_UPDATE_DIRENTRY)
- {
- VfatUpdateEntry (DeviceExt, FileObject);
- pFcb->Flags &= ~FCB_UPDATE_DIRENTRY;
- }
+ CcRosReleaseFileCache (FileObject, pFcb->RFCB.Bcb);
}
-
- /* Uninitialize the file cache. */
- CcRosReleaseFileCache (FileObject, pFcb->RFCB.Bcb);
return STATUS_SUCCESS;
}
return VfatQueueRequest (IrpContext);
}
- Status = VfatCleanupFile(IrpContext->DeviceExt, IrpContext->FileObject);
+ Status = VfatCleanupFile(IrpContext);
ExReleaseResourceLite (&IrpContext->DeviceExt->DirResource);