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.
29 PDEVICE_EXTENSION DeviceExt = IrpContext->DeviceExt;
30 PFILE_OBJECT FileObject = IrpContext->FileObject;
32 DPRINT("VfatCleanupFile(DeviceExt %x, FileObject %x)\n",
33 DeviceExt, FileObject);
35 /* FIXME: handle file/directory deletion here */
36 pCcb = (PVFATCCB) (FileObject->FsContext2);
39 return STATUS_SUCCESS;
43 if (!(pFcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY) &&
44 FsRtlAreThereCurrentFileLocks(&pFcb->FileLock))
46 /* remove all locks this process have on this file */
47 FsRtlFastUnlockAll(&pFcb->FileLock,
49 IoGetRequestorProcess(IrpContext->Irp),
54 /* Uninitialize file cache if initialized for this file object. */
55 if (pFcb->RFCB.Bcb != NULL)
57 CcRosReleaseFileCache (FileObject, pFcb->RFCB.Bcb);
60 return STATUS_SUCCESS;
63 NTSTATUS VfatCleanup (PVFAT_IRP_CONTEXT IrpContext)
65 * FUNCTION: Cleans up after a file has been closed.
70 DPRINT("VfatCleanup(DeviceObject %x, Irp %x)\n", DeviceObject, Irp);
72 if (IrpContext->DeviceObject == VfatGlobalData->DeviceObject)
74 Status = STATUS_SUCCESS;
78 if (!ExAcquireResourceExclusiveLite (&IrpContext->DeviceExt->DirResource, IrpContext->Flags & IRPCONTEXT_CANWAIT))
80 return VfatQueueRequest (IrpContext);
83 Status = VfatCleanupFile(IrpContext);
85 ExReleaseResourceLite (&IrpContext->DeviceExt->DirResource);
88 IrpContext->Irp->IoStatus.Status = Status;
89 IrpContext->Irp->IoStatus.Information = 0;
91 IoCompleteRequest (IrpContext->Irp, IO_NO_INCREMENT);
92 VfatFreeIrpContext(IrpContext);