1 /* 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) 7 */ 8 9 /* INCLUDES *****************************************************************/ 10 11 #include "vfat.h" 12 13 #define NDEBUG 14 #include <debug.h> 15 16 /* FUNCTIONS ****************************************************************/ 17 18 /* 19 * FUNCTION: Closes a file 20 */ 21 NTSTATUS 22 VfatCloseFile( 23 PDEVICE_EXTENSION DeviceExt, 24 PFILE_OBJECT FileObject) 25 { 26 PVFATFCB pFcb; 27 PVFATCCB pCcb; 28 BOOLEAN IsVolume; 29 NTSTATUS Status = STATUS_SUCCESS; 30 31 DPRINT("VfatCloseFile(DeviceExt %p, FileObject %p)\n", 32 DeviceExt, FileObject); 33 34 /* FIXME : update entry in directory? */ 35 pCcb = (PVFATCCB) (FileObject->FsContext2); 36 pFcb = (PVFATFCB) (FileObject->FsContext); 37 38 if (pFcb == NULL) 39 { 40 return STATUS_SUCCESS; 41 } 42 43 IsVolume = BooleanFlagOn(pFcb->Flags, FCB_IS_VOLUME); 44 if (IsVolume) 45 { 46 DPRINT("Volume\n"); 47 FileObject->FsContext2 = NULL; 48 } 49 else 50 { 51 vfatReleaseFCB(DeviceExt, pFcb); 52 } 53 54 FileObject->FsContext2 = NULL; 55 FileObject->FsContext = NULL; 56 FileObject->SectionObjectPointer = NULL; 57 58 if (pCcb) 59 { 60 vfatDestroyCCB(pCcb); 61 } 62 63 #ifdef ENABLE_SWAPOUT 64 if (IsVolume && DeviceExt->OpenHandleCount == 0) 65 { 66 VfatCheckForDismount(DeviceExt, FALSE); 67 } 68 #endif 69 70 return Status; 71 } 72 73 /* 74 * FUNCTION: Closes a file 75 */ 76 NTSTATUS 77 VfatClose( 78 PVFAT_IRP_CONTEXT IrpContext) 79 { 80 NTSTATUS Status; 81 82 DPRINT("VfatClose(DeviceObject %p, Irp %p)\n", IrpContext->DeviceObject, IrpContext->Irp); 83 84 if (IrpContext->DeviceObject == VfatGlobalData->DeviceObject) 85 { 86 DPRINT("Closing file system\n"); 87 IrpContext->Irp->IoStatus.Information = 0; 88 return STATUS_SUCCESS; 89 } 90 if (!ExAcquireResourceExclusiveLite(&IrpContext->DeviceExt->DirResource, BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT))) 91 { 92 return VfatMarkIrpContextForQueue(IrpContext); 93 } 94 95 Status = VfatCloseFile(IrpContext->DeviceExt, IrpContext->FileObject); 96 ExReleaseResourceLite(&IrpContext->DeviceExt->DirResource); 97 98 IrpContext->Irp->IoStatus.Information = 0; 99 100 return Status; 101 } 102 103 /* EOF */ 104