ReactOS 0.4.15-dev-7897-g78dc504
filobsup.c File Reference
#include "fatprocs.h"
Include dependency graph for filobsup.c:

Go to the source code of this file.

Macros

#define BugCheckFileId   (FAT_BUG_CHECK_FILOBSUP)
 
#define Dbg   (DEBUG_TRACE_FILOBSUP)
 

Functions

VOID FatSetFileObject (IN PFILE_OBJECT FileObject OPTIONAL, IN TYPE_OF_OPEN TypeOfOpen, IN PVOID VcbOrFcbOrDcb, IN PCCB Ccb OPTIONAL)
 
TYPE_OF_OPEN FatDecodeFileObject (_In_ PFILE_OBJECT FileObject, _Outptr_ PVCB *Vcb, _Outptr_ PFCB *FcbOrDcb, _Outptr_ PCCB *Ccb)
 
 _Requires_lock_held_ (_Global_critical_region_)
 

Macro Definition Documentation

◆ BugCheckFileId

#define BugCheckFileId   (FAT_BUG_CHECK_FILOBSUP)

Definition at line 22 of file filobsup.c.

◆ Dbg

#define Dbg   (DEBUG_TRACE_FILOBSUP)

Definition at line 28 of file filobsup.c.

Function Documentation

◆ _Requires_lock_held_()

_Requires_lock_held_ ( _Global_critical_region_  )

Definition at line 345 of file filobsup.c.

372{
373 PFCB OriginalFcb = Fcb;
374 PFCB NextFcb;
375
376 PAGED_CODE();
377
378 DebugTrace(+1, Dbg, "FatPurgeReferencedFileObjects, Fcb = %p\n", Fcb );
379
380 NT_ASSERT( FlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT) );
381
382 //
383 // First, if we have a delayed close, force it closed.
384 //
385
386 FatFspClose(Fcb->Vcb);
387
388 //
389 // Walk the directory tree forcing sections closed.
390 //
391 // Note that it very important to get the next node to visit before
392 // acting on the current node. This is because acting on a node may
393 // make it, and an arbitrary number of direct ancestors, vanish.
394 // Since we never visit ancestors in our top-down enumeration scheme, we
395 // can safely continue the enumeration even when the tree is vanishing
396 // beneath us. This is way cool.
397 //
398
399 while ( Fcb != NULL ) {
400
401 NextFcb = FatGetNextFcbTopDown(IrpContext, Fcb, OriginalFcb);
402
403 //
404 // Check for the EA file fcb
405 //
406
408
409 FatForceCacheMiss( IrpContext, Fcb, FlushType );
410 }
411
412 Fcb = NextFcb;
413 }
414
415 DebugTrace(-1, Dbg, "FatPurgeReferencedFileObjects (VOID)\n", 0 );
416
417 return;
418}
#define PAGED_CODE()
_In_ PFCB Fcb
Definition: cdprocs.h:159
#define IRP_CONTEXT_FLAG_WAIT
Definition: cdstruc.h:1215
#define NULL
Definition: types.h:112
#define FAT_DIRENT_ATTR_VOLUME_ID
Definition: fat.h:371
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define Dbg
Definition: filobsup.c:28
#define DebugTrace(INDENT, LEVEL, X, Y)
Definition: fatdata.h:313
PFCB FatGetNextFcbTopDown(IN PIRP_CONTEXT IrpContext, IN PFCB Fcb, IN PFCB TerminationFcb)
Definition: strucsup.c:2627
IN PFCB IN FAT_FLUSH_TYPE FlushType
Definition: fatprocs.h:1082
Definition: cdstruc.h:902
PVCB Vcb
Definition: cdstruc.h:933
UCHAR DirentFatFlags
Definition: fatstruc.h:1133
#define NT_ASSERT
Definition: rtlfuncs.h:3310

◆ FatDecodeFileObject()

TYPE_OF_OPEN FatDecodeFileObject ( _In_ PFILE_OBJECT  FileObject,
_Outptr_ PVCB Vcb,
_Outptr_ PFCB FcbOrDcb,
_Outptr_ PCCB Ccb 
)

Definition at line 176 of file filobsup.c.

