3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: drivers/fs/vfat/close.c
6 * PURPOSE: VFAT Filesystem
7 * PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
11 /* INCLUDES *****************************************************************/
13 #include <ddk/ntddk.h>
20 /* FUNCTIONS ****************************************************************/
23 VfatCloseFile (PDEVICE_EXTENSION DeviceExt
, PFILE_OBJECT FileObject
)
25 * FUNCTION: Closes a file
30 NTSTATUS Status
= STATUS_SUCCESS
;
32 DPRINT ("VfatCloseFile(DeviceExt %x, FileObject %x)\n",
33 DeviceExt
, FileObject
);
35 /* FIXME : update entry in directory? */
36 pCcb
= (PVFATCCB
) (FileObject
->FsContext2
);
37 pFcb
= (PVFATFCB
) (FileObject
->FsContext
);
41 return STATUS_SUCCESS
;
44 if (pFcb
->Flags
& FCB_IS_VOLUME
)
48 FileObject
->FsContext2
= NULL
;
50 else if (FileObject
->FileName
.Buffer
)
52 // This a FO, that was created outside from FSD.
53 // Some FO's are created with IoCreateStreamFileObject() insid from FSD.
54 // This FO's haven't a FileName.
55 if (FileObject
->DeletePending
)
57 if (pFcb
->Flags
& FCB_DELETE_PENDING
)
59 VfatDelEntry (DeviceExt
, pFcb
);
63 Status
= STATUS_DELETE_PENDING
;
66 vfatReleaseFCB (DeviceExt
, pFcb
);
69 FileObject
->FsContext2
= NULL
;
70 FileObject
->FsContext
= NULL
;
71 FileObject
->SectionObjectPointer
= NULL
;
81 NTSTATUS
VfatClose (PVFAT_IRP_CONTEXT IrpContext
)
83 * FUNCTION: Closes a file
88 DPRINT ("VfatClose(DeviceObject %x, Irp %x)\n", IrpContext
->DeviceObject
, IrpContext
->Irp
);
90 if (IrpContext
->DeviceObject
== VfatGlobalData
->DeviceObject
)
92 DPRINT("Closing file system\n");
93 Status
= STATUS_SUCCESS
;
97 /* There occurs a dead look at the call to CcRosDeleteFileCache/ObDereferenceObject/VfatClose
98 in CmLazyCloseThreadMain if VfatClose is execute asynchronous in a worker thread. */
99 if (!ExAcquireResourceExclusiveLite (&IrpContext
->DeviceExt
->DirResource
, IrpContext
->Flags
& IRPCONTEXT_CANWAIT
))
101 if (!ExAcquireResourceExclusiveLite (&IrpContext
->DeviceExt
->DirResource
, TRUE
))
104 return VfatQueueRequest (IrpContext
);
107 Status
= VfatCloseFile (IrpContext
->DeviceExt
, IrpContext
->FileObject
);
108 ExReleaseResourceLite (&IrpContext
->DeviceExt
->DirResource
);
111 IrpContext
->Irp
->IoStatus
.Status
= Status
;
112 IrpContext
->Irp
->IoStatus
.Information
= 0;
113 IoCompleteRequest (IrpContext
->Irp
, IO_NO_INCREMENT
);
114 VfatFreeIrpContext(IrpContext
);