2005-08-24 18:29:45 +00:00
|
|
|
/*
|
2001-03-07 13:44:41 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
2003-10-11 17:51:56 +00:00
|
|
|
* FILE: drivers/fs/vfat/cleanup.c
|
2001-03-07 13:44:41 +00:00
|
|
|
* PURPOSE: VFAT Filesystem
|
|
|
|
* PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include "vfat.h"
|
|
|
|
|
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
|
|
|
|
static NTSTATUS
|
2003-01-25 15:55:08 +00:00
|
|
|
VfatCleanupFile(PVFAT_IRP_CONTEXT IrpContext)
|
2001-03-07 13:44:41 +00:00
|
|
|
/*
|
|
|
|
* FUNCTION: Cleans up after a file has been closed.
|
|
|
|
*/
|
|
|
|
{
|
2002-08-08 17:54:16 +00:00
|
|
|
PVFATFCB pFcb;
|
2003-01-25 15:55:08 +00:00
|
|
|
PFILE_OBJECT FileObject = IrpContext->FileObject;
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2002-08-08 17:54:16 +00:00
|
|
|
DPRINT("VfatCleanupFile(DeviceExt %x, FileObject %x)\n",
|
2003-10-11 17:51:56 +00:00
|
|
|
IrpContext->DeviceExt, FileObject);
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2002-08-08 17:54:16 +00:00
|
|
|
/* FIXME: handle file/directory deletion here */
|
2003-02-13 22:24:19 +00:00
|
|
|
pFcb = (PVFATFCB) FileObject->FsContext;
|
|
|
|
if (pFcb)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2006-12-30 01:11:14 +00:00
|
|
|
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 == 1)
|
|
|
|
{
|
2005-04-01 18:35:34 +00:00
|
|
|
PFILE_OBJECT tmpFileObject;
|
|
|
|
tmpFileObject = pFcb->FileObject;
|
|
|
|
if (tmpFileObject != NULL)
|
|
|
|
{
|
|
|
|
pFcb->FileObject = NULL;
|
|
|
|
#ifdef USE_ROS_CC_AND_FS
|
|
|
|
CcRosReleaseFileCache(tmpFileObject);
|
|
|
|
#else
|
|
|
|
CcUninitializeCacheMap(tmpFileObject, NULL, NULL);
|
|
|
|
#endif
|
|
|
|
ObDereferenceObject(tmpFileObject);
|
|
|
|
}
|
|
|
|
|
2005-01-25 21:05:38 +00:00
|
|
|
#if 0
|
|
|
|
/* FIXME:
|
|
|
|
* CcPurgeCacheSection is unimplemented.
|
|
|
|
*/
|
|
|
|
CcPurgeCacheSection(FileObject->SectionObjectPointer, NULL, 0, FALSE);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
/* Uninitialize file cache if. */
|
2005-01-12 13:00:43 +00:00
|
|
|
#ifdef USE_ROS_CC_AND_FS
|
2005-01-25 21:05:38 +00:00
|
|
|
CcRosReleaseFileCache (FileObject);
|
2005-01-12 13:00:43 +00:00
|
|
|
#else
|
2006-12-30 01:11:14 +00:00
|
|
|
CcUninitializeCacheMap (FileObject, NULL, NULL);
|
2005-01-12 13:00:43 +00:00
|
|
|
#endif
|
2006-12-30 01:11:14 +00:00
|
|
|
pFcb->OpenHandleCount--;
|
|
|
|
IoRemoveShareAccess(FileObject, &pFcb->FCBShareAccess);
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2001-11-02 22:47:36 +00:00
|
|
|
return STATUS_SUCCESS;
|
2001-03-07 13:44:41 +00:00
|
|
|
}
|
|
|
|
|
2001-11-02 22:47:36 +00:00
|
|
|
NTSTATUS VfatCleanup (PVFAT_IRP_CONTEXT IrpContext)
|
2001-03-07 13:44:41 +00:00
|
|
|
/*
|
|
|
|
* FUNCTION: Cleans up after a file has been closed.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
2003-07-24 19:00:42 +00:00
|
|
|
DPRINT("VfatCleanup(DeviceObject %x, Irp %x)\n", IrpContext->DeviceObject, IrpContext->Irp);
|
2001-03-07 13:44:41 +00:00
|
|
|
|
2003-10-11 17:51:56 +00:00
|
|
|
if (IrpContext->DeviceObject == VfatGlobalData->DeviceObject)
|
|
|
|
{
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
goto ByeBye;
|
|
|
|
}
|
2002-05-15 18:05:00 +00:00
|
|
|
|
2003-07-24 19:00:42 +00:00
|
|
|
if (!ExAcquireResourceExclusiveLite (&IrpContext->DeviceExt->DirResource,
|
|
|
|
(BOOLEAN)(IrpContext->Flags & IRPCONTEXT_CANWAIT)))
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
|
|
|
return VfatQueueRequest (IrpContext);
|
|
|
|
}
|
2001-03-07 13:44:41 +00:00
|
|
|
|
2003-01-25 15:55:08 +00:00
|
|
|
Status = VfatCleanupFile(IrpContext);
|
2001-03-07 13:44:41 +00:00
|
|
|
|
2001-11-02 22:47:36 +00:00
|
|
|
ExReleaseResourceLite (&IrpContext->DeviceExt->DirResource);
|
|
|
|
|
2002-05-15 18:05:00 +00:00
|
|
|
ByeBye:
|
2001-11-02 22:47:36 +00:00
|
|
|
IrpContext->Irp->IoStatus.Status = Status;
|
|
|
|
IrpContext->Irp->IoStatus.Information = 0;
|
|
|
|
|
|
|
|
IoCompleteRequest (IrpContext->Irp, IO_NO_INCREMENT);
|
|
|
|
VfatFreeIrpContext(IrpContext);
|
2001-03-07 13:44:41 +00:00
|
|
|
return (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|