ReactOS  0.4.15-dev-1197-g8081ba9
cleanup.c
Go to the documentation of this file.
1 /*
2  * ReactOS kernel
3  * Copyright (C) 2016 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/cleanup.c
22  * PURPOSE: NTFS filesystem driver
23  * PROGRAMMER: Pierre Schweitzer (pierre@reactos.org)
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: Cleans up a file
38  */
42  BOOLEAN CanWait)
43 {
44  PNTFS_FCB Fcb;
45 
46  DPRINT("NtfsCleanupFile(DeviceExt %p, FileObject %p, CanWait %u)\n",
47  DeviceExt,
48  FileObject,
49  CanWait);
50 
51  Fcb = (PNTFS_FCB)(FileObject->FsContext);
52  if (!Fcb)
53  return STATUS_SUCCESS;
54 
55  if (Fcb->Flags & FCB_IS_VOLUME)
56  {
58 
59  if (Fcb->OpenHandleCount != 0)
60  {
61  // Remove share access when handled
62  }
63  }
64  else
65  {
67  {
68  return STATUS_PENDING;
69  }
70 
72 
74 
75  if (Fcb->OpenHandleCount != 0)
76  {
77  // Remove share access when handled
78  }
79 
81 
83  }
84 
85  return STATUS_SUCCESS;
86 }
87 
90 {
91  PDEVICE_EXTENSION DeviceExtension;
95 
96  DPRINT("NtfsCleanup() called\n");
97 
98  DeviceObject = IrpContext->DeviceObject;
100  {
101  DPRINT("Cleaning up file system\n");
102  IrpContext->Irp->IoStatus.Information = 0;
103  return STATUS_SUCCESS;
104  }
105 
106  FileObject = IrpContext->FileObject;
107  DeviceExtension = DeviceObject->DeviceExtension;
108 
109  if (!ExAcquireResourceExclusiveLite(&DeviceExtension->DirResource,
110  BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT)))
111  {
112  return NtfsMarkIrpContextForQueue(IrpContext);
113  }
114 
115  Status = NtfsCleanupFile(DeviceExtension, FileObject, BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT));
116 
117  ExReleaseResourceLite(&DeviceExtension->DirResource);
118 
119  if (Status == STATUS_PENDING)
120  {
121  return NtfsMarkIrpContextForQueue(IrpContext);
122  }
123 
124  IrpContext->Irp->IoStatus.Information = 0;
125  return Status;
126 }
PDEVICE_OBJECT DeviceObject
Definition: ntfs.h:484
Definition: cdstruc.h:908
#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
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
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define IRPCONTEXT_CANWAIT
Definition: vfat.h:575
void DPRINT(...)
Definition: polytest.cpp:61
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:588
FSRTL_COMMON_FCB_HEADER RFCB
Definition: ntfs.h:513
ULONG OpenHandleCount
Definition: ntfs.h:533
#define STATUS_PENDING
Definition: ntstatus.h:82
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
* PFILE_OBJECT
Definition: iotypes.h:1978
NTSTATUS NtfsCleanup(PNTFS_IRP_CONTEXT IrpContext)
Definition: cleanup.c:89
ULONG Flags
Definition: ntfs.h:532
Status
Definition: gdiplustypes.h:24
struct _FCB * PNTFS_FCB
ULONG Flags
Definition: ntfs.h:477
ERESOURCE MainResource
Definition: ntfs.h:524
PDEVICE_OBJECT DeviceObject
Definition: ntfs.h:148
#define FCB_IS_VOLUME
Definition: vfat.h:437
BOOLEAN NTAPI CcUninitializeCacheMap(IN PFILE_OBJECT FileObject, IN OPTIONAL PLARGE_INTEGER TruncateSize, IN OPTIONAL PCACHE_UNINITIALIZE_EVENT UninitializeEvent)
Definition: fssup.c:286
#define FO_CLEANUP_COMPLETE
Definition: iotypes.h:1770
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
NTSTATUS NtfsCleanupFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, BOOLEAN CanWait)
Definition: cleanup.c:40
_In_ PFCB Fcb
Definition: cdprocs.h:159
return STATUS_SUCCESS
Definition: btrfs.c:3014
PFILE_OBJECT FileObject
Definition: ntfs.h:485