[RDBSS]
[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_TRUNCATE_ON_CLOSE 0x00000002
204 #define FCB_STATE_PAGING_FILE 0x00000004
205 #define FCB_STATE_DISABLE_LOCAL_BUFFERING 0x00000010
206 #define FCB_STATE_TEMPORARY 0x00000020
207 #define FCB_STATE_BUFFERING_STATE_CHANGE_PENDING 0x00000040
208 #define FCB_STATE_ORPHANED 0x00000080
209 #define FCB_STATE_READAHEAD_DEFERRED 0x00000100
210 #define FCB_STATE_DELAY_CLOSE 0x00000800
211 #define FCB_STATE_FAKEFCB 0x00001000
212 #define FCB_STATE_FILE_IS_BUF_COMPRESSED 0x00004000
213 #define FCB_STATE_FILE_IS_DISK_COMPRESSED 0x00008000
214 #define FCB_STATE_FILE_IS_SHADOWED 0x00010000
215 #define FCB_STATE_BUFFERSTATE_CHANGING 0x00002000
216 #define FCB_STATE_SPECIAL_PATH 0x00020000
217 #define FCB_STATE_TIME_AND_SIZE_ALREADY_SET 0x00040000
218 #define FCB_STATE_FILETIMECACHEING_ENABLED 0x00080000
219 #define FCB_STATE_FILESIZECACHEING_ENABLED 0x00100000
220 #define FCB_STATE_LOCK_BUFFERING_ENABLED 0x00200000
221 #define FCB_STATE_COLLAPSING_ENABLED 0x00400000
222 #define FCB_STATE_OPENSHARING_ENABLED 0x00800000
223 #define FCB_STATE_READBUFFERING_ENABLED 0x01000000
224 #define FCB_STATE_READCACHING_ENABLED 0x02000000
225 #define FCB_STATE_WRITEBUFFERING_ENABLED 0x04000000
226 #define FCB_STATE_WRITECACHING_ENABLED 0x08000000
227 #define FCB_STATE_NAME_ALREADY_REMOVED 0x10000000
228 #define FCB_STATE_ADDEDBACKSLASH 0x20000000
229 #define FCB_STATE_FOBX_USED 0x40000000
230 #define FCB_STATE_SRVOPEN_USED 0x80000000
231
232 #define FCB_STATE_BUFFERING_STATE_MASK \
233 ((FCB_STATE_WRITECACHING_ENABLED \
234 | FCB_STATE_WRITEBUFFERING_ENABLED \
235 | FCB_STATE_READCACHING_ENABLED \
236 | FCB_STATE_READBUFFERING_ENABLED \
237 | FCB_STATE_OPENSHARING_ENABLED \
238 | FCB_STATE_COLLAPSING_ENABLED \
239 | FCB_STATE_LOCK_BUFFERING_ENABLED \
240 | FCB_STATE_FILESIZECACHEING_ENABLED \
241 | FCB_STATE_FILETIMECACHEING_ENABLED))
242
243 typedef struct _FCB_INIT_PACKET
244 {
245 PULONG pAttributes;
246 PULONG pNumLinks;
247 PLARGE_INTEGER pCreationTime;
248 PLARGE_INTEGER pLastAccessTime;
249 PLARGE_INTEGER pLastWriteTime;
250 PLARGE_INTEGER pLastChangeTime;
251 PLARGE_INTEGER pAllocationSize;
252 PLARGE_INTEGER pFileSize;
253 PLARGE_INTEGER pValidDataLength;
254 } FCB_INIT_PACKET;
255
256 #define SRVOPEN_FLAG_ENCLOSED_ALLOCATED 0x10000
257 #define SRVOPEN_FLAG_FOBX_USED 0x20000
258 #define SRVOPEN_FLAG_SHAREACCESS_UPDATED 0x40000
259
260 typedef struct _SRV_OPEN
261 {
262 union
263 {
264 MRX_SRV_OPEN;
265 struct
266 {
267 MRX_NORMAL_NODE_HEADER spacer;
268 PFCB Fcb;
269 #if (_WIN32_WINNT >= 0x600)
270 PV_NET_ROOT VNetRoot;
271 #endif
272 };
273 };
274 BOOLEAN UpperFinalizationDone;
275 RX_BLOCK_CONDITION Condition;
276 volatile LONG BufferingToken;
277 LIST_ENTRY ScavengerFinalizationList;
278 LIST_ENTRY TransitionWaitList;
279 LIST_ENTRY FobxList;
280 PFOBX InternalFobx;
281 union
282 {
283 LIST_ENTRY SrvOpenKeyList;
284 ULONG SequenceNumber;
285 };
286 NTSTATUS OpenStatus;
287 } SRV_OPEN, *PSRV_OPEN;
288
289 #define FOBX_FLAG_MATCH_ALL 0x10000
290 #define FOBX_FLAG_FREE_UNICODE 0x20000
291 #define FOBX_FLAG_USER_SET_LAST_WRITE 0x40000
292 #define FOBX_FLAG_USER_SET_LAST_ACCESS 0x80000
293 #define FOBX_FLAG_USER_SET_LAST_CHANGE 0x200000
294 #define FOBX_FLAG_DELETE_ON_CLOSE 0x800000
295 #define FOBX_FLAG_SRVOPEN_CLOSED 0x1000000
296 #define FOBX_FLAG_UNC_NAME 0x2000000
297 #define FOBX_FLAG_ENCLOSED_ALLOCATED 0x4000000
298 #define FOBX_FLAG_MARKED_AS_DORMANT 0x8000000
299 #ifdef __REACTOS__
300 #define FOBX_FLAG_DISABLE_COLLAPSING 0x20000000
301 #endif
302
303 typedef struct _FOBX
304 {
305 union
306 {
307 MRX_FOBX;
308 struct
309 {
310 MRX_NORMAL_NODE_HEADER spacer;
311 PSRV_OPEN SrvOpen;
312 };
313 };
314 volatile ULONG FobxSerialNumber;
315 LIST_ENTRY FobxQLinks;
316 LIST_ENTRY ScavengerFinalizationList;
317 LIST_ENTRY ClosePendingList;
318 LARGE_INTEGER CloseTime;
319 BOOLEAN UpperFinalizationDone;
320 BOOLEAN ContainsWildCards;
321 BOOLEAN fOpenCountDecremented;
322 union
323 {
324 struct
325 {
326 union
327 {
328 MRX_PIPE_HANDLE_INFORMATION;
329 MRX_PIPE_HANDLE_INFORMATION PipeHandleInformation;
330 };
331 LARGE_INTEGER CollectDataTime;
332 ULONG CollectDataSize;
333 THROTTLING_STATE ThrottlingState;
334 LIST_ENTRY ReadSerializationQueue;
335 LIST_ENTRY WriteSerializationQueue;
336 } NamedPipe;
337 struct {
338 RXVBO PredictedReadOffset;
339 RXVBO PredictedWriteOffset;
340 THROTTLING_STATE LockThrottlingState;
341 LARGE_INTEGER LastLockOffset;
342 LARGE_INTEGER LastLockRange;
343 } DiskFile;
344 } Specific;
345 PRDBSS_DEVICE_OBJECT RxDeviceObject;
346 } FOBX, *PFOBX;
347
348 #define RDBSS_REF_TRACK_SRVCALL 0x00000001
349 #define RDBSS_REF_TRACK_NETROOT 0x00000002
350 #define RDBSS_REF_TRACK_VNETROOT 0x00000004
351 #define RDBSS_REF_TRACK_NETFOBX 0x00000008
352 #define RDBSS_REF_TRACK_NETFCB 0x00000010
353 #define RDBSS_REF_TRACK_SRVOPEN 0x00000020
354 #define RX_PRINT_REF_TRACKING 0x40000000
355 #define RX_LOG_REF_TRACKING 0x80000000
356
357 extern ULONG RdbssReferenceTracingValue;
358
359 VOID
360 RxpTrackReference(
361 _In_ ULONG TraceType,
362 _In_ PCSTR FileName,
363 _In_ ULONG Line,
364 _In_ PVOID Instance);
365
366 BOOLEAN
367 RxpTrackDereference(
368 _In_ ULONG TraceType,
369 _In_ PCSTR FileName,
370 _In_ ULONG Line,
371 _In_ PVOID Instance);
372
373 #define REF_TRACING_ON(TraceMask) (TraceMask & RdbssReferenceTracingValue)
374 #ifndef __REACTOS__
375 #define PRINT_REF_COUNT(TYPE, Count) \
376 if (REF_TRACING_ON( RDBSS_REF_TRACK_ ## TYPE) && \
377 (RdbssReferenceTracingValue & RX_PRINT_REF_TRACKING)) \
378 { \
379 DbgPrint("%ld\n", Count); \
380 }
381 #else
382 #define PRINT_REF_COUNT(TYPE, Count) \
383 if (REF_TRACING_ON( RDBSS_REF_TRACK_ ## TYPE) && \
384 (RdbssReferenceTracingValue & RX_PRINT_REF_TRACKING)) \
385 { \
386 DbgPrint("(%s:%d) %s: %ld\n", __FILE__, __LINE__, #TYPE, Count); \
387 }
388 #endif
389
390 #define RxReferenceSrvCall(SrvCall) \
391 RxpTrackReference(RDBSS_REF_TRACK_SRVCALL, __FILE__, __LINE__, SrvCall); \
392 RxReference(SrvCall)
393
394 #define RxDereferenceSrvCall(SrvCall, LockHoldingState) \
395 RxpTrackDereference(RDBSS_REF_TRACK_SRVCALL, __FILE__, __LINE__, SrvCall); \
396 RxDereference(SrvCall, LockHoldingState)
397
398 #define RxReferenceNetRoot(NetRoot) \
399 RxpTrackReference(RDBSS_REF_TRACK_NETROOT, __FILE__, __LINE__, NetRoot); \
400 RxReference(NetRoot)
401
402 #define RxDereferenceNetRoot(NetRoot, LockHoldingState) \
403 RxpTrackDereference(RDBSS_REF_TRACK_NETROOT, __FILE__, __LINE__, NetRoot); \
404 RxDereference(NetRoot, LockHoldingState)
405
406 #define RxReferenceVNetRoot(VNetRoot) \
407 RxpTrackReference(RDBSS_REF_TRACK_VNETROOT, __FILE__, __LINE__, VNetRoot); \
408 RxReference(VNetRoot)
409
410 #define RxDereferenceVNetRoot(VNetRoot, LockHoldingState) \
411 RxpTrackDereference(RDBSS_REF_TRACK_VNETROOT, __FILE__, __LINE__, VNetRoot); \
412 RxDereference(VNetRoot, LockHoldingState)
413
414 #define RxReferenceNetFobx(Fobx) \
415 RxpTrackReference(RDBSS_REF_TRACK_NETFOBX, __FILE__, __LINE__, Fobx); \
416 RxReference(Fobx)
417
418 #define RxDereferenceNetFobx(Fobx, LockHoldingState) \
419 RxpTrackDereference(RDBSS_REF_TRACK_NETFOBX, __FILE__, __LINE__, Fobx); \
420 RxDereference(Fobx, LockHoldingState)
421
422 #define RxReferenceSrvOpen(SrvOpen) \
423 RxpTrackReference(RDBSS_REF_TRACK_SRVOPEN, __FILE__, __LINE__, SrvOpen); \
424 RxReference(SrvOpen)
425
426 #define RxDereferenceSrvOpen(SrvOpen, LockHoldingState) \
427 RxpTrackDereference(RDBSS_REF_TRACK_SRVOPEN, __FILE__, __LINE__, SrvOpen); \
428 RxDereference(SrvOpen, LockHoldingState)
429
430 #define RxReferenceNetFcb(Fcb) \
431 (RxpTrackReference(RDBSS_REF_TRACK_NETFCB, __FILE__, __LINE__, Fcb), \
432 RxpReferenceNetFcb(Fcb))
433
434 #define RxDereferenceNetFcb(Fcb) \
435 ((LONG)RxpTrackDereference(RDBSS_REF_TRACK_NETFCB, __FILE__, __LINE__, Fcb), \
436 RxpDereferenceNetFcb(Fcb))
437
438 #define RxDereferenceAndFinalizeNetFcb(Fcb, RxContext, RecursiveFinalize, ForceFinalize) \
439 (RxpTrackDereference(RDBSS_REF_TRACK_NETFCB, __FILE__, __LINE__, Fcb), \
440 RxpDereferenceAndFinalizeNetFcb(Fcb, RxContext, RecursiveFinalize, ForceFinalize))
441
442 PSRV_CALL
443 RxCreateSrvCall(
444 _In_ PRX_CONTEXT RxContext,
445 _In_ PUNICODE_STRING Name,
446 _In_opt_ PUNICODE_STRING InnerNamePrefix,
447 _In_ PRX_CONNECTION_ID RxConnectionId);
448
449 #define RxWaitForStableSrvCall(S, R) RxWaitForStableCondition(&(S)->Condition, &(S)->TransitionWaitList, (R), NULL)
450 #define RxTransitionSrvCall(S, C) RxUpdateCondition((C), &(S)->Condition, &(S)->TransitionWaitList)
451
452 #if (_WIN32_WINNT >= 0x0600)
453 BOOLEAN
454 RxFinalizeSrvCall(
455 _Out_ PSRV_CALL ThisSrvCall,
456 _In_ BOOLEAN ForceFinalize);
457 #else
458 BOOLEAN
459 RxFinalizeSrvCall(
460 _Out_ PSRV_CALL ThisSrvCall,
461 _In_ BOOLEAN RecursiveFinalize,
462 _In_ BOOLEAN ForceFinalize);
463 #endif
464
465 PNET_ROOT
466 RxCreateNetRoot(
467 _In_ PSRV_CALL SrvCall,
468 _In_ PUNICODE_STRING Name,
469 _In_ ULONG NetRootFlags,
470 _In_opt_ PRX_CONNECTION_ID RxConnectionId);
471
472 #define RxWaitForStableNetRoot(N, R) RxWaitForStableCondition(&(N)->Condition, &(N)->TransitionWaitList, (R), NULL)
473 #define RxTransitionNetRoot(N, C) RxUpdateCondition((C), &(N)->Condition, &(N)->TransitionWaitList)
474
475 BOOLEAN
476 RxFinalizeNetRoot(
477 _Out_ PNET_ROOT ThisNetRoot,
478 _In_ BOOLEAN RecursiveFinalize,
479 _In_ BOOLEAN ForceFinalize);
480
481 NTSTATUS
482 RxInitializeVNetRootParameters(
483 _In_ PRX_CONTEXT RxContext,
484 _Out_ LUID *LogonId,
485 _Out_ PULONG SessionId,
486 _Out_ PUNICODE_STRING *UserNamePtr,
487 _Out_ PUNICODE_STRING *UserDomainNamePtr,
488 _Out_ PUNICODE_STRING *PasswordPtr,
489 _Out_ PULONG Flags);
490
491 VOID
492 RxUninitializeVNetRootParameters(
493 _In_ PUNICODE_STRING UserName,
494 _In_ PUNICODE_STRING UserDomainName,
495 _In_ PUNICODE_STRING Password,
496 _Out_ PULONG Flags);
497
498 PV_NET_ROOT
499 RxCreateVNetRoot(
500 _In_ PRX_CONTEXT RxContext,
501 _In_ PNET_ROOT NetRoot,
502 _In_ PUNICODE_STRING CanonicalName,
503 _In_ PUNICODE_STRING LocalNetRootName,
504 _In_ PUNICODE_STRING FilePath,
505 _In_ PRX_CONNECTION_ID RxConnectionId);
506
507 BOOLEAN
508 RxFinalizeVNetRoot(
509 _Out_ PV_NET_ROOT ThisVNetRoot,
510 _In_ BOOLEAN RecursiveFinalize,
511 _In_ BOOLEAN ForceFinalize);
512
513 #define RxWaitForStableVNetRoot(V, R) RxWaitForStableCondition(&(V)->Condition, &(V)->TransitionWaitList, (R), NULL)
514 #define RxTransitionVNetRoot(V, C) RxUpdateCondition((C), &(V)->Condition, &(V)->TransitionWaitList)
515
516 VOID
517 RxSetFileSizeWithLock(
518 _Inout_ PFCB Fcb,
519 _In_ PLONGLONG FileSize);
520
521 VOID
522 RxGetFileSizeWithLock(
523 _In_ PFCB Fcb,
524 _Out_ PLONGLONG FileSize);
525
526 #if (_WIN32_WINNT >= 0x0600)
527 RxCreateNetFcb(
528 _In_ PRX_CONTEXT RxContext,
529 _In_ PIRP Irp,
530 _In_ PV_NET_ROOT VNetRoot,
531 _In_ PUNICODE_STRING Name);
532 #else
533 PFCB
534 RxCreateNetFcb(
535 _In_ PRX_CONTEXT RxContext,
536 _In_ PV_NET_ROOT VNetRoot,
537 _In_ PUNICODE_STRING Name);
538 #endif
539
540 #define RxWaitForStableNetFcb(F, R) RxWaitForStableCondition(&(F)->Condition, &(F)->NonPaged->TransitionWaitList, (R), NULL )
541 #define RxTransitionNetFcb(F, C) RxUpdateCondition((C), &(F)->Condition, &(F)->NonPaged->TransitionWaitList)
542
543 #define RxFormInitPacket(IP, I1, I1a, I2, I3, I4a, I4b, I5, I6, I7) ( \
544 IP.pAttributes = I1, IP.pNumLinks = I1a, \
545 IP.pCreationTime = I2, IP.pLastAccessTime = I3, \
546 IP.pLastWriteTime = I4a, IP.pLastChangeTime = I4b, \
547 IP.pAllocationSize = I5, IP.pFileSize = I6, \
548 IP.pValidDataLength = I7, &IP)
549
550 #if DBG
551 #define ASSERT_CORRECT_FCB_STRUCTURE_DBG_ONLY(Fcb) \
552 { \
553 ASSERT(Fcb->NonPaged == Fcb->CopyOfNonPaged); \
554 ASSERT(Fcb->NonPaged->FcbBackPointer == Fcb); \
555 }
556 #else
557 #define ASSERT_CORRECT_FCB_STRUCTURE_DBG_ONLY(Fcb)
558 #endif
559
560 #define ASSERT_CORRECT_FCB_STRUCTURE(Fcb) \
561 { \
562 ASSERT(NodeTypeIsFcb(Fcb)); \
563 ASSERT(Fcb->NonPaged != NULL ); \
564 ASSERT(NodeType(Fcb->NonPaged) == RDBSS_NTC_NONPAGED_FCB); \
565 ASSERT_CORRECT_FCB_STRUCTURE_DBG_ONLY(Fcb); \
566 }
567
568 VOID
569 NTAPI
570 RxFinishFcbInitialization(
571 _In_ OUT PMRX_FCB Fcb,
572 _In_ RX_FILE_TYPE FileType,
573 _In_opt_ PFCB_INIT_PACKET InitPacket);
574
575 #define RxWaitForStableSrvOpen(S, R) RxWaitForStableCondition(&(S)->Condition, &(S)->TransitionWaitList, (R), NULL)
576 #define RxTransitionSrvOpen(S, C) RxUpdateCondition((C), &(S)->Condition, &(S)->TransitionWaitList)
577
578 VOID
579 RxRemoveNameNetFcb(
580 _Out_ PFCB ThisFcb);
581
582 LONG
583 RxpReferenceNetFcb(
584 _In_ PFCB Fcb);
585
586 LONG
587 RxpDereferenceNetFcb(
588 _In_ PFCB Fcb);
589
590 BOOLEAN
591 RxpDereferenceAndFinalizeNetFcb(
592 _Out_ PFCB ThisFcb,
593 _In_ PRX_CONTEXT RxContext,
594 _In_ BOOLEAN RecursiveFinalize,
595 _In_ BOOLEAN ForceFinalize);
596
597 PSRV_OPEN
598 RxCreateSrvOpen(
599 _In_ PV_NET_ROOT VNetRoot,
600 _In_ OUT PFCB Fcb);
601
602 BOOLEAN
603 RxFinalizeSrvOpen(
604 _Out_ PSRV_OPEN ThisSrvOpen,
605 _In_ BOOLEAN RecursiveFinalize,
606 _In_ BOOLEAN ForceFinalize);
607
608 FORCEINLINE
609 PUNICODE_STRING
610 GET_ALREADY_PREFIXED_NAME(
611 PMRX_SRV_OPEN SrvOpen,
612 PMRX_FCB Fcb)
613 {
614 PFCB ThisFcb = (PFCB)Fcb;
615
616 #if DBG
617 if (SrvOpen != NULL)
618 {
619 ASSERT(NodeType(SrvOpen) == RDBSS_NTC_SRVOPEN);
620 ASSERT(ThisFcb != NULL);
621 ASSERT(NodeTypeIsFcb(Fcb));
622 ASSERT(SrvOpen->pFcb == Fcb);
623 ASSERT(SrvOpen->pAlreadyPrefixedName == &ThisFcb->PrivateAlreadyPrefixedName);
624 }
625 #endif
626
627 return &ThisFcb->PrivateAlreadyPrefixedName;
628 }
629 #define GET_ALREADY_PREFIXED_NAME_FROM_CONTEXT(Rxcontext) GET_ALREADY_PREFIXED_NAME((Rxcontext)->pRelevantSrvOpen, (Rxcontext)->pFcb)
630
631 PMRX_FOBX
632 NTAPI
633 RxCreateNetFobx(
634 _Out_ PRX_CONTEXT RxContext,
635 _In_ PMRX_SRV_OPEN MrxSrvOpen);
636
637 BOOLEAN
638 RxFinalizeNetFobx(
639 _Out_ PFOBX ThisFobx,
640 _In_ BOOLEAN RecursiveFinalize,
641 _In_ BOOLEAN ForceFinalize);
642
643 #ifdef __REACTOS__
644 #define FILL_IN_FCB(Fcb, a, nl, ct, lat, lwt, lct, as, fs, vdl) \
645 (Fcb)->Attributes = a; \
646 (Fcb)->NumberOfLinks = nl; \
647 (Fcb)->CreationTime.QuadPart = ct; \
648 (Fcb)->LastAccessTime.QuadPart = lat; \
649 (Fcb)->LastWriteTime.QuadPart = lwt; \
650 (Fcb)->LastChangeTime.QuadPart = lct; \
651 (Fcb)->ActualAllocationLength = as; \
652 (Fcb)->Header.AllocationSize.QuadPart = as; \
653 (Fcb)->Header.FileSize.QuadPart = fs; \
654 (Fcb)->Header.ValidDataLength.QuadPart = vdl; \
655 SetFlag((Fcb)->FcbState, FCB_STATE_TIME_AND_SIZE_ALREADY_SET)
656
657 #define TRACKER_ACQUIRE_FCB 0x61616161
658 #define TRACKER_RELEASE_FCB_NO_BUFF_PENDING 0x72727272
659 #define TRACKER_RELEASE_NON_EXCL_FCB_BUFF_PENDING 0x72727230
660 #define TRACKER_RELEASE_EXCL_FCB_BUFF_PENDING 0x72727231
661 #define TRACKER_RELEASE_FCB_FOR_THRD_NO_BUFF_PENDING 0x72727474
662 #define TRACKER_RELEASE_NON_EXCL_FCB_FOR_THRD_BUFF_PENDING 0x72727430
663 #define TRACKER_RELEASE_EXCL_FCB_FOR_THRD_BUFF_PENDING 0x72727431
664 #define TRACKER_FCB_FREE 0x72724372
665
666 #define FCB_STATE_BUFFERING_STATE_WITH_NO_SHARES \
667 (( FCB_STATE_WRITECACHING_ENABLED \
668 | FCB_STATE_WRITEBUFFERING_ENABLED \
669 | FCB_STATE_READCACHING_ENABLED \
670 | FCB_STATE_READBUFFERING_ENABLED \
671 | FCB_STATE_LOCK_BUFFERING_ENABLED \
672 | FCB_STATE_FILESIZECACHEING_ENABLED \
673 | FCB_STATE_FILETIMECACHEING_ENABLED))
674
675 #endif
676
677 #endif