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 *****************************************************************/
16 /* FUNCTIONS ****************************************************************/
19 VfatCleanupFile(PVFAT_IRP_CONTEXT IrpContext
)
21 * FUNCTION: Cleans up after a file has been closed.
25 PFILE_OBJECT FileObject
= IrpContext
->FileObject
;
27 DPRINT("VfatCleanupFile(DeviceExt %x, FileObject %x)\n",
28 IrpContext
->DeviceExt
, FileObject
);
30 /* FIXME: handle file/directory deletion here */
31 pFcb
= (PVFATFCB
) FileObject
->FsContext
;
34 if (!(*pFcb
->Attributes
& FILE_ATTRIBUTE_DIRECTORY
) &&
35 FsRtlAreThereCurrentFileLocks(&pFcb
->FileLock
))
37 /* remove all locks this process have on this file */
38 FsRtlFastUnlockAll(&pFcb
->FileLock
,
40 IoGetRequestorProcess(IrpContext
->Irp
),
44 if (pFcb
->Flags
& FCB_IS_DIRTY
)
46 VfatUpdateEntry (pFcb
);
49 /* Uninitialize file cache if initialized for this file object. */
50 if (FileObject
->PrivateCacheMap
)
52 CcRosReleaseFileCache (FileObject
);
55 pFcb
->OpenHandleCount
--;
56 IoRemoveShareAccess(FileObject
, &pFcb
->FCBShareAccess
);
58 return STATUS_SUCCESS
;
61 NTSTATUS
VfatCleanup (PVFAT_IRP_CONTEXT IrpContext
)
63 * FUNCTION: Cleans up after a file has been closed.
68 DPRINT("VfatCleanup(DeviceObject %x, Irp %x)\n", IrpContext
->DeviceObject
, IrpContext
->Irp
);
70 if (IrpContext
->DeviceObject
== VfatGlobalData
->DeviceObject
)
72 Status
= STATUS_SUCCESS
;
76 if (!ExAcquireResourceExclusiveLite (&IrpContext
->DeviceExt
->DirResource
,
77 (BOOLEAN
)(IrpContext
->Flags
& IRPCONTEXT_CANWAIT
)))
79 return VfatQueueRequest (IrpContext
);
82 Status
= VfatCleanupFile(IrpContext
);
84 ExReleaseResourceLite (&IrpContext
->DeviceExt
->DirResource
);
87 IrpContext
->Irp
->IoStatus
.Status
= Status
;
88 IrpContext
->Irp
->IoStatus
.Information
= 0;
90 IoCompleteRequest (IrpContext
->Irp
, IO_NO_INCREMENT
);
91 VfatFreeIrpContext(IrpContext
);