ReactOS 0.4.15-dev-8422-g6219a1a
cleanup.c File Reference
#include "vfat.h"
#include <debug.h>
Include dependency graph for cleanup.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static BOOLEAN VfatCleanupFile (PVFAT_IRP_CONTEXT IrpContext)
 
NTSTATUS VfatCleanup (PVFAT_IRP_CONTEXT IrpContext)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file cleanup.c.

Function Documentation

◆ VfatCleanup()

NTSTATUS VfatCleanup ( PVFAT_IRP_CONTEXT  IrpContext)

Definition at line 176 of file cleanup.c.

178{
180
181 DPRINT("VfatCleanup(DeviceObject %p, Irp %p)\n", IrpContext->DeviceObject, IrpContext->Irp);
182
183 if (IrpContext->DeviceObject == VfatGlobalData->DeviceObject)
184 {
185 IrpContext->Irp->IoStatus.Information = 0;
186 return STATUS_SUCCESS;
187 }
188
190 Deleted = VfatCleanupFile(IrpContext);
192
193 IrpContext->Irp->IoStatus.Information = 0;
194 return STATUS_SUCCESS;
195}
unsigned char BOOLEAN
#define TRUE
Definition: types.h:120
static BOOLEAN VfatCleanupFile(PVFAT_IRP_CONTEXT IrpContext)
Definition: cleanup.c:24
#define ExAcquireResourceExclusiveLite(res, wait)
Definition: env_spec_w32.h:615
PVFAT_GLOBAL_DATA VfatGlobalData
Definition: iface.c:18
@ Deleted
Definition: kstypes.h:187
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1822
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
ERESOURCE DirResource
Definition: ntfs.h:103
PDEVICE_OBJECT DeviceObject
Definition: vfat.h:412
PDEVICE_OBJECT DeviceObject
Definition: vfat.h:584
PDEVICE_EXTENSION DeviceExt
Definition: vfat.h:585
IO_STATUS_BLOCK IoStatus

Referenced by VfatDispatchRequest().

◆ VfatCleanupFile()

static BOOLEAN VfatCleanupFile ( PVFAT_IRP_CONTEXT  IrpContext)
static

Definition at line 24 of file cleanup.c.

