2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: drivers/filesystems/fastfat/close.c
5 * PURPOSE: VFAT Filesystem
6 * PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
9 /* INCLUDES *****************************************************************/
16 /* FUNCTIONS ****************************************************************/
19 * FUNCTION: Closes a file
23 PDEVICE_EXTENSION DeviceExt
,
24 PFILE_OBJECT FileObject
)
29 NTSTATUS Status
= STATUS_SUCCESS
;
31 DPRINT("VfatCloseFile(DeviceExt %p, FileObject %p)\n",
32 DeviceExt
, FileObject
);
34 /* FIXME : update entry in directory? */
35 pCcb
= (PVFATCCB
) (FileObject
->FsContext2
);
36 pFcb
= (PVFATFCB
) (FileObject
->FsContext
);
40 return STATUS_SUCCESS
;
43 IsVolume
= BooleanFlagOn(pFcb
->Flags
, FCB_IS_VOLUME
);
47 FileObject
->FsContext2
= NULL
;
51 if (pFcb
->OpenHandleCount
== 0 && BooleanFlagOn(pFcb
->Flags
, FCB_CACHE_INITIALIZED
))
53 PFILE_OBJECT tmpFileObject
;
54 tmpFileObject
= pFcb
->FileObject
;
55 if (tmpFileObject
!= NULL
)
57 pFcb
->FileObject
= NULL
;
58 CcUninitializeCacheMap(tmpFileObject
, NULL
, NULL
);
59 ClearFlag(pFcb
->Flags
, FCB_CACHE_INITIALIZED
);
60 ObDereferenceObject(tmpFileObject
);
65 pFcb
->Flags
|= FCB_CLOSED
;
67 vfatReleaseFCB(DeviceExt
, pFcb
);
70 FileObject
->FsContext2
= NULL
;
71 FileObject
->FsContext
= NULL
;
72 FileObject
->SectionObjectPointer
= NULL
;
80 if (IsVolume
&& DeviceExt
->OpenHandleCount
== 0)
82 VfatCheckForDismount(DeviceExt
, FALSE
);
90 * FUNCTION: Closes a file
94 PVFAT_IRP_CONTEXT IrpContext
)
98 DPRINT("VfatClose(DeviceObject %p, Irp %p)\n", IrpContext
->DeviceObject
, IrpContext
->Irp
);
100 if (IrpContext
->DeviceObject
== VfatGlobalData
->DeviceObject
)
102 DPRINT("Closing file system\n");
103 IrpContext
->Irp
->IoStatus
.Information
= 0;
104 return STATUS_SUCCESS
;
106 if (!ExAcquireResourceExclusiveLite(&IrpContext
->DeviceExt
->DirResource
, BooleanFlagOn(IrpContext
->Flags
, IRPCONTEXT_CANWAIT
)))
108 return VfatMarkIrpContextForQueue(IrpContext
);
111 Status
= VfatCloseFile(IrpContext
->DeviceExt
, IrpContext
->FileObject
);
112 ExReleaseResourceLite(&IrpContext
->DeviceExt
->DirResource
);
114 IrpContext
->Irp
->IoStatus
.Information
= 0;