ReactOS 0.4.15-dev-8093-g3285f69
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{
45
46 DPRINT("NtfsCleanupFile(DeviceExt %p, FileObject %p, CanWait %u)\n",
47 DeviceExt,
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,
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}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
_In_ PFCB Fcb
Definition: cdprocs.h:159
#define NULL
Definition: types.h:112
NTSTATUS NtfsCleanup(PNTFS_IRP_CONTEXT IrpContext)
Definition: cleanup.c:89
NTSTATUS NtfsCleanupFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, BOOLEAN CanWait)
Definition: cleanup.c:40
PNTFS_GLOBAL_DATA NtfsGlobalData
Definition: ntfs.c:36
FORCEINLINE NTSTATUS NtfsMarkIrpContextForQueue(PNTFS_IRP_CONTEXT IrpContext)
Definition: ntfs.h:569
#define IRPCONTEXT_CANWAIT
Definition: ntfs.h:474
struct _FCB * PNTFS_FCB
#define FCB_IS_VOLUME
Definition: ntfs.h:510
#define ExAcquireResourceExclusiveLite(res, wait)
Definition: env_spec_w32.h:615
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
BOOLEAN NTAPI CcUninitializeCacheMap(IN PFILE_OBJECT FileObject, IN OPTIONAL PLARGE_INTEGER TruncateSize, IN OPTIONAL PCACHE_UNINITIALIZE_EVENT UninitializeEvent)
Definition: fssup.c:286
Status
Definition: gdiplustypes.h:25
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1822
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
PDEVICE_OBJECT DeviceObject
Definition: ntfs.h:148
PFILE_OBJECT FileObject
Definition: ntfs.h:489
ULONG Flags
Definition: ntfs.h:481
PDEVICE_OBJECT DeviceObject
Definition: ntfs.h:488
Definition: cdstruc.h:902
ULONG Flags
Definition: ntfs.h:536
FSRTL_COMMON_FCB_HEADER RFCB
Definition: ntfs.h:517
ULONG OpenHandleCount
Definition: ntfs.h:537
ERESOURCE MainResource
Definition: ntfs.h:528
IO_STATUS_BLOCK IoStatus
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
#define FO_CLEANUP_COMPLETE
Definition: iotypes.h:1790
* PFILE_OBJECT
Definition: iotypes.h:1998