26{
27 PVFATFCB pFcb;
28 PVFATCCB pCcb;
29 BOOLEAN IsVolume;
30 PDEVICE_EXTENSION DeviceExt = IrpContext->DeviceExt;
33
34 DPRINT("VfatCleanupFile(DeviceExt %p, FileObject %p)\n",
35 IrpContext->DeviceExt, FileObject);
36
37 /* FIXME: handle file/directory deletion here */
38 pFcb = (PVFATFCB)FileObject->FsContext;
39 if (!pFcb)
40 return FALSE;
41
42 IsVolume = BooleanFlagOn(pFcb->Flags, FCB_IS_VOLUME);
43 if (IsVolume)
44 {
45 pFcb->OpenHandleCount--;
46 DeviceExt->OpenHandleCount--;
47
48 if (pFcb->OpenHandleCount != 0)
49 {
51 }
52 }
53 else
54 {
57
58 pCcb = FileObject->FsContext2;
60 {
62 }
63
64 /* Notify about the cleanup */
66 &(IrpContext->DeviceExt->NotifyList),
67 FileObject->FsContext2);
68
69 pFcb->OpenHandleCount--;
70 DeviceExt->OpenHandleCount--;
71
72 if (!vfatFCBIsDirectory(pFcb) &&
74 {
75 /* remove all locks this process have on this file */
78 IoGetRequestorProcess(IrpContext->Irp),
79 NULL);
80 }
81
83 {
84 VfatUpdateEntry (DeviceExt, pFcb);
85 }
86
88 pFcb->OpenHandleCount == 0)
89 {
90 if (vfatFCBIsDirectory(pFcb) &&
91 !VfatIsDirectoryEmpty(DeviceExt, pFcb))
92 {
93 pFcb->Flags &= ~FCB_DELETE_PENDING;
94 }
95 else
96 {
97 PFILE_OBJECT tmpFileObject;
98 tmpFileObject = pFcb->FileObject;
99 if (tmpFileObject != NULL)
100 {
101 pFcb->FileObject = NULL;
102 CcUninitializeCacheMap(tmpFileObject, NULL, NULL);
104 ObDereferenceObject(tmpFileObject);
105 }
106
107 pFcb->RFCB.ValidDataLength.QuadPart = 0;
108 pFcb->RFCB.FileSize.QuadPart = 0;
109 pFcb->RFCB.AllocationSize.QuadPart = 0;
110 }
111 }
112
113 /* Uninitialize the cache (should be done even if caching was never initialized) */
115
117 pFcb->OpenHandleCount == 0)
118 {
119 VfatDelEntry(DeviceExt, pFcb, NULL);
120
121 vfatReportChange(DeviceExt,
122 pFcb,
123 (vfatFCBIsDirectory(pFcb) ?
126 }
127
128 if (pFcb->OpenHandleCount != 0)
129 {
131 }
132/* FIXME: causes FS corruption and breaks selfhosting/testbots and so on */
133#if 0
134 /* If that's the last open handle we just closed, try to see whether
135 * we can delay close operation
136 */
139 {
140 /* This is only allowed if that's a directory with no open files
141 * OR if it's a file with no section opened
142 */
143 if ((vfatFCBIsDirectory(pFcb) && IsListEmpty(&pFcb->ParentListHead)) ||
144 (!vfatFCBIsDirectory(pFcb) && FileObject->SectionObjectPointer->DataSectionObject == NULL &&
145 FileObject->SectionObjectPointer->ImageSectionObject == NULL))
146 {
147 DPRINT("Delaying close of: %wZ\n", &pFcb->PathNameU);
149 }
150 }
151#endif
152
154#ifdef KDBG
155 pFcb->Flags |= FCB_CLEANED_UP;
156#endif
157
160 }
161
162#ifdef ENABLE_SWAPOUT
163 if (IsVolume && BooleanFlagOn(DeviceExt->Flags, VCB_DISMOUNT_PENDING))
164 {
165 Deleted = VfatCheckForDismount(DeviceExt, TRUE);
166 }
167#endif
168
169 return Deleted;
170}
NTSTATUS VfatUpdateEntry(IN PDEVICE_EXTENSION DeviceExt, IN PVFATFCB pFcb)
Definition: dirwr.c:115
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define FCB_IS_VOLUME
Definition: ntfs.h:510
#define FCB_CACHE_INITIALIZED
Definition: ntfs.h:508
BOOLEAN VfatCheckForDismount(IN PDEVICE_EXTENSION DeviceExt, IN BOOLEAN Force)
Definition: misc.c:495
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define ClearFlag(_F, _SF)
Definition: ext2fs.h:191
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define VCB_DISMOUNT_PENDING
Definition: ext2fs.h:791
#define FCB_DELETE_PENDING
Definition: ext2fs.h:888
#define CCB_DELETE_ON_CLOSE
Definition: ext2fs.h:1035
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
NTSTATUS NTAPI FsRtlFastUnlockAll(IN PFILE_LOCK FileLock, IN PFILE_OBJECT FileObject, IN PEPROCESS Process, IN PVOID Context OPTIONAL)
Definition: filelock.c:1025
#define FsRtlAreThereCurrentFileLocks(FL)
Definition: fsrtlfuncs.h:1584
BOOLEAN NTAPI CcUninitializeCacheMap(IN PFILE_OBJECT FileObject, IN OPTIONAL PLARGE_INTEGER TruncateSize, IN OPTIONAL PCACHE_UNINITIALIZE_EVENT UninitializeEvent)
Definition: fssup.c:286
if(dx< 0)
Definition: linetemp.h:194
VOID NTAPI FsRtlNotifyCleanup(IN PNOTIFY_SYNC NotifySync, IN PLIST_ENTRY NotifyList, IN PVOID FsContext)
Definition: notify.c:659
VOID NTAPI IoRemoveShareAccess(IN PFILE_OBJECT FileObject, IN PSHARE_ACCESS ShareAccess)
Definition: file.c:3478
PEPROCESS NTAPI IoGetRequestorProcess(IN PIRP Irp)
Definition: irp.c:1782
PNOTIFY_SYNC NotifySync
Definition: vfat.h:352
LIST_ENTRY NotifyList
Definition: vfat.h:351
PFILE_OBJECT FileObject
Definition: vfat.h:591
LARGE_INTEGER AllocationSize
Definition: env_spec_w32.h:755
LARGE_INTEGER ValidDataLength
Definition: env_spec_w32.h:757
Definition: vfat.h:537
ULONG Flags
Definition: vfat.h:539
Definition: vfat.h:448
FILE_LOCK FileLock
Definition: vfat.h:520
PFILE_OBJECT FileObject
Definition: vfat.h:499
ULONG Flags
Definition: vfat.h:496
ERESOURCE PagingIoResource
Definition: vfat.h:453
FSRTL_COMMON_FCB_HEADER RFCB
Definition: vfat.h:450
UNICODE_STRING PathNameU
Definition: vfat.h:472
LIST_ENTRY ParentListHead
Definition: vfat.h:493
ERESOURCE MainResource
Definition: vfat.h:452
SHARE_ACCESS FCBShareAccess
Definition: vfat.h:508
ULONG OpenHandleCount
Definition: vfat.h:511
LONGLONG QuadPart
Definition: typedefs.h:114
struct _VFATFCB * PVFATFCB
#define FCB_DELAYED_CLOSE
Definition: vfat.h:439
#define FCB_IS_PAGE_FILE
Definition: vfat.h:436
FORCEINLINE BOOLEAN vfatFCBIsDirectory(PVFATFCB FCB)
Definition: vfat.h:637
FORCEINLINE BOOLEAN VfatIsDirectoryEmpty(PDEVICE_EXTENSION DeviceExt, struct _VFATFCB *Fcb)
Definition: vfat.h:367
#define FCB_IS_DIRTY
Definition: vfat.h:438
FORCEINLINE NTSTATUS VfatDelEntry(PDEVICE_EXTENSION DeviceExt, struct _VFATFCB *Fcb, struct _VFAT_MOVE_CONTEXT *MoveContext)
Definition: vfat.h:388
#define FCB_IS_FAT
Definition: vfat.h:435
FORCEINLINE VOID vfatReportChange(IN PDEVICE_EXTENSION DeviceExt, IN PVFATFCB Fcb, IN ULONG FilterMatch, IN ULONG Action)
Definition: vfat.h:658
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
#define FILE_ACTION_REMOVED
#define FILE_NOTIFY_CHANGE_FILE_NAME
#define FO_CLEANUP_COMPLETE
Definition: iotypes.h:1790
* PFILE_OBJECT
Definition: iotypes.h:1998
#define FILE_NOTIFY_CHANGE_DIR_NAME
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by VfatCleanup().