227{
230 PVOID FsContext2;
231
232 PAGED_CODE();
233
234 DebugTrace(+1, Dbg, "FatDecodeFileObject, FileObject = %p\n", FileObject);
235
236 //
237 // Reference the fs context fields of the file object, and zero out
238 // the out pointer parameters.
239 //
240
241 FsContext = FileObject->FsContext;
242 FsContext2 = FileObject->FsContext2;
243
244 //
245 // Special case the situation where FsContext is null
246 //
247
248 if (FsContext == NULL) {
249
250 *Ccb = NULL;
251 *FcbOrDcb = NULL;
252 *Vcb = NULL;
253
255
256 } else {
257
258 //
259 // Now we can case on the node type code of the fscontext pointer
260 // and set the appropriate out pointers
261 //
262
263 switch (NodeType(FsContext)) {
264
265 case FAT_NTC_VCB:
266
267 *Ccb = FsContext2;
268 *FcbOrDcb = NULL;
269 *Vcb = FsContext;
270
272
273 break;
274
275 case FAT_NTC_ROOT_DCB:
276 case FAT_NTC_DCB:
277
278 *Ccb = FsContext2;
280 *Vcb = (*FcbOrDcb)->Vcb;
281
283
284 DebugTrace(0, Dbg, "Referencing directory: %wZ\n", &(*FcbOrDcb)->FullFileName);
285
286 break;
287
288 case FAT_NTC_FCB:
289
290 *Ccb = FsContext2;
292 *Vcb = (*FcbOrDcb)->Vcb;
293
294 if (*Ccb != NULL ) {
295
297 DebugTrace(0, Dbg, "Referencing file: %wZ\n", &(*FcbOrDcb)->FullFileName);
298
299 } else {
300
301 //
302 // No Ccb means this is a special open.
303 //
304
305
306 if ( *FcbOrDcb == (*Vcb)->EaFcb ) {
307
309 DebugTrace(0, Dbg, "Referencing EA file: %wZ\n", &(*FcbOrDcb)->FullFileName);
310
311 } else {
312
313#ifdef _MSC_VER
314#pragma prefast(suppress:28159, "things are seriously wrong if we get here")
315#endif
317
318 }
319
320 }
321
322 break;
323
324 default:
325
326#ifdef _MSC_VER
327#pragma prefast( suppress:28159, "things are seriously wrong if we get here" )
328#endif
330 }
331 }
332
333 //
334 // and return to our caller
335 //
336
337 DebugTrace(0, Dbg, "FatDecodeFileObject -> VCB(%p)\n", *Vcb);
338 DebugTrace(0, Dbg, "FatDecodeFileObject -> FCB(%p)\n", *FcbOrDcb);
339 DebugTrace(0, Dbg, "FatDecodeFileObject -> CCB(%p)\n", *Ccb);
340 DebugTrace(-1, Dbg, "FatDecodeFileObject -> TypeOfOpen = %08lx\n", TypeOfOpen);
341
342 return TypeOfOpen;
343}
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN TypeOfOpen
Definition: cdprocs.h:589
@ UnopenedFileObject
Definition: cdprocs.h:573
@ UserDirectoryOpen
Definition: cdprocs.h:576
@ UserFileOpen
Definition: cdprocs.h:577
@ UserVolumeOpen
Definition: cdprocs.h:575
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:592
enum _TYPE_OF_OPEN TYPE_OF_OPEN
#define NodeType(P)
Definition: nodetype.h:51
#define FAT_NTC_ROOT_DCB
Definition: nodetype.h:31
#define FAT_NTC_FCB
Definition: nodetype.h:29
#define FAT_NTC_DCB
Definition: nodetype.h:30
#define FAT_NTC_VCB
Definition: nodetype.h:28
#define FatBugCheck(A, B, C)
Definition: nodetype.h:104
@ DirectoryFile
Definition: fatprocs.h:1046
@ VirtualVolumeFile
Definition: fatprocs.h:1045
@ EaFile
Definition: fatprocs.h:1047
IN PFCB FcbOrDcb
Definition: fatprocs.h:306
_Inout_ PLIST_ENTRY _In_ PVOID FsContext
Definition: fltkernel.h:2239
#define Vcb
Definition: cdprocs.h:1415
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550

