352748f558ec5bd50d564e834d26638a2932f27d
[reactos.git] / reactos / sdk / include / ddk / fcb.h
1 #ifndef _FCB_STRUCTS_DEFINED_
2 #define _FCB_STRUCTS_DEFINED_
3
4 #include "buffring.h"
5
6 struct _FCB_INIT_PACKET;
7 typedef struct _FCB_INIT_PACKET *PFCB_INIT_PACKET;
8
9 typedef struct _SRV_CALL
10 {
11 union
12 {
13 MRX_SRV_CALL;
14 struct
15 {
16 MRX_NORMAL_NODE_HEADER spacer;
17 };
18 };
19 BOOLEAN UpperFinalizationDone;
20 RX_PREFIX_ENTRY PrefixEntry;
21 RX_BLOCK_CONDITION Condition;
22 ULONG SerialNumberForEnum;
23 volatile LONG NumberOfCloseDelayedFiles;
24 LIST_ENTRY TransitionWaitList;
25 LIST_ENTRY ScavengerFinalizationList;
26 PURGE_SYNCHRONIZATION_CONTEXT PurgeSyncronizationContext;
27 RX_BUFFERING_MANAGER BufferingManager;
28 } SRV_CALL, *PSRV_CALL;
29
30 #define NETROOT_FLAG_FINALIZATION_IN_PROGRESS 0x00040000
31 #define NETROOT_FLAG_NAME_ALREADY_REMOVED 0x00080000
32
33 typedef struct _NET_ROOT
34 {
35 union
36 {
37 MRX_NET_ROOT;
38 struct
39 {
40 MRX_NORMAL_NODE_HEADER spacer;
41 PSRV_CALL SrvCall;
42 };
43 };
44 BOOLEAN UpperFinalizationDone;
45 RX_BLOCK_CONDITION Condition;
46 LIST_ENTRY TransitionWaitList;
47 LIST_ENTRY ScavengerFinalizationList;
48 PURGE_SYNCHRONIZATION_CONTEXT PurgeSyncronizationContext;
49 PV_NET_ROOT DefaultVNetRoot;
50 LIST_ENTRY VirtualNetRoots;
51 ULONG NumberOfVirtualNetRoots;
52 ULONG SerialNumberForEnum;
53 RX_PREFIX_ENTRY PrefixEntry;
54 RX_FCB_TABLE FcbTable;
55 } NET_ROOT, *PNET_ROOT;
56
57 typedef struct _V_NET_ROOT
58 {
59 union
60 {
61 MRX_V_NET_ROOT;
62 struct
63 {
64 MRX_NORMAL_NODE_HEADER spacer;
65 PNET_ROOT NetRoot;
66 };
67 };
68 BOOLEAN UpperFinalizationDone;
69 BOOLEAN ConnectionFinalizationDone;
70 RX_BLOCK_CONDITION Condition;
71 volatile LONG AdditionalReferenceForDeleteFsctlTaken;
72 RX_PREFIX_ENTRY PrefixEntry;
73 UNICODE_STRING NamePrefix;
74 ULONG PrefixOffsetInBytes;
75 LIST_ENTRY NetRootListEntry;
76 ULONG SerialNumberForEnum;
77 LIST_ENTRY TransitionWaitList;
78 LIST_ENTRY ScavengerFinalizationList;
79 } V_NET_ROOT, *PV_NET_ROOT;
80
81 typedef struct _NON_PAGED_FCB
82 {
83 NODE_TYPE_CODE NodeTypeCode;
84 NODE_BYTE_SIZE NodeByteSize;
85 SECTION_OBJECT_POINTERS SectionObjectPointers;
86 ERESOURCE HeaderResource;
87 ERESOURCE PagingIoResource;
88 #ifdef USE_FILESIZE_LOCK
89 FAST_MUTEX FileSizeLock;
90 #endif
91 LIST_ENTRY TransitionWaitList;
92 ULONG OutstandingAsyncWrites;
93 PKEVENT OutstandingAsyncEvent;
94 KEVENT TheActualEvent;
95 PVOID MiniRdrContext[2];
96 FAST_MUTEX AdvancedFcbHeaderMutex;
97 ERESOURCE BufferedLocksResource;
98 #if DBG
99 PFCB FcbBackPointer;
100 #endif
101 } NON_PAGED_FCB, *PNON_PAGED_FCB;
102
103 typedef enum _RX_FCBTRACKER_CASES
104 {
105 RX_FCBTRACKER_CASE_NORMAL,
106 RX_FCBTRACKER_CASE_NULLCONTEXT,
107 RX_FCBTRACKER_CASE_CBS_CONTEXT,
108 RX_FCBTRACKER_CASE_CBS_WAIT_CONTEXT,
109 RX_FCBTRACKER_CASE_MAXIMUM
110 } RX_FCBTRACKER_CASES;
111
112 typedef struct _FCB_LOCK
113 {
114 struct _FCB_LOCK * Next;
115 LARGE_INTEGER Length;
116 LARGE_INTEGER BytesOffset;
117 ULONG Key;
118 BOOLEAN ExclusiveLock;
119 } FCB_LOCK, *PFCB_LOCK;
120
121 typedef struct _FCB_BUFFERED_LOCKS
122 {
123 struct _FCB_LOCK * List;
124 volatile ULONG PendingLockOps;
125 PERESOURCE Resource;
126 } FCB_BUFFERED_LOCKS, *PFCB_BUFFERED_LOCKS;
127
128 typedef struct _FCB
129 {
130 union
131 {
132 MRX_FCB;
133 struct
134 {
135 FSRTL_ADVANCED_FCB_HEADER spacer;
136 PNET_ROOT NetRoot;
137 };
138 };
139 PV_NET_ROOT VNetRoot;
140 PNON_PAGED_FCB NonPaged;
141 LIST_ENTRY ScavengerFinalizationList;
142 PKEVENT pBufferingStateChangeCompletedEvent;
143 LONG NumberOfBufferingStateChangeWaiters;
144 RX_FCB_TABLE_ENTRY FcbTableEntry;
145 UNICODE_STRING PrivateAlreadyPrefixedName;
146 BOOLEAN UpperFinalizationDone;
147 RX_BLOCK_CONDITION Condition;
148 PRX_FSD_DISPATCH_VECTOR PrivateDispatchVector;
149 PRDBSS_DEVICE_OBJECT RxDeviceObject;
150 PMINIRDR_DISPATCH MRxDispatch;
151 PFAST_IO_DISPATCH MRxFastIoDispatch;
152 PSRV_OPEN InternalSrvOpen;
153 PFOBX InternalFobx;
154 SHARE_ACCESS ShareAccess;
155 SHARE_ACCESS ShareAccessPerSrvOpens;
156 ULONG NumberOfLinks;
157 LARGE_INTEGER CreationTime;
158 LARGE_INTEGER LastAccessTime;
159 LARGE_INTEGER LastWriteTime;
160 LARGE_INTEGER LastChangeTime;
161 #if (_WIN32_WINNT < 0x0600)
162 PETHREAD CreateSectionThread;
163 #endif
164 ULONG ulFileSizeVersion;
165 #if (_WIN32_WINNT < 0x0600)
166 union
167 {
168 struct
169 {
170 #endif
171 FILE_LOCK FileLock;
172 #if (_WIN32_WINNT < 0x0600)
173 PVOID LazyWriteThread;
174 #endif
175 union
176 {
177 LOWIO_PER_FCB_INFO;
178 LOWIO_PER_FCB_INFO LowIoPerFcbInfo;
179 };
180 #ifdef USE_FILESIZE_LOCK
181 PFAST_MUTEX FileSizeLock;
182 #endif
183 #if (_WIN32_WINNT < 0x0600)
184 } Fcb;
185 } Specific;
186 #endif
187 ULONG EaModificationCount;
188 FCB_BUFFERED_LOCKS BufferedLocks;
189 #if DBG
190 PNON_PAGED_FCB CopyOfNonPaged;
191 #endif
192 #ifdef RDBSS_TRACKER
193 ULONG FcbAcquires[RX_FCBTRACKER_CASE_MAXIMUM];
194 ULONG FcbReleases[RX_FCBTRACKER_CASE_MAXIMUM];
195 #else
196 #error tracker must be defined
197 #endif
198 PCHAR PagingIoResourceFile;
199 ULONG PagingIoResourceLine;
200 } FCB, *PFCB;
201
202 #define FCB_STATE_DELETE_ON_CLOSE 0x00000001
203 #define FCB_STATE_PAGING_FILE 0x00000004
204 #define FCB_STATE_DISABLE_LOCAL_BUFFERING 0x00000010
205 #define FCB_STATE_TEMPORARY 0x00000020
206 #define FCB_STATE_BUFFERING_STATE_CHANGE_PENDING 0x00000040
207 #define FCB_STATE_ORPHANED 0x00000080
208 #define FCB_STATE_READAHEAD_DEFERRED 0x00000100
209 #define FCB_STATE_DELAY_CLOSE 0x00000800
210 #define FCB_STATE_FAKEFCB 0x00001000
211 #define FCB_STATE_FILE_IS_BUF_COMPRESSED 0x00004000
212 #define FCB_STATE_FILE_IS_DISK_COMPRESSED 0x00008000
213 #define FCB_STATE_FILE_IS_SHADOWED 0x00010000
214 #define FCB_STATE_BUFFERSTATE_CHANGING 0x00002000
215 #define FCB_STATE_SPECIAL_PATH 0x00020000
216 #define FCB_STATE_TIME_AND_SIZE_ALREADY_SET 0x00040000
217 #define FCB_STATE_FILETIMECACHEING_ENABLED 0x00080000
218 #define FCB_STATE_FILESIZECACHEING_ENABLED 0x00100000
219 #define FCB_STATE_LOCK_BUFFERING_ENABLED 0x00200000
220 #define FCB_STATE_COLLAPSING_ENABLED 0x00400000
221 #define FCB_STATE_OPENSHARING_ENABLED 0x00800000
222 #define FCB_STATE_READBUFFERING_ENABLED 0x01000000
223 #define FCB_STATE_READCACHING_ENABLED 0x02000000
224 #define FCB_STATE_WRITEBUFFERING_ENABLED 0x04000000
225 #define FCB_STATE_WRITECACHING_ENABLED 0x08000000
226 #define FCB_STATE_NAME_ALREADY_REMOVED 0x10000000
227 #define FCB_STATE_ADDEDBACKSLASH 0x20000000
228 #define FCB_STATE_FOBX_USED 0x40000000
229 #define FCB_STATE_SRVOPEN_USED 0x80000000
230
231 #define FCB_STATE_BUFFERING_STATE_MASK \
232 ((FCB_STATE_WRITECACHING_ENABLED \
233 | FCB_STATE_WRITEBUFFERING_ENABLED \
234 | FCB_STATE_READCACHING_ENABLED \
235 | FCB_STATE_READBUFFERING_ENABLED \
236 | FCB_STATE_OPENSHARING_ENABLED \
237 | FCB_STATE_COLLAPSING_ENABLED \
238 | FCB_STATE_LOCK_BUFFERING_ENABLED \
239 | FCB_STATE_FILESIZECACHEING_ENABLED \
240 | FCB_STATE_FILETIMECACHEING_ENABLED))
241
242 typedef struct _FCB_INIT_PACKET
243 {
244 PULONG pAttributes;
245 PULONG pNumLinks;
246 PLARGE_INTEGER pCreationTime;
247 PLARGE_INTEGER pLastAccessTime;
248 PLARGE_INTEGER pLastWriteTime;
249 PLARGE_INTEGER pLastChangeTime;
250 PLARGE_INTEGER pAllocationSize;
251 PLARGE_INTEGER pFileSize;
252 PLARGE_INTEGER pValidDataLength;
253 } FCB_INIT_PACKET;
254
255 #define SRVOPEN_FLAG_ENCLOSED_ALLOCATED 0x10000
256 #define SRVOPEN_FLAG_FOBX_USED 0x20000
257 #define SRVOPEN_FLAG_SHAREACCESS_UPDATED 0x40000
258
259 typedef struct _SRV_OPEN
260 {
261 union
262 {
263 MRX_SRV_OPEN;
264 struct
265 {
266 MRX_NORMAL_NODE_HEADER spacer;
267 PFCB Fcb;
268 #if (_WIN32_WINNT >= 0x600)
269 PV_NET_ROOT VNetRoot;
270 #endif
271 };
272 };
273 BOOLEAN UpperFinalizationDone;
274 RX_BLOCK_CONDITION Condition;
275 volatile LONG BufferingToken;
276 LIST_ENTRY ScavengerFinalizationList;
277 LIST_ENTRY TransitionWaitList;
278 LIST_ENTRY FobxList;
279 PFOBX InternalFobx;
280 union
281 {
282 LIST_ENTRY SrvOpenKeyList;
283 ULONG SequenceNumber;
284 };
285 NTSTATUS OpenStatus;
286 } SRV_OPEN, *PSRV_OPEN;
287
288 #define FOBX_FLAG_MATCH_ALL 0x10000
289 #define FOBX_FLAG_FREE_UNICODE 0x20000
290 #define FOBX_FLAG_DELETE_ON_CLOSE 0x800000
291 #define FOBX_FLAG_SRVOPEN_CLOSED 0x1000000
292 #define FOBX_FLAG_UNC_NAME 0x2000000
293 #define FOBX_FLAG_ENCLOSED_ALLOCATED 0x4000000
294 #define FOBX_FLAG_MARKED_AS_DORMANT 0x8000000
295
296 typedef struct _FOBX
297 {
298 union
299 {
300 MRX_FOBX;
301 struct
302 {
303 MRX_NORMAL_NODE_HEADER spacer;
304 PSRV_OPEN SrvOpen;
305 };
306 };
307 volatile ULONG FobxSerialNumber;
308 LIST_ENTRY FobxQLinks;
309 LIST_ENTRY ScavengerFinalizationList;
310 LIST_ENTRY ClosePendingList;
311 LARGE_INTEGER CloseTime;
312 BOOLEAN UpperFinalizationDone;
313 BOOLEAN ContainsWildCards;
314 BOOLEAN fOpenCountDecremented;
315 union
316 {
317 struct
318 {
319 union
320 {
321 MRX_PIPE_HANDLE_INFORMATION;
322 MRX_PIPE_HANDLE_INFORMATION PipeHandleInformation;
323 };
324 LARGE_INTEGER CollectDataTime;
325 ULONG CollectDataSize;
326 THROTTLING_STATE ThrottlingState;
327 LIST_ENTRY ReadSerializationQueue;
328 LIST_ENTRY WriteSerializationQueue;
329 } NamedPipe;
330 struct {
331 RXVBO PredictedReadOffset;
332 RXVBO PredictedWriteOffset;
333 THROTTLING_STATE LockThrottlingState;
334 LARGE_INTEGER LastLockOffset;
335 LARGE_INTEGER LastLockRange;
336 } DiskFile;
337 } Specific;
338 PRDBSS_DEVICE_OBJECT RxDeviceObject;
339 } FOBX, *PFOBX;
340
341 #define RDBSS_REF_TRACK_SRVCALL 0x00000001
342 #define RDBSS_REF_TRACK_NETROOT 0x00000002
343 #define RDBSS_REF_TRACK_VNETROOT 0x00000004
344 #define RDBSS_REF_TRACK_NETFOBX 0x00000008
345 #define RDBSS_REF_TRACK_NETFCB 0x00000010
346 #define RDBSS_REF_TRACK_SRVOPEN 0x00000020
347 #define RX_PRINT_REF_TRACKING 0x40000000
348
349 extern ULONG RdbssReferenceTracingValue;
350
351 VOID
352 RxpTrackReference(
353 _In_ ULONG TraceType,
354 _In_ PCSTR FileName,
355 _In_ ULONG Line,
356 _In_ PVOID Instance);
357
358 BOOLEAN
359 RxpTrackDereference(
360 _In_ ULONG TraceType,
361 _In_ PCSTR FileName,
362 _In_ ULONG Line,
363 _In_ PVOID Instance);
364
365 #define REF_TRACING_ON(TraceMask) (TraceMask & RdbssReferenceTracingValue)
366 #define PRINT_REF_COUNT(TYPE, Count) \
367 if (REF_TRACING_ON( RDBSS_REF_TRACK_ ## TYPE) && \
368 (RdbssReferenceTracingValue & RX_PRINT_REF_TRACKING)) \
369 { \
370 DbgPrint("%ld\n", Count); \
371 }
372
373 #define RxReferenceSrvCall(SrvCall) \
374 RxpTrackReference(RDBSS_REF_TRACK_SRVCALL, __FILE__, __LINE__, SrvCall); \
375 RxReference(SrvCall)
376
377 #define RxDereferenceSrvCall(SrvCall, LockHoldingState) \
378 RxpTrackDereference(RDBSS_REF_TRACK_SRVCALL, __FILE__, __LINE__, SrvCall); \
379 RxDereference(SrvCall, LockHoldingState)
380
381 #define RxReferenceNetRoot(NetRoot) \
382 RxpTrackReference(RDBSS_REF_TRACK_NETROOT, __FILE__, __LINE__, NetRoot); \
383 RxReference(NetRoot)
384
385 #define RxDereferenceNetRoot(NetRoot, LockHoldingState) \
386 RxpTrackDereference(RDBSS_REF_TRACK_NETROOT, __FILE__, __LINE__, NetRoot); \
387 RxDereference(NetRoot, LockHoldingState)
388
389 #define RxReferenceVNetRoot(VNetRoot) \
390 RxpTrackReference(RDBSS_REF_TRACK_VNETROOT, __FILE__, __LINE__, VNetRoot); \
391 RxReference(VNetRoot)
392
393 #define RxDereferenceVNetRoot(VNetRoot, LockHoldingState) \
394 RxpTrackDereference(RDBSS_REF_TRACK_VNETROOT, __FILE__, __LINE__, VNetRoot); \
395 RxDereference(VNetRoot, LockHoldingState)
396
397 #define RxReferenceNetFobx(Fobx) \
398 RxpTrackReference(RDBSS_REF_TRACK_NETFOBX, __FILE__, __LINE__, Fobx); \
399 RxReference(Fobx)
400
401 #define RxDereferenceNetFobx(Fobx, LockHoldingState) \
402 RxpTrackDereference(RDBSS_REF_TRACK_NETFOBX, __FILE__, __LINE__, Fobx); \
403 RxDereference(Fobx, LockHoldingState)
404
405 #define RxReferenceSrvOpen(SrvOpen) \
406 RxpTrackReference(RDBSS_REF_TRACK_SRVOPEN, __FILE__, __LINE__, SrvOpen); \
407 RxReference(SrvOpen)
408
409 #define RxDereferenceSrvOpen(SrvOpen, LockHoldingState) \
410 RxpTrackDereference(RDBSS_REF_TRACK_SRVOPEN, __FILE__, __LINE__, SrvOpen); \
411 RxDereference(SrvOpen, LockHoldingState)
412
413 #define RxReferenceNetFcb(Fcb) \
414 (RxpTrackReference(RDBSS_REF_TRACK_NETFCB, __FILE__, __LINE__, Fcb), \
415 RxpReferenceNetFcb(Fcb))
416
417 #define RxDereferenceNetFcb(Fcb) \
418 ((LONG)RxpTrackDereference(RDBSS_REF_TRACK_NETFCB, __FILE__, __LINE__, Fcb), \
419 RxpDereferenceNetFcb(Fcb))
420
421 #define RxDereferenceAndFinalizeNetFcb(Fcb, RxContext, RecursiveFinalize, ForceFinalize) \
422 (RxpTrackDereference(RDBSS_REF_TRACK_NETFCB, __FILE__, __LINE__, Fcb), \
423 RxpDereferenceAndFinalizeNetFcb(Fcb, RxContext, RecursiveFinalize, ForceFinalize))
424
425 PSRV_CALL
426 RxCreateSrvCall(
427 _In_ PRX_CONTEXT RxContext,
428 _In_ PUNICODE_STRING Name,
429 _In_opt_ PUNICODE_STRING InnerNamePrefix,
430 _In_ PRX_CONNECTION_ID RxConnectionId);
431
432 #define RxWaitForStableSrvCall(S, R) RxWaitForStableCondition(&(S)->Condition, &(S)->TransitionWaitList, (R), NULL)
433 #define RxTransitionSrvCall(S, C) RxUpdateCondition((C), &(S)->Condition, &(S)->TransitionWaitList)
434
435 #if (_WIN32_WINNT >= 0x0600)
436 BOOLEAN
437 RxFinalizeSrvCall(
438 _Out_ PSRV_CALL ThisSrvCall,
439 _In_ BOOLEAN ForceFinalize);
440 #else
441 BOOLEAN
442 RxFinalizeSrvCall(
443 _Out_ PSRV_CALL ThisSrvCall,
444 _In_ BOOLEAN RecursiveFinalize,
445 _In_ BOOLEAN ForceFinalize);
446 #endif
447
448 PNET_ROOT
449 RxCreateNetRoot(
450 _In_ PSRV_CALL SrvCall,
451 _In_ PUNICODE_STRING Name,
452 _In_ ULONG NetRootFlags,
453 _In_opt_ PRX_CONNECTION_ID RxConnectionId);
454
455 #define RxWaitForStableNetRoot(N, R) RxWaitForStableCondition(&(N)->Condition, &(N)->TransitionWaitList, (R), NULL)
456 #define RxTransitionNetRoot(N, C) RxUpdateCondition((C), &(N)->Condition, &(N)->TransitionWaitList)
457
458 BOOLEAN
459 RxFinalizeNetRoot(
460 _Out_ PNET_ROOT ThisNetRoot,
461 _In_ BOOLEAN RecursiveFinalize,
462 _In_ BOOLEAN ForceFinalize);
463
464 NTSTATUS
465 RxInitializeVNetRootParameters(
466 _In_ PRX_CONTEXT RxContext,
467 _Out_ LUID *LogonId,
468 _Out_ PULONG SessionId,
469 _Out_ PUNICODE_STRING *UserNamePtr,
470 _Out_ PUNICODE_STRING *UserDomainNamePtr,
471 _Out_ PUNICODE_STRING *PasswordPtr,
472 _Out_ PULONG Flags);
473
474 VOID
475 RxUninitializeVNetRootParameters(
476 _In_ PUNICODE_STRING UserName,
477 _In_ PUNICODE_STRING UserDomainName,
478 _In_ PUNICODE_STRING Password,
479 _Out_ PULONG Flags);
480
481 PV_NET_ROOT
482 RxCreateVNetRoot(
483 _In_ PRX_CONTEXT RxContext,
484 _In_ PNET_ROOT NetRoot,
485 _In_ PUNICODE_STRING CanonicalName,
486 _In_ PUNICODE_STRING LocalNetRootName,
487 _In_ PUNICODE_STRING FilePath,
488 _In_ PRX_CONNECTION_ID RxConnectionId);
489
490 BOOLEAN
491 RxFinalizeVNetRoot(
492 _Out_ PV_NET_ROOT ThisVNetRoot,
493 _In_ BOOLEAN RecursiveFinalize,
494 _In_ BOOLEAN ForceFinalize);
495
496 #define RxWaitForStableVNetRoot(V, R) RxWaitForStableCondition(&(V)->Condition, &(V)->TransitionWaitList, (R), NULL)
497 #define RxTransitionVNetRoot(V, C) RxUpdateCondition((C), &(V)->Condition, &(V)->TransitionWaitList)
498
499 VOID
500 RxGetFileSizeWithLock(
501 _In_ PFCB Fcb,
502 _Out_ PLONGLONG FileSize);
503
504 #if (_WIN32_WINNT >= 0x0600)
505 RxCreateNetFcb(
506 _In_ PRX_CONTEXT RxContext,
507 _In_ PIRP Irp,
508 _In_ PV_NET_ROOT VNetRoot,
509 _In_ PUNICODE_STRING Name);
510 #else
511 PFCB
512 RxCreateNetFcb(
513 _In_ PRX_CONTEXT RxContext,
514 _In_ PV_NET_ROOT VNetRoot,
515 _In_ PUNICODE_STRING Name);
516 #endif
517
518 #define RxWaitForStableNetFcb(F, R) RxWaitForStableCondition(&(F)->Condition, &(F)->NonPaged->TransitionWaitList, (R), NULL )
519 #define RxTransitionNetFcb(F, C) RxUpdateCondition((C), &(F)->Condition, &(F)->NonPaged->TransitionWaitList)
520
521 #define RxFormInitPacket(IP, I1, I1a, I2, I3, I4a, I4b, I5, I6, I7) ( \
522 IP.pAttributes = I1, IP.pNumLinks = I1a, \
523 IP.pCreationTime = I2, IP.pLastAccessTime = I3, \
524 IP.pLastWriteTime = I4a, IP.pLastChangeTime = I4b, \
525 IP.pAllocationSize = I5, IP.pFileSize = I6, \
526 IP.pValidDataLength = I7, &IP)
527
528 #if DBG
529 #define ASSERT_CORRECT_FCB_STRUCTURE_DBG_ONLY(Fcb) \
530 { \
531 ASSERT(Fcb->NonPaged == Fcb->CopyOfNonPaged); \
532 ASSERT(Fcb->NonPaged->FcbBackPointer == Fcb); \
533 }
534 #else
535 #define ASSERT_CORRECT_FCB_STRUCTURE_DBG_ONLY(Fcb)
536 #endif
537
538 #define ASSERT_CORRECT_FCB_STRUCTURE(Fcb) \
539 { \
540 ASSERT(NodeTypeIsFcb(Fcb)); \
541 ASSERT(Fcb->NonPaged != NULL ); \
542 ASSERT(NodeType(Fcb->NonPaged) == RDBSS_NTC_NONPAGED_FCB); \
543 ASSERT_CORRECT_FCB_STRUCTURE_DBG_ONLY(Fcb); \
544 }
545
546 VOID
547 NTAPI
548 RxFinishFcbInitialization(
549 _In_ OUT PMRX_FCB Fcb,
550 _In_ RX_FILE_TYPE FileType,
551 _In_opt_ PFCB_INIT_PACKET InitPacket);
552
553 #define RxWaitForStableSrvOpen(S, R) RxWaitForStableCondition(&(S)->Condition, &(S)->TransitionWaitList, (R), NULL)
554 #define RxTransitionSrvOpen(S, C) RxUpdateCondition((C), &(S)->Condition, &(S)->TransitionWaitList)
555
556 VOID
557 RxRemoveNameNetFcb(
558 _Out_ PFCB ThisFcb);
559
560 LONG
561 RxpReferenceNetFcb(
562 _In_ PFCB Fcb);
563
564 LONG
565 RxpDereferenceNetFcb(
566 _In_ PFCB Fcb);
567
568 BOOLEAN
569 RxpDereferenceAndFinalizeNetFcb(
570 _Out_ PFCB ThisFcb,
571 _In_ PRX_CONTEXT RxContext,
572 _In_ BOOLEAN RecursiveFinalize,
573 _In_ BOOLEAN ForceFinalize);
574
575 PSRV_OPEN
576 RxCreateSrvOpen(
577 _In_ PV_NET_ROOT VNetRoot,
578 _In_ OUT PFCB Fcb);
579
580 BOOLEAN
581 RxFinalizeSrvOpen(
582 _Out_ PSRV_OPEN ThisSrvOpen,
583 _In_ BOOLEAN RecursiveFinalize,
584 _In_ BOOLEAN ForceFinalize);
585
586 FORCEINLINE
587 PUNICODE_STRING
588 GET_ALREADY_PREFIXED_NAME(
589 PMRX_SRV_OPEN SrvOpen,
590 PMRX_FCB Fcb)
591 {
592 PFCB ThisFcb = (PFCB)Fcb;
593
594 #if DBG
595 if (SrvOpen != NULL)
596 {
597 ASSERT(NodeType(SrvOpen) == RDBSS_NTC_SRVOPEN);
598 ASSERT(ThisFcb != NULL);
599 ASSERT(NodeTypeIsFcb(Fcb));
600 ASSERT(SrvOpen->pFcb == Fcb);
601 ASSERT(SrvOpen->pAlreadyPrefixedName == &ThisFcb->PrivateAlreadyPrefixedName);
602 }
603 #endif
604
605 return &ThisFcb->PrivateAlreadyPrefixedName;
606 }
607 #define GET_ALREADY_PREFIXED_NAME_FROM_CONTEXT(Rxcontext) GET_ALREADY_PREFIXED_NAME((Rxcontext)->pRelevantSrvOpen, (Rxcontext)->pFcb)
608
609 PMRX_FOBX
610 NTAPI
611 RxCreateNetFobx(
612 _Out_ PRX_CONTEXT RxContext,
613 _In_ PMRX_SRV_OPEN MrxSrvOpen);
614
615 BOOLEAN
616 RxFinalizeNetFobx(
617 _Out_ PFOBX ThisFobx,
618 _In_ BOOLEAN RecursiveFinalize,
619 _In_ BOOLEAN ForceFinalize);
620
621 #ifdef __REACTOS__
622 #define FILL_IN_FCB(Fcb, a, nl, ct, lat, lwt, lct, as, fs, vdl) \
623 (Fcb)->Attributes = a; \
624 (Fcb)->NumberOfLinks = nl; \
625 (Fcb)->CreationTime.QuadPart = ct; \
626 (Fcb)->LastAccessTime.QuadPart = lat; \
627 (Fcb)->LastWriteTime.QuadPart = lwt; \
628 (Fcb)->LastChangeTime.QuadPart = lct; \
629 (Fcb)->ActualAllocationLength = as; \
630 (Fcb)->Header.AllocationSize.QuadPart = as; \
631 (Fcb)->Header.FileSize.QuadPart = fs; \
632 (Fcb)->Header.ValidDataLength.QuadPart = vdl; \
633 (Fcb)->FcbState |= FCB_STATE_TIME_AND_SIZE_ALREADY_SET
634
635 #define TRACKER_ACQUIRE_FCB 0x61616161
636 #define TRACKER_RELEASE_FCB_NO_BUFF_PENDING 0x72727272
637 #define TRACKER_RELEASE_NON_EXCL_FCB_BUFF_PENDING 0x72727230
638 #define TRACKER_RELEASE_EXCL_FCB_BUFF_PENDING 0x72727231
639 #define TRACKER_RELEASE_FCB_FOR_THRD_NO_BUFF_PENDING 0x72727474
640 #define TRACKER_RELEASE_NON_EXCL_FCB_FOR_THRD_BUFF_PENDING 0x72727430
641 #define TRACKER_RELEASE_EXCL_FCB_FOR_THRD_BUFF_PENDING 0x72727431
642 #define TRACKER_FCB_FREE 0x72724372
643
644 #define FCB_STATE_BUFFERING_STATE_WITH_NO_SHARES \
645 (( FCB_STATE_WRITECACHING_ENABLED \
646 | FCB_STATE_WRITEBUFFERING_ENABLED \
647 | FCB_STATE_READCACHING_ENABLED \
648 | FCB_STATE_READBUFFERING_ENABLED \
649 | FCB_STATE_LOCK_BUFFERING_ENABLED \
650 | FCB_STATE_FILESIZECACHEING_ENABLED \
651 | FCB_STATE_FILETIMECACHEING_ENABLED))
652
653 #endif
654
655 #endif