ReactOS 0.4.17-dev-1196-gb6224c3
close.c
Go to the documentation of this file.
1/*
2 * ReactOS kernel
3 * Copyright (C) 2002 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 * COPYRIGHT: See COPYING in the top level directory
20 * PROJECT: ReactOS kernel
21 * FILE: drivers/filesystem/ntfs/close.c
22 * PURPOSE: NTFS filesystem driver
23 * PROGRAMMER: Art Yerkes
24 * UPDATE HISTORY:
25 */
26
27/* INCLUDES *****************************************************************/
28
29#include "ntfs.h"
30
31#define NDEBUG
32#include <debug.h>
33
34/* FUNCTIONS ****************************************************************/
35
36/*
37 * FUNCTION: Closes a file
38 */
42{
45
46 DPRINT("NtfsCloseFile(DeviceExt %p, FileObject %p)\n",
47 DeviceExt,
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
62 /* SectionObjectPointer is deliberately left alone. Mm reaches the file's section object
63 * pointers through it for as long as a section exists, which outlasts the handle. */
64
65 DeviceExt->OpenHandleCount--;
66
67 if (FileObject->FileName.Buffer)
68 {
69 // This a FO, that was created outside from FSD.
70 // Some FO's are created with IoCreateStreamFileObject() insid from FSD.
71 // This FO's don't have a FileName.
72 NtfsReleaseFCB(DeviceExt, Fcb);
73 }
74
75 if (Ccb->DirectorySearchPattern)
76 {
77 ExFreePool(Ccb->DirectorySearchPattern);
78 }
79
81
82 return STATUS_SUCCESS;
83}
84
85
88{
89 PDEVICE_EXTENSION DeviceExtension;
93
94 DPRINT("NtfsClose() called\n");
95
96 DeviceObject = IrpContext->DeviceObject;
98 {
99 DPRINT("Closing file system\n");
100 IrpContext->Irp->IoStatus.Information = 0;
101 return STATUS_SUCCESS;
102 }
103
104 FileObject = IrpContext->FileObject;
105 DeviceExtension = DeviceObject->DeviceExtension;
106
107 if (!ExAcquireResourceExclusiveLite(&DeviceExtension->DirResource,
109 {
110 return NtfsMarkIrpContextForQueue(IrpContext);
111 }
112
113 Status = NtfsCloseFile(DeviceExtension, FileObject);
114
115 ExReleaseResourceLite(&DeviceExtension->DirResource);
116
117 if (Status == STATUS_PENDING)
118 {
119 return NtfsMarkIrpContextForQueue(IrpContext);
120 }
121
122 IrpContext->Irp->IoStatus.Information = 0;
123 return Status;
124}
125
126/* EOF */
LONG NTSTATUS
Definition: precomp.h:26
_In_ PFCB Fcb
Definition: cdprocs.h:159
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:592
#define NULL
Definition: types.h:112
NTSTATUS NtfsCloseFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
Definition: close.c:40
NTSTATUS NtfsClose(PNTFS_IRP_CONTEXT IrpContext)
Definition: close.c:87
PNTFS_GLOBAL_DATA NtfsGlobalData
Definition: ntfs.c:36
FORCEINLINE NTSTATUS NtfsMarkIrpContextForQueue(PNTFS_IRP_CONTEXT IrpContext)
Definition: ntfs.h:652
struct NTFS_CCB * PNTFS_CCB
#define IRPCONTEXT_CANWAIT
Definition: ntfs.h:505
struct _FCB * PNTFS_FCB
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define ExAcquireResourceExclusiveLite(res, wait)
Definition: env_spec_w32.h:615
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
Status
Definition: gdiplustypes.h:24
VOID NtfsReleaseFCB(PNTFS_VCB Vcb, PNTFS_FCB Fcb)
Definition: fcb.c:209
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1822
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
Definition: ntfs.h:151
PDEVICE_OBJECT DeviceObject
Definition: ntfs.h:175
PFILE_OBJECT FileObject
Definition: ntfs.h:564
ULONG Flags
Definition: ntfs.h:556
PDEVICE_OBJECT DeviceObject
Definition: ntfs.h:563
Definition: cdstruc.h:902
IO_STATUS_BLOCK IoStatus
#define STATUS_PENDING
Definition: telnetd.h:14
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
* PFILE_OBJECT
Definition: iotypes.h:1998