2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: drivers/fs/vfat/close.c
5 * PURPOSE: VFAT Filesystem
6 * PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
9 /* INCLUDES *****************************************************************/
14 /* FUNCTIONS ****************************************************************/
17 VfatCloseFile (PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
)
19 * FUNCTION: Closes a file
24 NTSTATUS Status
= STATUS_SUCCESS
;
26 DPRINT ("VfatCloseFile(DeviceExt %p, FileObject %p)\n",
27 DeviceExt
, FileObject
);
29 /* FIXME : update entry in directory? */
30 pCcb
= (PVFATCCB
) (FileObject
->FsContext2
);
31 pFcb
= (PVFATFCB
) (FileObject
->FsContext
);
35 return STATUS_SUCCESS
;
38 if (pFcb
->Flags
& FCB_IS_VOLUME
)
42 FileObject
->FsContext2
= NULL
;
46 if (FileObject
->DeletePending
)
48 if (pFcb
->Flags
& FCB_DELETE_PENDING
)
50 VfatDelEntry (DeviceExt
, pFcb
);
54 Status
= STATUS_DELETE_PENDING
;
57 vfatReleaseFCB (DeviceExt
, pFcb
);
60 FileObject
->FsContext2
= NULL
;
61 FileObject
->FsContext
= NULL
;
62 FileObject
->SectionObjectPointer
= NULL
;
72 NTSTATUS
VfatClose (PVFAT_IRP_CONTEXT IrpContext
)
74 * FUNCTION: Closes a file
79 DPRINT ("VfatClose(DeviceObject %p, Irp %p)\n", IrpContext
->DeviceObject
, IrpContext
->Irp
);
81 if (IrpContext
->DeviceObject
== VfatGlobalData
->DeviceObject
)
83 DPRINT("Closing file system\n");
84 Status
= STATUS_SUCCESS
;
88 /* There occurs a dead look at the call to CcRosDeleteFileCache/ObDereferenceObject/VfatClose
89 in CmLazyCloseThreadMain if VfatClose is execute asynchronous in a worker thread. */
90 if (!ExAcquireResourceExclusiveLite (&IrpContext
->DeviceExt
->DirResource
, IrpContext
->Flags
& IRPCONTEXT_CANWAIT
))
92 if (!ExAcquireResourceExclusiveLite (&IrpContext
->DeviceExt
->DirResource
, TRUE
))
95 return VfatQueueRequest (IrpContext
);
98 Status
= VfatCloseFile (IrpContext
->DeviceExt
, IrpContext
->FileObject
);
99 ExReleaseResourceLite (&IrpContext
->DeviceExt
->DirResource
);
102 IrpContext
->Irp
->IoStatus
.Status
= Status
;
103 IrpContext
->Irp
->IoStatus
.Information
= 0;
104 IoCompleteRequest (IrpContext
->Irp
, IO_NO_INCREMENT
);
105 VfatFreeIrpContext(IrpContext
);