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 #ifdef USE_ROS_CC_AND_FS
53 CcRosReleaseFileCache (FileObject
);
55 CcUninitializeCacheMap (FileObject
, NULL
, NULL
);
59 pFcb
->OpenHandleCount
--;
60 IoRemoveShareAccess(FileObject
, &pFcb
->FCBShareAccess
);
62 return STATUS_SUCCESS
;
65 NTSTATUS
VfatCleanup (PVFAT_IRP_CONTEXT IrpContext
)
67 * FUNCTION: Cleans up after a file has been closed.
72 DPRINT("VfatCleanup(DeviceObject %x, Irp %x)\n", IrpContext
->DeviceObject
, IrpContext
->Irp
);
74 if (IrpContext
->DeviceObject
== VfatGlobalData
->DeviceObject
)
76 Status
= STATUS_SUCCESS
;
80 if (!ExAcquireResourceExclusiveLite (&IrpContext
->DeviceExt
->DirResource
,
81 (BOOLEAN
)(IrpContext
->Flags
& IRPCONTEXT_CANWAIT
)))
83 return VfatQueueRequest (IrpContext
);
86 Status
= VfatCleanupFile(IrpContext
);
88 ExReleaseResourceLite (&IrpContext
->DeviceExt
->DirResource
);
91 IrpContext
->Irp
->IoStatus
.Status
= Status
;
92 IrpContext
->Irp
->IoStatus
.Information
= 0;
94 IoCompleteRequest (IrpContext
->Irp
, IO_NO_INCREMENT
);
95 VfatFreeIrpContext(IrpContext
);