1 /* $Id: cleanup.c,v 1.14 2003/10/11 17:51:56 hbirr Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: drivers/fs/vfat/cleanup.c
6 * PURPOSE: VFAT Filesystem
7 * PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
11 /* INCLUDES *****************************************************************/
13 #include <ddk/ntddk.h>
20 /* FUNCTIONS ****************************************************************/
23 VfatCleanupFile(PVFAT_IRP_CONTEXT IrpContext
)
25 * FUNCTION: Cleans up after a file has been closed.
29 PFILE_OBJECT FileObject
= IrpContext
->FileObject
;
31 DPRINT("VfatCleanupFile(DeviceExt %x, FileObject %x)\n",
32 IrpContext
->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 if (pFcb
->Flags
& FCB_IS_DIRTY
)
50 VfatUpdateEntry (pFcb
);
53 /* Uninitialize file cache if initialized for this file object. */
54 if (FileObject
->PrivateCacheMap
)
56 CcRosReleaseFileCache (FileObject
);
59 return STATUS_SUCCESS
;
62 NTSTATUS
VfatCleanup (PVFAT_IRP_CONTEXT IrpContext
)
64 * FUNCTION: Cleans up after a file has been closed.
69 DPRINT("VfatCleanup(DeviceObject %x, Irp %x)\n", IrpContext
->DeviceObject
, IrpContext
->Irp
);
71 if (IrpContext
->DeviceObject
== VfatGlobalData
->DeviceObject
)
73 Status
= STATUS_SUCCESS
;
77 if (!ExAcquireResourceExclusiveLite (&IrpContext
->DeviceExt
->DirResource
,
78 (BOOLEAN
)(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
);