2003-07-24 20:52:58 +00:00
|
|
|
/* $Id: cleanup.c,v 1.13 2003/07/24 20:52:58 chorns Exp $
|
2001-03-07 13:44:41 +00:00
|
|
|
*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* FILE: services/fs/vfat/cleanup.c
|
|
|
|
* PURPOSE: VFAT Filesystem
|
|
|
|
* PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
|
|
|
#include <ddk/ntddk.h>
|
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
#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
|
|
|
PDEVICE_EXTENSION DeviceExt = IrpContext->DeviceExt;
|
|
|
|
PFILE_OBJECT FileObject = IrpContext->FileObject;
|
2002-08-08 17:54:16 +00:00
|
|
|
|
|
|
|
DPRINT("VfatCleanupFile(DeviceExt %x, FileObject %x)\n",
|
2001-11-02 22:47:36 +00:00
|
|
|
DeviceExt, FileObject);
|
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-01-25 15:55:08 +00:00
|
|
|
{
|
2003-02-13 22:24:19 +00:00
|
|
|
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 (FileObject->PrivateCacheMap)
|
|
|
|
{
|
|
|
|
CcRosReleaseFileCache (FileObject);
|
|
|
|
}
|
2003-01-25 15:55:08 +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
|
|
|
|
2002-05-15 18:05:00 +00:00
|
|
|
if (IrpContext->DeviceObject == VfatGlobalData->DeviceObject)
|
|
|
|
{
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
goto ByeBye;
|
|
|
|
}
|
|
|
|
|
2003-07-24 19:00:42 +00:00
|
|
|
if (!ExAcquireResourceExclusiveLite (&IrpContext->DeviceExt->DirResource,
|
|
|
|
(BOOLEAN)(IrpContext->Flags & IRPCONTEXT_CANWAIT)))
|
2001-11-02 22:47:36 +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 */
|