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
)
28 NTSTATUS Status
= STATUS_SUCCESS
;
30 DPRINT("VfatCloseFile(DeviceExt %p, FileObject %p)\n",
31 DeviceExt
, FileObject
);
33 /* FIXME : update entry in directory? */
34 pCcb
= (PVFATCCB
) (FileObject
->FsContext2
);
35 pFcb
= (PVFATFCB
) (FileObject
->FsContext
);
39 return STATUS_SUCCESS
;
42 if (pFcb
->Flags
& FCB_IS_VOLUME
)
45 FileObject
->FsContext2
= NULL
;
49 if (FileObject
->DeletePending
)
51 if (pFcb
->Flags
& FCB_DELETE_PENDING
)
53 VfatDelEntry(DeviceExt
, pFcb
, NULL
);
55 FsRtlNotifyFullReportChange(DeviceExt
->NotifySync
,
56 &(DeviceExt
->NotifyList
),
57 (PSTRING
)&pFcb
->PathNameU
,
58 pFcb
->PathNameU
.Length
- pFcb
->LongNameU
.Length
,
61 ((*pFcb
->Attributes
& FILE_ATTRIBUTE_DIRECTORY
) ?
62 FILE_NOTIFY_CHANGE_DIR_NAME
: FILE_NOTIFY_CHANGE_FILE_NAME
),
68 Status
= STATUS_DELETE_PENDING
;
72 vfatReleaseFCB(DeviceExt
, pFcb
);
75 FileObject
->FsContext2
= NULL
;
76 FileObject
->FsContext
= NULL
;
77 FileObject
->SectionObjectPointer
= NULL
;
88 * FUNCTION: Closes a file
92 PVFAT_IRP_CONTEXT IrpContext
)
96 DPRINT("VfatClose(DeviceObject %p, Irp %p)\n", IrpContext
->DeviceObject
, IrpContext
->Irp
);
98 if (IrpContext
->DeviceObject
== VfatGlobalData
->DeviceObject
)
100 DPRINT("Closing file system\n");
101 Status
= STATUS_SUCCESS
;
105 /* There occurs a dead look at the call to CcRosDeleteFileCache/ObDereferenceObject/VfatClose
106 in CmLazyCloseThreadMain if VfatClose is execute asynchronous in a worker thread. */
107 if (!ExAcquireResourceExclusiveLite(&IrpContext
->DeviceExt
->DirResource
, IrpContext
->Flags
& IRPCONTEXT_CANWAIT
))
109 if (!ExAcquireResourceExclusiveLite(&IrpContext
->DeviceExt
->DirResource
, TRUE
))
112 return VfatQueueRequest(IrpContext
);
115 Status
= VfatCloseFile(IrpContext
->DeviceExt
, IrpContext
->FileObject
);
116 ExReleaseResourceLite(&IrpContext
->DeviceExt
->DirResource
);
119 IrpContext
->Irp
->IoStatus
.Status
= Status
;
120 IrpContext
->Irp
->IoStatus
.Information
= 0;
121 IoCompleteRequest(IrpContext
->Irp
, IO_NO_INCREMENT
);
122 VfatFreeIrpContext(IrpContext
);