ReactOS  0.4.15-dev-1632-g4e289ce
close.c File Reference
#include "ntfs.h"
#include <debug.h>
Include dependency graph for close.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NtfsCloseFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
 
NTSTATUS NtfsClose (PNTFS_IRP_CONTEXT IrpContext)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 31 of file close.c.

Function Documentation

◆ NtfsClose()

NTSTATUS NtfsClose ( PNTFS_IRP_CONTEXT  IrpContext)

Definition at line 84 of file close.c.

85 {
86  PDEVICE_EXTENSION DeviceExtension;
90 
91  DPRINT("NtfsClose() called\n");
92 
93  DeviceObject = IrpContext->DeviceObject;
95  {
96  DPRINT("Closing file system\n");
97  IrpContext->Irp->IoStatus.Information = 0;
98  return STATUS_SUCCESS;
99  }
100 
101  FileObject = IrpContext->FileObject;
102  DeviceExtension = DeviceObject->DeviceExtension;
103 
104  if (!ExAcquireResourceExclusiveLite(&DeviceExtension->DirResource,
105  BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT)))
106  {
107  return NtfsMarkIrpContextForQueue(IrpContext);
108  }
109 
110  Status = NtfsCloseFile(DeviceExtension, FileObject);
111 
112  ExReleaseResourceLite(&DeviceExtension->DirResource);
113 
114  if (Status == STATUS_PENDING)
115  {
116  return NtfsMarkIrpContextForQueue(IrpContext);
117  }
118 
119  IrpContext->Irp->IoStatus.Information = 0;
120  return Status;
121 }
PDEVICE_OBJECT DeviceObject
Definition: ntfs.h:484
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
FORCEINLINE NTSTATUS NtfsMarkIrpContextForQueue(PNTFS_IRP_CONTEXT IrpContext)
Definition: ntfs.h:565
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NtfsCloseFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
Definition: close.c:40
IO_STATUS_BLOCK IoStatus
PNTFS_GLOBAL_DATA NtfsGlobalData
Definition: ntfs.c:41
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define IRPCONTEXT_CANWAIT
Definition: vfat.h:575
void DPRINT(...)
Definition: polytest.cpp:61
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
Status
Definition: gdiplustypes.h:24
#define STATUS_PENDING
Definition: ntstatus.h:82
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
* PFILE_OBJECT
Definition: iotypes.h:1995
ULONG Flags
Definition: ntfs.h:477
PDEVICE_OBJECT DeviceObject
Definition: ntfs.h:148
#define STATUS_SUCCESS
Definition: shellext.h:65
PFILE_OBJECT FileObject
Definition: ntfs.h:485

◆ NtfsCloseFile()

NTSTATUS NtfsCloseFile ( PDEVICE_EXTENSION  DeviceExt,
PFILE_OBJECT  FileObject 
)

Definition at line 40 of file close.c.

42 {
43  PNTFS_CCB Ccb;
44  PNTFS_FCB Fcb;
45 
46  DPRINT("NtfsCloseFile(DeviceExt %p, FileObject %p)\n",
47  DeviceExt,
48  FileObject);
49 
50  Ccb = (PNTFS_CCB)(FileObject->FsContext2);
51  Fcb = (PNTFS_FCB)(FileObject->FsContext);
52 
53  DPRINT("Ccb %p\n", Ccb);
54  if (Ccb == NULL)
55  {
56  return STATUS_SUCCESS;
57  }
58 
59  FileObject->FsContext2 = NULL;
60  FileObject->FsContext = NULL;
61  FileObject->SectionObjectPointer = NULL;
62  DeviceExt->OpenHandleCount--;
63 
64  if (FileObject->FileName.Buffer)
65  {
66  // This a FO, that was created outside from FSD.
67  // Some FO's are created with IoCreateStreamFileObject() insid from FSD.
68  // This FO's don't have a FileName.
69  NtfsReleaseFCB(DeviceExt, Fcb);
70  }
71 
72  if (Ccb->DirectorySearchPattern)
73  {
74  ExFreePool(Ccb->DirectorySearchPattern);
75  }
76 
77  ExFreePool(Ccb);
78 
79  return STATUS_SUCCESS;
80 }
VOID NtfsReleaseFCB(PNTFS_VCB Vcb, PNTFS_FCB Fcb)
Definition: fcb.c:171
Definition: cdstruc.h:902
Definition: ntfs.h:129
void DPRINT(...)
Definition: polytest.cpp:61
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
struct NTFS_CCB * PNTFS_CCB
struct _FCB * PNTFS_FCB
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:588
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ PFCB Fcb
Definition: cdprocs.h:159
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by NtfsClose(), and NtfsCreateFile().