Referenced by _Function_class_(), _Requires_lock_held_(), FatAllowExtendedDasdIo(), FatCommonQueryEa(), FatCommonSetEa(), FatDeferredFlush(), FatFspDispatch(), FatIsVolumeDirty(), FatIsVolumeMounted(), FatSetRenameInfo(), FatSetZeroOnDeallocate(), and FatUnlockVolume().

◆ FatSetFileObject()

VOID FatSetFileObject ( IN PFILE_OBJECT FileObject  OPTIONAL,
IN TYPE_OF_OPEN  TypeOfOpen,
IN PVOID  VcbOrFcbOrDcb,
IN PCCB Ccb  OPTIONAL 
)

Definition at line 39 of file filobsup.c.

70{
71 PAGED_CODE();
72
73 DebugTrace(+1, Dbg, "FatSetFileObject, FileObject = %p\n", FileObject );
74
76
77
79
80 ||
81
83 (NodeType(VcbOrFcbOrDcb) == FAT_NTC_FCB) &&
84 (Ccb != NULL))
85
86 ||
87
88 ((TypeOfOpen == EaFile) &&
89 (NodeType(VcbOrFcbOrDcb) == FAT_NTC_FCB) &&
90 (Ccb == NULL))
91
92 ||
93
95 ((NodeType(VcbOrFcbOrDcb) == FAT_NTC_DCB) || (NodeType(VcbOrFcbOrDcb) == FAT_NTC_ROOT_DCB)) &&
96 (Ccb != NULL))
97
98 ||
99
101 (NodeType(VcbOrFcbOrDcb) == FAT_NTC_VCB) &&
102 (Ccb != NULL))
103
104 ||
105
107 (NodeType(VcbOrFcbOrDcb) == FAT_NTC_VCB) &&
108 (Ccb == NULL))
109
110 ||
111
113 ((NodeType(VcbOrFcbOrDcb) == FAT_NTC_DCB) || (NodeType(VcbOrFcbOrDcb) == FAT_NTC_ROOT_DCB)) &&
114 (Ccb == NULL))
115 );
116
117
119
120 //
121 // If we were given an Fcb, Dcb, or Vcb, we have some processing to do.
122 //
123
124 NT_ASSERT((Ccb == NULL) || (NodeType(Ccb) == FAT_NTC_CCB));
125
126 if ( VcbOrFcbOrDcb != NULL ) {
127
128 //
129 // Set the Vpb field in the file object, and if we were given an
130 // Fcb or Dcb move the field over to point to the nonpaged Fcb/Dcb
131 //
132
133 if (NodeType(VcbOrFcbOrDcb) == FAT_NTC_VCB) {
134
135 FileObject->Vpb = ((PVCB)VcbOrFcbOrDcb)->Vpb;
136
137 } else {
138
139 FileObject->Vpb = ((PFCB)VcbOrFcbOrDcb)->Vcb->Vpb;
140
141 //
142 // If this is a temporary file, note it in the FcbState
143 //
144
145 if (FlagOn(((PFCB)VcbOrFcbOrDcb)->FcbState, FCB_STATE_TEMPORARY)) {
146
148 }
149 }
150 }
151
152 NT_ASSERT((Ccb == NULL) || (NodeType(Ccb) == FAT_NTC_CCB));
153
154 //
155 // Now set the fscontext fields of the file object
156 //
157
159
160 FileObject->FsContext = VcbOrFcbOrDcb;
161 FileObject->FsContext2 = Ccb;
162 }
163
164 NT_ASSERT((Ccb == NULL) || (NodeType(Ccb) == FAT_NTC_CCB));
165
166 //
167 // And return to our caller
168 //
169
170 DebugTrace(-1, Dbg, "FatSetFileObject -> VOID\n", 0);
171
172 return;
173}
struct _VCB * PVCB
Definition: fatstruc.h:557
FCB * PFCB
Definition: cdstruc.h:1040
#define FAT_NTC_CCB
Definition: nodetype.h:32
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define FCB_STATE_TEMPORARY
Definition: fatstruc.h:1198
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define ARGUMENT_PRESENT(ArgumentPointer)
#define FO_TEMPORARY_FILE
Definition: iotypes.h:1791