3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: services/fs/vfat/cleanup.c
6 * PURPOSE: VFAT Filesystem
7 * PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
10 /* INCLUDES *****************************************************************/
12 #include <ddk/ntddk.h>
19 /* FUNCTIONS ****************************************************************/
22 VfatCleanupFile(PVFAT_IRP_CONTEXT IrpContext)
24 * FUNCTION: Cleans up after a file has been closed.
28 PDEVICE_EXTENSION DeviceExt = IrpContext->DeviceExt;
29 PFILE_OBJECT FileObject = IrpContext->FileObject;
31 DPRINT("VfatCleanupFile(DeviceExt %x, FileObject %x)\n",
32 DeviceExt, FileObject);
34 /* FIXME: handle file/directory deletion here */
35 pFcb = (PVFATFCB) FileObject->FsContext;
38 if (!(pFcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY) &&
39 FsRtlAreThereCurrentFileLocks(&pFcb->FileLock))
41 /* remove all locks this process have on this file */
42 FsRtlFastUnlockAll(&pFcb->FileLock,
44 IoGetRequestorProcess(IrpContext->Irp),
48 /* Uninitialize file cache if initialized for this file object. */
49 if (FileObject->PrivateCacheMap)
51 CcRosReleaseFileCache (FileObject);
54 return STATUS_SUCCESS;
57 NTSTATUS VfatCleanup (PVFAT_IRP_CONTEXT IrpContext)
59 * FUNCTION: Cleans up after a file has been closed.
64 DPRINT("VfatCleanup(DeviceObject %x, Irp %x)\n", DeviceObject, Irp);
66 if (IrpContext->DeviceObject == VfatGlobalData->DeviceObject)
68 Status = STATUS_SUCCESS;
72 if (!ExAcquireResourceExclusiveLite (&IrpContext->DeviceExt->DirResource, IrpContext->Flags & IRPCONTEXT_CANWAIT))
74 return VfatQueueRequest (IrpContext);
77 Status = VfatCleanupFile(IrpContext);
79 ExReleaseResourceLite (&IrpContext->DeviceExt->DirResource);
82 IrpContext->Irp->IoStatus.Status = Status;
83 IrpContext->Irp->IoStatus.Information = 0;
85 IoCompleteRequest (IrpContext->Irp, IO_NO_INCREMENT);
86 VfatFreeIrpContext(IrpContext);