Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1573 lines
47 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. Fcb.h
  5. Abstract:
  6. This module defines File Control Block data structures, by which we mean:
  7. 1) File Control Blocks (FCB)
  8. 2) File Object Extensions (FOXB)
  9. 3) Net Roots (NET_ROOT)
  10. 4) ServerSide Open Context (SRV_OPEN)
  11. 5) Server Call Context (SRV_CALL)
  12. 6) View of Net Roots (V_NET_ROOT)
  13. The more complete description follows the prototypes.
  14. Author:
  15. Joe Linn [JoeLinn] 19-aug-1994
  16. Revision History:
  17. Balan Sethu Raman [SethuR] 1-Aug-96
  18. --*/
  19. #ifndef _FCB_STRUCTS_DEFINED_
  20. #define _FCB_STRUCTS_DEFINED_
  21. #include "fcbtable.h"
  22. #include "buffring.h"
  23. typedef NODE_TYPE_CODE TYPE_OF_OPEN;
  24. struct _FCB_INIT_PACKET;
  25. typedef struct _FCB_INIT_PACKET *PFCB_INIT_PACKET;
  26. /* -----------------------------------------------------------
  27. There are six important data structures in the wrapper that are shared with the
  28. various mini redirectors. These data structures come in two flavours -- the
  29. mini redirector flavour which contains only those fields that can be manipulated
  30. by the mini redirector and the RDBSS flavour defined here. The mini redirector
  31. flavour carries the prefix MRX_.
  32. The six data structures are SRV_CALL,NET_ROOT,V_NET_ROOT,FCB,SRV_OPEN and FOBX
  33. respectively.
  34. The global view of these structures is the following (information on each of the
  35. data structures follows the locking description )
  36. L O C K I N G <-------
  37. There are two levels of lookup tables used: a global table for srvcalls
  38. and netroots and a table-per-netroot for fcbs. This allows directory
  39. operations on different netroots to be almost completely noninterfering
  40. (once the connections are established). Directory operations on the
  41. same netroot do intefere slightly. The following table describes what
  42. locks you need:
  43. OPERATION DATATYPE LOCK REQUIRED
  44. create/finalize srvcall/(v)netroot exclusive on netnametablelock
  45. ref/deref/lookup srvcall/(v)netroot shared on netnametablelock (at least)
  46. create/finalize fcb/srvopen/fobx exclusive on netroot->fcbtablelock
  47. ref/deref/lookup fcb/srvopen/fobx shared on netroot->fcbtablelock
  48. Note that manipulations on srvopens and fobxs require the same lock as
  49. fcbs....this is simply a memory saving idea. It would be
  50. straightforward to add another resource at the fcb level to remove this;
  51. a set of sharted resources could be used to decrease the probability of
  52. collision to an acceptably low level.
  53. R E F C O U N T S <---------------
  54. Each of the structures is reference counted. The counts are the
  55. following:
  56. refcount(srvcall) = number of netroots pointing to srvcall + DYNAMIC
  57. refcount(netroot) = number of fcbs pointing to netroot + DYNAMIC
  58. refcount(fcb) = number of fcbs pointing to netroot + DYNAMIC
  59. refcount(srvopen) = number of fcbs pointing to netroot + DYNAMIC
  60. refcount(fobx) = DYNAMIC
  61. In each case, dynamic refers to the number of callers that have
  62. referenced the structure without dereferencing it. The static part of
  63. the refcount is maintained by the routines themselves; for example,
  64. CreateNetRoot increments the refcount for the associated srvcall.
  65. Reference and Successful Lookups increment the reference counts;
  66. dereference decrements the count. Creates set the reference counts to 1,
  67. If you require both locks (like FinalizeNetFcb), you take the fcblock
  68. first AND THEN the global table lock. obviously, you release in the
  69. opposite order.
  70. ----------------------------------*/
  71. //
  72. // SRV_CALL
  73. //
  74. // A global list of the SRV_CALL structures is maintained in the global
  75. // data. Each SrvCall structure has stuff that is unique to a srv_call.
  76. // Now, the rx doesn't know what this stuff is except for
  77. //
  78. // 0) signature and refcount
  79. // a) a name and associated table stuff
  80. // b) a list of associated NET_ROOTs
  81. // c) a set of timing parameters that control how often the subrx wants
  82. // to be called by the rx in different circumstances (i.e. idle timouts)
  83. // d) the minirdr id
  84. // .
  85. // .
  86. // z) whatever additional storage is request by the minirdr (or creator of the block).
  87. //
  88. // In fact, the Unicode name of the structure is carried in the structure itself
  89. // at the end. The extra space begins at the end of the known stuff so that a
  90. // mini redirector can just refer to his extra space using the context fields
  91. // These flags are not visible to the mini redirectors.
  92. #define SRVCALL_FLAG_NO_CONNECTION_ALLOWED (0x10000)
  93. #define SRVCALL_FLAG_NO_WRITES_ALLOWED (0x20000)
  94. #define SRVCALL_FLAG_NO_DELETES_ALLOWED (0x40000)
  95. #ifdef __cplusplus
  96. typedef struct _SRV_CALL : public MRX_SRV_CALL {
  97. #else // !__cplusplus
  98. typedef struct _SRV_CALL {
  99. //
  100. // The portion of SRV_CALL visible to mini redirectors.
  101. //
  102. union {
  103. MRX_SRV_CALL;
  104. struct {
  105. MRX_NORMAL_NODE_HEADER spacer;
  106. };
  107. };
  108. #endif // __cplusplus
  109. //
  110. // The finalization of a SRV_CALL instance consists of two parts,
  111. // destroying the association with all NET_ROOTS etc and freeing the
  112. // memory. There can be a delay between these two and this field
  113. // prevents thefirst step from being duplicated.
  114. //
  115. BOOLEAN UpperFinalizationDone;
  116. //
  117. // Name and Prefixtable entry for name lookups
  118. //
  119. RX_PREFIX_ENTRY PrefixEntry;
  120. //
  121. // Current condition of the SRV_CALL, i.e., good/bad/in transition
  122. //
  123. RX_BLOCK_CONDITION Condition;
  124. ULONG SerialNumberForEnum;
  125. //
  126. // Number of delayed close files
  127. //
  128. LONG NumberOfCloseDelayedFiles;
  129. //
  130. // List of Contexts which are waiting for the SRV_CALL transitioning
  131. // to be completed before resumption of processing. This typically
  132. // happens when concurrent requests are directed at a server. One of
  133. // these requests initiates the construction while the other requests
  134. // are queued.
  135. //
  136. LIST_ENTRY TransitionWaitList;
  137. //
  138. // List Entry to thread together all the SRV_CALL instances marked
  139. // for garbage collection/scavenging.
  140. //
  141. LIST_ENTRY ScavengerFinalizationList;
  142. //
  143. // Synchronization context for coordinating the purge operations on the
  144. // files opened at this server.
  145. //
  146. PURGE_SYNCHRONIZATION_CONTEXT PurgeSyncronizationContext;
  147. //
  148. // The Buffering manager for coordinating/processing the buffering state
  149. // change requests of the files opened at the server.
  150. //
  151. RX_BUFFERING_MANAGER BufferingManager;
  152. } SRV_CALL, *PSRV_CALL;
  153. //
  154. // A NET_ROOT contains
  155. // 0) signature and refcount
  156. // a) a name and associated table stuff
  157. // b) backpointer to the SRV_CALL structure
  158. // c) size information for the various substructures
  159. // d) a lookuptable of FCB structures
  160. // .
  161. // .
  162. // z) whatever additional storage is request by the minirdr (or creator of the block).
  163. //
  164. // A NET_ROOT is what the rx wants to deal with.....not a server.
  165. // Accordingly, the rx calls down to open a netroot and the subrx is
  166. // responsible for opening a server and calling up to put the right
  167. // structures.
  168. //
  169. #define NETROOT_FLAG_ENCLOSED_ALLOCATED ( 0x00010000 )
  170. #define NETROOT_FLAG_DEVICE_NETROOT ( 0x00020000 )
  171. #define NETROOT_FLAG_FINALIZATION_IN_PROGRESS ( 0x00040000 )
  172. #define NETROOT_FLAG_NAME_ALREADY_REMOVED ( 0x00080000 )
  173. #define NETROOT_INIT_KEY (0)
  174. #ifdef __cplusplus
  175. typedef struct _NET_ROOT : public MRX_NET_ROOT {
  176. #else // !__cplusplus
  177. typedef struct _NET_ROOT {
  178. //
  179. // The porion of NET_ROOT instance visible to mini redirectors.
  180. //
  181. union {
  182. MRX_NET_ROOT;
  183. struct {
  184. MRX_NORMAL_NODE_HEADER spacer;
  185. PSRV_CALL SrvCall;
  186. };
  187. };
  188. #endif // __cplusplus
  189. //
  190. // The finalization of a NET_ROOT instance consists of two parts,
  191. // destroying the association with all V_NET_ROOTS etc and freeing the
  192. // memory. There can be a delay between these two and this field
  193. // prevents thefirst step from being duplicated.
  194. //
  195. BOOLEAN UpperFinalizationDone;
  196. //
  197. // Current condition of the NET_ROOT, i.e., good/bad/in transition
  198. //
  199. RX_BLOCK_CONDITION Condition;
  200. //
  201. // List of Contexts which are waiting for the NET_ROOT transitioning
  202. // to be completed before resumption of processing. This typically
  203. // happens when concurrent requests are directed at a server. One of
  204. // these requests initiates the construction while the other requests
  205. // are queued.
  206. //
  207. LIST_ENTRY TransitionWaitList;
  208. //
  209. // List Entry to thread together all the NET_ROOT instances marked
  210. // for garbage collection/scavenging.
  211. //
  212. LIST_ENTRY ScavengerFinalizationList;
  213. //
  214. // Synchronization context for coordinating the purge operations on the
  215. // files opened for this NET_ROOt
  216. //
  217. PURGE_SYNCHRONIZATION_CONTEXT PurgeSyncronizationContext;
  218. //
  219. // The default V_NET_ROOT instance to be used on this NET_ROOT
  220. //
  221. PV_NET_ROOT DefaultVNetRoot;
  222. //
  223. // list of V_NET_ROOTs associated with the NET_ROOT
  224. //
  225. LIST_ENTRY VirtualNetRoots;
  226. //
  227. // the count of V_NET_ROOT instances associated with the NET_ROOT
  228. //
  229. ULONG NumberOfVirtualNetRoots;
  230. ULONG SerialNumberForEnum;
  231. //
  232. // NET_ROOT name and prefix table entry
  233. //
  234. RX_PREFIX_ENTRY PrefixEntry;
  235. //
  236. // the FCB's associated with this NET_ROOT
  237. //
  238. RX_FCB_TABLE FcbTable;
  239. } NET_ROOT, *PNET_ROOT;
  240. //
  241. // A V_NETROOT contains
  242. // 0) signature and refcount
  243. // a) ptr to netroot and links.
  244. // b) name info for table lookup (prefix)
  245. // c) name for a prefix to be added to whatever name you see. this is for simulating a netroot
  246. // mapped not at the root of the actual netroot.
  247. //
  248. #ifdef __cplusplus
  249. typedef struct _V_NET_ROOT : public MRX_V_NET_ROOT {
  250. #else // !__cplusplus
  251. typedef struct _V_NET_ROOT {
  252. //
  253. // the portion of V_NET_ROOT visible to mini redirectors
  254. //
  255. union {
  256. MRX_V_NET_ROOT;
  257. struct {
  258. MRX_NORMAL_NODE_HEADER spacer;
  259. PNET_ROOT NetRoot;
  260. };
  261. };
  262. #endif // __cplusplus
  263. //
  264. // The finalization of a V_NET_ROOT instance consists of two parts,
  265. // destroying the association with all FCBs etc and freeing the
  266. // memory. There can be a delay between these two and this field
  267. // prevents thefirst step from being duplicated.
  268. //
  269. BOOLEAN UpperFinalizationDone;
  270. BOOLEAN ConnectionFinalizationDone;
  271. //
  272. // Current condition of the V_NET_ROOT, i.e., good/bad/in transition
  273. //
  274. RX_BLOCK_CONDITION Condition;
  275. //
  276. // Additional reference for the Delete FSCTL. This field is long as
  277. // opposed to a BOOLEAN eventhough it can have only one of two values
  278. // 0 or 1. This enables the usage of interlocked instructions
  279. //
  280. LONG AdditionalReferenceForDeleteFsctlTaken;
  281. //
  282. // Prefix table entry and V_NET_ROOT name ( prefix table entry is inserted
  283. // in the RxNetNameTable)
  284. //
  285. RX_PREFIX_ENTRY PrefixEntry;
  286. //
  287. // this name is prepended to all fcbs (not currently used)
  288. //
  289. UNICODE_STRING NamePrefix;
  290. //
  291. // amount of bytes required to get past the netroot
  292. //
  293. ULONG PrefixOffsetInBytes;
  294. //
  295. // List entry to wire the V_NET_ROOT instance into a list of V_NET_ROOTS
  296. // maintained in the NET_ROOT
  297. //
  298. LIST_ENTRY NetRootListEntry;
  299. ULONG SerialNumberForEnum;
  300. //
  301. // List of Contexts which are waiting for the NET_ROOT transitioning
  302. // to be completed before resumption of processing. This typically
  303. // happens when concurrent requests are directed at a server. One of
  304. // these requests initiates the construction while the other requests
  305. // are queued.
  306. //
  307. LIST_ENTRY TransitionWaitList;
  308. //
  309. // List Entry to thread together all the V_NET_ROOT instances marked
  310. // for garbage collection/scavenging.
  311. //
  312. LIST_ENTRY ScavengerFinalizationList;
  313. } V_NET_ROOT, *PV_NET_ROOT;
  314. #define FILESIZE_LOCK_DISABLED(x)
  315. //
  316. // An FCB contains
  317. // 0) FSRTL_COMMON_HEADER
  318. // 1) a reference count
  319. // a) a name and associated table stuff
  320. // b) backpointer to the NET_ROOT structure
  321. // c) a list of SRV_OPEN structures
  322. // d) device object
  323. // e) dispatch table (not yet)
  324. // .
  325. // .
  326. // z) whatever additional storage is request by the minirdr (or creator of the block).
  327. //
  328. // The FCB is pointed to by the FsContext Field in the file object. The
  329. // rule is that all the guys sharing an FCB are talking about the same
  330. // file. (unfortuantely, SMB servers are implemented today in such a way
  331. // that names are aliased so that two different names could be the same
  332. // actual file.....sigh!) The Fcb is the focal point of file
  333. // operations...since operations on the same FCB are actually on the same
  334. // file, synchronization is based on the Fcb rather than some higher level
  335. // (the levels described so far are lower, i.e. farther from the user).
  336. // Again, we will provide for colocation of FCB/SRV_OPEN/FOBX to improve
  337. // paging behaviour. We don't colocate the FCB and NET_ROOT because the
  338. // NET_ROOTs are not paged but FCBs usually are (i.e. unless they are
  339. // paging files).
  340. //
  341. // The Fcb record corresponds to every open file and directory and is is split up into
  342. // two portions a non paged part, i.e., an instance allocated in non paged pool and
  343. // a paged part. The former is the NON_PAGED_FCB and the later is referred to as FCB.
  344. // The FCB conatins a pointer to the corresponding NON_PAGED_FCB part. A backpointer
  345. // is maintained from the NON_PAGED_FCB to the FCB for debugging purposes in debug builds
  346. //
  347. typedef struct _NON_PAGED_FCB {
  348. //
  349. // Struct type and size for debugging/tracking
  350. //
  351. NODE_TYPE_CODE NodeTypeCode;
  352. NODE_BYTE_SIZE NodeByteSize;
  353. //
  354. // The following field contains a record of special pointers used by
  355. // MM and Cache to manipluate section objects. Note that the values
  356. // are set outside of the file system. However the file system on an
  357. // open/create will set the file object's SectionObject field to point
  358. // to this field
  359. //
  360. SECTION_OBJECT_POINTERS SectionObjectPointers;
  361. //
  362. // This resource is used in the common fsrtl routines....allocated here for
  363. // space locality.
  364. //
  365. ERESOURCE HeaderResource;
  366. //
  367. // This resource is also used in the common fsrtl routines....allocated here for
  368. // space locality.
  369. //
  370. ERESOURCE PagingIoResource;
  371. #ifdef USE_FILESIZE_LOCK
  372. //
  373. // This mutex protect the filesize during read/write
  374. //
  375. FAST_MUTEX FileSizeLock;
  376. #endif
  377. //
  378. // The list of contexts whose processing has been suspended pending the state
  379. // transition of the FCB.
  380. //
  381. LIST_ENTRY TransitionWaitList;
  382. //
  383. // This context is non-zero only if the file currently has asynchronous
  384. // non-cached valid data length extending writes. It allows
  385. // synchronization between pending writes and other operations.
  386. //
  387. ULONG OutstandingAsyncWrites;
  388. //
  389. // This event is set when OutstandingAsyncWrites transitions to zero.
  390. //
  391. PKEVENT OutstandingAsyncEvent;
  392. KEVENT TheActualEvent;
  393. //
  394. // The mechanism for the mini redirectors to store additional information
  395. //
  396. PVOID MiniRdrContext[2];
  397. //
  398. // This is the mutex that is inserted into the FCB_ADVANCED_HEADER
  399. // FastMutex field
  400. //
  401. FAST_MUTEX AdvancedFcbHeaderMutex;
  402. #if DBG
  403. PFCB FcbBackPointer;
  404. #endif
  405. } NON_PAGED_FCB, *PNON_PAGED_FCB;
  406. typedef enum _FCB_CONDITION {
  407. FcbGood = 1,
  408. FcbBad,
  409. FcbNeedsToBeVerified
  410. } FCB_CONDITION;
  411. //
  412. // A enumerated type distinguishing the varios contexts under which the FCB resource
  413. // is accquired.
  414. //
  415. typedef enum _RX_FCBTRACKER_CASES {
  416. RX_FCBTRACKER_CASE_NORMAL,
  417. RX_FCBTRACKER_CASE_NULLCONTEXT,
  418. RX_FCBTRACKER_CASE_CBS_CONTEXT,
  419. RX_FCBTRACKER_CASE_CBS_WAIT_CONTEXT,
  420. RX_FCBTRACKER_CASE_MAXIMUM
  421. } RX_FCBTRACKER_CASES;
  422. #ifdef __cplusplus
  423. typedef struct _FCB : public MRX_FCB {
  424. #else // !__cplusplus
  425. typedef struct _FCB {
  426. //
  427. // Entries are reference counted. ordinarily this would be at the beginning but
  428. // in the case of FCB's it will follows the common header and fixed part
  429. //
  430. union {
  431. MRX_FCB;
  432. struct {
  433. FSRTL_ADVANCED_FCB_HEADER spacer;
  434. PNET_ROOT NetRoot;
  435. };
  436. };
  437. #endif // !__cplusplus
  438. //
  439. // VNetroot for this FCB, if any
  440. //
  441. PV_NET_ROOT VNetRoot;
  442. //
  443. // Structure for fields that must be in non-paged pool.
  444. //
  445. PNON_PAGED_FCB NonPaged;
  446. //
  447. // List Entry to thread together all the FCB instances marked
  448. // for garbage collection/scavenging.
  449. //
  450. LIST_ENTRY ScavengerFinalizationList;
  451. //
  452. // The resource accquisition mechanism gives preference to buffering state change
  453. // processing over other requests. Therefor when a buffering state change is
  454. // indicated all subsequent requests are shunted off to wait on a buffering state
  455. // change completion event. This enables the actual buffering state change processing
  456. // to complete in a timely fashion.
  457. //
  458. PKEVENT pBufferingStateChangeCompletedEvent;
  459. //
  460. // Number of contexts awaiting buffering state change processing completion
  461. //
  462. LONG NumberOfBufferingStateChangeWaiters;
  463. //
  464. // the name in the table is always a suffix of the name as viewed by the mini
  465. // redirector. the string in the prefix entry is the name in the table....
  466. // the "alreadyprefixedname: points to the whole name.
  467. //
  468. RX_FCB_TABLE_ENTRY FcbTableEntry;
  469. //
  470. // the name alongwith the MRX_NET_ROOT prefix, i.e. fully qualified name
  471. //
  472. UNICODE_STRING PrivateAlreadyPrefixedName;
  473. //
  474. // Indicates that the V_NET_ROOT related processing on finalization is complete
  475. //
  476. BOOLEAN UpperFinalizationDone;
  477. //
  478. // the present state of the FCB, good/bad/in transition
  479. //
  480. RX_BLOCK_CONDITION Condition;
  481. //
  482. // Pointer to the private dispatch table, if any.
  483. //
  484. PRX_FSD_DISPATCH_VECTOR PrivateDispatchVector;
  485. //
  486. // the device object that owns this fcb
  487. //
  488. PRDBSS_DEVICE_OBJECT RxDeviceObject;
  489. PMINIRDR_DISPATCH MRxDispatch;
  490. //
  491. // private fast dispatch table, if any. This allows lwio to add it's own hooks
  492. //
  493. PFAST_IO_DISPATCH MRxFastIoDispatch;
  494. //
  495. // Whenever a FCB instance is created a correpsonding SRV_OPEN and FOBX instance
  496. // is also created. More than one SRV_OPEN can be associated with a given FCB and
  497. // more than one FOBX is associated with a given SRV_OPEN. In a majority of the
  498. // cases the number of SRV_OPENs associated with an FCB is one and the number of
  499. // FOBX associated with a given SRV_OPEN is 1. In order to improve the spatial
  500. // locality and the paging behaviour in such cases the allocation for the
  501. // FCB also involves an allocation for the SRV_OPEN and FOBX.
  502. //
  503. //
  504. // set initially to the internally allocated srv_open
  505. //
  506. PSRV_OPEN InternalSrvOpen;
  507. //
  508. // set to internal fobx until allocated
  509. //
  510. PFOBX InternalFobx;
  511. //
  512. // the shared access for each time this file/directory is opened.
  513. //
  514. SHARE_ACCESS ShareAccess;
  515. SHARE_ACCESS ShareAccessPerSrvOpens;
  516. //
  517. // this information is returned when the file is opened. ..might as well
  518. // cache it so that so that tandard info query can be handled on the client
  519. // side
  520. //
  521. ULONG NumberOfLinks;
  522. //
  523. // Cache these entries..... speeds up RxFastQueryBasicInfo().
  524. //
  525. LARGE_INTEGER CreationTime;
  526. LARGE_INTEGER LastAccessTime;
  527. LARGE_INTEGER LastWriteTime;
  528. LARGE_INTEGER LastChangeTime;
  529. //
  530. // used to check by mini redirs in order to decide whether to update the FCB
  531. //
  532. ULONG ulFileSizeVersion;
  533. //
  534. // The following field is used by the filelock module
  535. // to maintain current byte range locking information.
  536. //
  537. FILE_LOCK FileLock;
  538. //
  539. // do this wierdly so that I can call stuff be the inner or outer names
  540. //
  541. union {
  542. #ifndef __cplusplus
  543. LOWIO_PER_FCB_INFO;
  544. #endif // __cplusplus
  545. LOWIO_PER_FCB_INFO LowIoPerFcbInfo;
  546. };
  547. #ifdef USE_FILESIZE_LOCK
  548. PFAST_MUTEX FileSizeLock;
  549. #endif
  550. //
  551. // The following field is used to verify that the Ea's for a file
  552. // have not changed between calls to query for Ea's. It is compared
  553. // with a similar field in a Fobx.
  554. //
  555. // IMPORTANT!! **** DO NOT MOVE THIS FIELD ****
  556. //
  557. // The slack space in the union above is computed from
  558. // the field offset of the EaModificationCount.
  559. //
  560. ULONG EaModificationCount;
  561. #if DBG
  562. PNON_PAGED_FCB CopyOfNonPaged; // copy of NonPaged so we can zap the real pointer and still find it
  563. #endif
  564. #ifdef RDBSS_TRACKER
  565. ULONG FcbAcquires[RX_FCBTRACKER_CASE_MAXIMUM]; // there are four types
  566. ULONG FcbReleases[RX_FCBTRACKER_CASE_MAXIMUM];
  567. #else
  568. #error tracker must be defined
  569. #endif
  570. PCHAR PagingIoResourceFile;
  571. ULONG PagingIoResourceLine;
  572. } FCB, *PFCB;
  573. //
  574. // Here are the Fcb state fields.
  575. //
  576. #define FCB_STATE_SRVOPEN_USED ( 0x80000000 )
  577. #define FCB_STATE_FOBX_USED ( 0x40000000 )
  578. #define FCB_STATE_ADDEDBACKSLASH ( 0x20000000 )
  579. #define FCB_STATE_NAME_ALREADY_REMOVED ( 0x10000000 )
  580. #define FCB_STATE_WRITECACHING_ENABLED ( 0x08000000 )
  581. #define FCB_STATE_WRITEBUFFERING_ENABLED ( 0x04000000 )
  582. #define FCB_STATE_READCACHING_ENABLED ( 0x02000000 )
  583. #define FCB_STATE_READBUFFERING_ENABLED ( 0x01000000 )
  584. #define FCB_STATE_OPENSHARING_ENABLED ( 0x00800000 )
  585. #define FCB_STATE_COLLAPSING_ENABLED ( 0x00400000 )
  586. #define FCB_STATE_LOCK_BUFFERING_ENABLED ( 0x00200000 )
  587. #define FCB_STATE_FILESIZECACHEING_ENABLED ( 0x00100000 )
  588. #define FCB_STATE_FILETIMECACHEING_ENABLED ( 0x00080000 )
  589. #define FCB_STATE_TIME_AND_SIZE_ALREADY_SET ( 0x00040000 )
  590. #define FCB_STATE_SPECIAL_PATH ( 0x00020000 )
  591. #define FCB_STATE_FILE_IS_SHADOWED ( 0x00010000 )
  592. #define FCB_STATE_FILE_IS_DISK_COMPRESSED ( 0x00008000 )
  593. #define FCB_STATE_FILE_IS_BUF_COMPRESSED ( 0x00004000 )
  594. #define FCB_STATE_BUFFERSTATE_CHANGING ( 0x00002000 )
  595. #define FCB_STATE_FAKEFCB ( 0x00001000 )
  596. #define FCB_STATE_DELAY_CLOSE ( 0x00000800 )
  597. #define FCB_STATE_READAHEAD_DEFERRED ( 0x00000100 )
  598. #define FCB_STATE_ORPHANED ( 0x00000080 )
  599. #define FCB_STATE_BUFFERING_STATE_CHANGE_PENDING ( 0x00000040 )
  600. #define FCB_STATE_TEMPORARY ( 0x00000020 )
  601. #define FCB_STATE_DISABLE_LOCAL_BUFFERING ( 0x00000010 )
  602. #define FCB_STATE_LWIO_ENABLED ( 0x00000008 )
  603. #define FCB_STATE_PAGING_FILE ( 0x00000004 )
  604. #define FCB_STATE_TRUNCATE_ON_CLOSE ( 0x00000002 )
  605. #define FCB_STATE_DELETE_ON_CLOSE ( 0x00000001 )
  606. #define FCB_STATE_BUFFERING_STATE_MASK \
  607. (( FCB_STATE_WRITECACHING_ENABLED \
  608. | FCB_STATE_WRITEBUFFERING_ENABLED \
  609. | FCB_STATE_READCACHING_ENABLED \
  610. | FCB_STATE_READBUFFERING_ENABLED \
  611. | FCB_STATE_OPENSHARING_ENABLED \
  612. | FCB_STATE_COLLAPSING_ENABLED \
  613. | FCB_STATE_LOCK_BUFFERING_ENABLED \
  614. | FCB_STATE_FILESIZECACHEING_ENABLED \
  615. | FCB_STATE_FILETIMECACHEING_ENABLED ))
  616. //
  617. // This is the MAX recursive resource limit.
  618. //
  619. #define MAX_FCB_ASYNC_ACQUIRE (0xf000)
  620. typedef struct _FCB_INIT_PACKET {
  621. PULONG pAttributes; // in the fcb this is DirentRxFlags;
  622. PULONG pNumLinks; // in the fcb this is NumberOfLinks;
  623. PLARGE_INTEGER pCreationTime; // these fields are the same as for the Fcb
  624. PLARGE_INTEGER pLastAccessTime;
  625. PLARGE_INTEGER pLastWriteTime;
  626. PLARGE_INTEGER pLastChangeTime;
  627. PLARGE_INTEGER pAllocationSize; // common header fields
  628. PLARGE_INTEGER pFileSize;
  629. PLARGE_INTEGER pValidDataLength;
  630. } FCB_INIT_PACKET;
  631. //
  632. // A SRV_OPEN contains
  633. // 0) signature and refcount
  634. // a) backpointer to the FCB
  635. // b) backpointer to the NET_ROOT //maybe
  636. // c) a list of FOXB structures
  637. // d) access rights and collapsability status
  638. // .
  639. // .
  640. // z) whatever additional storage is request by the minirdr (or creator of the block).
  641. //
  642. // The SRV_OPEN points to a structure describing a spevific open on the
  643. // server; multiple file objects and fileobject extensions (FOBXs) can
  644. // share the same srvopen if the access rights are correct. For example,
  645. // this would be where the FID is stored for SMBs. A list of these hangs
  646. // from the FCB. Similarly, all fileobject extensionss that share the same
  647. // serverside open are listed together here. Also here is information
  648. // about whether a new open of this FCB can share this serverside open
  649. // context; obviously the guys that pass the test on the list.
  650. //
  651. //
  652. // The SRVOPEN flags are split into two groups, i.e., visible to mini rdrs and invisible to mini rdrs.
  653. // The visible ones are defined above and the definitions for the invisible ones can be found
  654. // in fcb.h. The convention that has been adopted is that the lower 16 flags will be visible
  655. // to the mini rdr and the upper 16 flags will be reserved for the wrapper. This needs to be
  656. // enforced in defining new flags.
  657. //
  658. #define SRVOPEN_FLAG_ENCLOSED_ALLOCATED (0x10000)
  659. #define SRVOPEN_FLAG_FOBX_USED (0x20000)
  660. #define SRVOPEN_FLAG_SHAREACCESS_UPDATED (0x40000)
  661. #ifdef __cplusplus
  662. typedef struct _SRV_OPEN : public MRX_SRV_OPEN {
  663. #else // !__cplusplus
  664. typedef struct _SRV_OPEN {
  665. //
  666. // the portion of SRV_OPEN visible to all the mini redirectors.
  667. //
  668. union {
  669. MRX_SRV_OPEN;
  670. struct {
  671. MRX_NORMAL_NODE_HEADER spacer;
  672. //
  673. // the Fcb and VNetRoot for this srv_open
  674. //
  675. PFCB Fcb;
  676. PV_NET_ROOT VNetRoot;
  677. };
  678. };
  679. #endif // !__cplusplus
  680. BOOLEAN UpperFinalizationDone;
  681. //
  682. // the current condition of the SRV_OPEN, good/bad/in transition
  683. //
  684. RX_BLOCK_CONDITION Condition;
  685. //
  686. // Buffering state manager token
  687. //
  688. LONG BufferingToken;
  689. //
  690. // List Entry to thread together all the FCB instances marked
  691. // for garbage collection/scavenging.
  692. //
  693. LIST_ENTRY ScavengerFinalizationList;
  694. //
  695. // The list of contexts whose processing has been suspended pending the state
  696. // transition of the SRV_OPEN.
  697. //
  698. LIST_ENTRY TransitionWaitList;
  699. //
  700. // List Head for the list of FOBXs associated with this SRV_OPEN
  701. //
  702. LIST_ENTRY FobxList;
  703. //
  704. // The colocated instance of FOBX that is allocated whenever a SRV_OPEN
  705. // instance is allocated.
  706. //
  707. PFOBX InternalFobx;
  708. //
  709. // the data structure for maintaining the mapping between the key
  710. // associated with the SRV_OPEN instance by the mini redirector and
  711. // the SRV_OPEN instance
  712. //
  713. union {
  714. LIST_ENTRY SrvOpenKeyList;
  715. ULONG SequenceNumber;
  716. };
  717. NTSTATUS OpenStatus;
  718. } SRV_OPEN, *PSRV_OPEN;
  719. #define RxWriteCachingAllowed(FCB,SRVOPEN) \
  720. (FlagOn( (FCB)->FcbState, FCB_STATE_WRITECACHING_ENABLED ) && \
  721. !FlagOn( (SRVOPEN)->Flags, SRVOPEN_FLAG_DONTUSE_WRITE_CACHING ))
  722. #define SRVOPEN_INIT_KEY (0)
  723. //
  724. // A FOBX contains
  725. // 0) signature and refcount
  726. // a) backpointer to the FCB
  727. // b) backpointer to the SRV_OPEN
  728. // c) context information about this open
  729. // ...
  730. // z) whatever additional storage is request by the minirdr (or creator of the block).
  731. //
  732. // The FOBX points to the "fileobject extension", i.e. all the stuff that
  733. // is per fileobject is not stored there because the IO system provides
  734. // fixed size filesystem objects (not a dig BTW, that's just the decision).
  735. // The FOBX for any file object is referenced by the FsContext2 field in
  736. // the fileobject. Even tho the FOBX is ordinarily a terminus in the
  737. // structure, it is currently refcounted anyway.
  738. // The FOBX flags are split into two groups, i.e., visible to mini rdrs and invisible to mini rdrs.
  739. // The visible ones are defined above and the definitions for the invisible ones can be found
  740. // in fcb.h. The convention that has been adopted is that the lower 16 flags will be visible
  741. // to the mini rdr and the upper 16 flags will be reserved for the wrapper. This needs to be
  742. // enforced in defining new flags.
  743. //
  744. #define FOBX_FLAG_MATCH_ALL (0x10000)
  745. //
  746. // This tells us whether we allocated buffers to hold search templates.
  747. //
  748. #define FOBX_FLAG_FREE_UNICODE (0x20000)
  749. //
  750. // These flags prevents cleanup from updating the modify time, etc.
  751. //
  752. #define FOBX_FLAG_USER_SET_LAST_WRITE (0x40000)
  753. #define FOBX_FLAG_USER_SET_LAST_ACCESS (0x80000)
  754. #define FOBX_FLAG_USER_SET_CREATION (0x100000)
  755. #define FOBX_FLAG_USER_SET_LAST_CHANGE (0x200000)
  756. //
  757. // This bit says the file object associated with this Fobx was opened for
  758. // read only access.
  759. //
  760. #define FOBX_FLAG_READ_ONLY (0x400000)
  761. //
  762. // the delete on close flag is used to track a file object that was opened with delete-on-close;
  763. // when this object is closed, we copy the bit to the fcb and make it global
  764. //
  765. #define FOBX_FLAG_DELETE_ON_CLOSE (0x800000)
  766. //
  767. // this bits is used by minirdrs that do not have NT semantics. for example, the smbmini has
  768. // to close a file before it can try a rename or delete. after the operation, we prevent people from
  769. // getting back in.
  770. //
  771. #define FOBX_FLAG_SRVOPEN_CLOSED (0x1000000)
  772. //
  773. // this bit is used to tell whether the original name was a UNC name so that
  774. // we can return the name the same way
  775. //
  776. #define FOBX_FLAG_UNC_NAME (0x2000000)
  777. //
  778. // this flag tells if this fobx is allocated as part of a larger structure
  779. //
  780. #define FOBX_FLAG_ENCLOSED_ALLOCATED (0x4000000)
  781. //
  782. // this flag specfies if the FOBX was included in the count of dormant
  783. // files against the server.
  784. //
  785. #define FOBX_FLAG_MARKED_AS_DORMANT (0x8000000)
  786. //
  787. // this flag notes down the fact that some writes have been issued on this FOBX
  788. // this is used to issue flushes on close
  789. //
  790. #define FOBX_FLAG_WRITES_ISSUED (0x10000000)
  791. #ifdef __cplusplus
  792. typedef struct _FOBX : public MRX_FOBX {
  793. #else // !__cplusplus
  794. typedef struct _FOBX {
  795. //
  796. // the portion of FOBX visible to the mini redirectors
  797. //
  798. union {
  799. MRX_FOBX;
  800. struct {
  801. MRX_NORMAL_NODE_HEADER spacer;
  802. PSRV_OPEN SrvOpen;
  803. };
  804. };
  805. #endif // __cplusplus
  806. //
  807. // a serial number....it wraps but not often
  808. //
  809. ULONG FobxSerialNumber;
  810. //
  811. // list entry to wire the FOBX to the list of FOBXs maintained in
  812. // the associated SRV_OPEN
  813. //
  814. LIST_ENTRY FobxQLinks;
  815. //
  816. // list entry to gather all the FOBX instance marked for garbage collection
  817. // scavenging
  818. //
  819. LIST_ENTRY ScavengerFinalizationList;
  820. //
  821. // list entry to thread together all the FOBXs which have a pending close
  822. // operation.
  823. //
  824. LIST_ENTRY ClosePendingList;
  825. BOOLEAN UpperFinalizationDone;
  826. BOOLEAN ContainsWildCards;
  827. BOOLEAN fOpenCountDecremented;
  828. //
  829. // Parameters depending on the type of file opened, pipe/file etc.
  830. //
  831. union {
  832. struct {
  833. union {
  834. #ifndef __cplusplus
  835. MRX_PIPE_HANDLE_INFORMATION;
  836. #endif // __cplusplus
  837. MRX_PIPE_HANDLE_INFORMATION PipeHandleInformation;
  838. };
  839. LARGE_INTEGER CollectDataTime;
  840. ULONG CollectDataSize;
  841. THROTTLING_STATE ThrottlingState; // for peek and read om msgmodepipes
  842. //
  843. // these serialization Qs must be together
  844. // and read must be the first
  845. //
  846. LIST_ENTRY ReadSerializationQueue;
  847. LIST_ENTRY WriteSerializationQueue;
  848. } NamedPipe;
  849. struct {
  850. RXVBO PredictedReadOffset;
  851. RXVBO PredictedWriteOffset;
  852. THROTTLING_STATE LockThrottlingState; // for locks
  853. LARGE_INTEGER LastLockOffset;
  854. LARGE_INTEGER LastLockRange;
  855. } DiskFile;
  856. } Specific;
  857. } FOBX, *PFOBX;
  858. #define FOBX_NUMBER_OF_SERIALIZATION_QUEUES 2
  859. //
  860. // The RDBSS wrapper relies upon ref. counting to mark the instances of
  861. // various data structures. The following macros implement a debugging
  862. // mechanism to track/log the reference counts associated with various
  863. // data structures. A fine grained control to monitor each data structure
  864. // separately is provided. Each of these can be further controlled to either
  865. // print the tracking info or log it.
  866. //
  867. #define RDBSS_REF_TRACK_SRVCALL (0x00000001)
  868. #define RDBSS_REF_TRACK_NETROOT (0x00000002)
  869. #define RDBSS_REF_TRACK_VNETROOT (0x00000004)
  870. #define RDBSS_REF_TRACK_NETFOBX (0x00000008)
  871. #define RDBSS_REF_TRACK_NETFCB (0x00000010)
  872. #define RDBSS_REF_TRACK_SRVOPEN (0x00000020)
  873. #define RX_LOG_REF_TRACKING (0x80000000)
  874. #define RX_PRINT_REF_TRACKING (0x40000000)
  875. //
  876. // The reference count tracking mechanism is activated by setting the following
  877. // variable to the appropriate value defined above.
  878. //
  879. extern ULONG RdbssReferenceTracingValue;
  880. //
  881. // Macros for tracking the line number and the file of each reference and
  882. // derefernce on the data structure. on Non DBG builds they are defined as
  883. // NOTHING. For each data structure the appropriate reference/dereference
  884. // macro is defined, These should be used instead of raw manipulation of
  885. // the reference counts.
  886. //
  887. #ifdef DBG
  888. VOID
  889. RxpTrackReference (
  890. ULONG TraceType,
  891. PCHAR FileName,
  892. ULONG Line,
  893. PVOID Instance
  894. );
  895. BOOLEAN
  896. RxpTrackDereference (
  897. ULONG TraceType,
  898. PCHAR FileName,
  899. ULONG Line,
  900. PVOID Instance
  901. );
  902. #else
  903. #define RxpTrackReference(Type,File,Line,Instance) NOTHING
  904. #define RxpTrackDereference(Type,File,Line,Instance) NOTHING
  905. #endif
  906. #define REF_TRACING_ON(TraceMask) (TraceMask & RdbssReferenceTracingValue)
  907. #define PRINT_REF_COUNT(TYPE,Count) \
  908. if (REF_TRACING_ON( RDBSS_REF_TRACK_ ## TYPE ) && \
  909. (RdbssReferenceTracingValue & RX_PRINT_REF_TRACKING)) { \
  910. DbgPrint("%ld\n",Count); \
  911. }
  912. #define RxReferenceSrvCallAtDpc(SrvCall) \
  913. RxpTrackReference( RDBSS_REF_TRACK_SRVCALL, __FILE__, __LINE__, SrvCall ); \
  914. ASSERT( SrvCall->NodeReferenceCount > 1 ); \
  915. InterlockedIncrement( &SrvCall->NodeReferenceCount )
  916. #define RxReferenceSrvCall(SrvCall) \
  917. RxpTrackReference( RDBSS_REF_TRACK_SRVCALL, __FILE__, __LINE__, SrvCall ); \
  918. RxReference( SrvCall )
  919. #define RxDereferenceSrvCall(SrvCall,LockHoldingState) \
  920. RxpTrackDereference( RDBSS_REF_TRACK_SRVCALL, __FILE__, __LINE__, SrvCall ); \
  921. RxDereference(SrvCall, LockHoldingState )
  922. #define RxReferenceNetRoot(NetRoot) \
  923. RxpTrackReference( RDBSS_REF_TRACK_NETROOT, __FILE__, __LINE__, NetRoot ); \
  924. RxReference( NetRoot )
  925. #define RxDereferenceNetRoot( NetRoot, LockHoldingState ) \
  926. RxpTrackDereference( RDBSS_REF_TRACK_NETROOT, __FILE__, __LINE__, NetRoot );\
  927. RxDereference( NetRoot, LockHoldingState )
  928. #define RxReferenceVNetRoot(VNetRoot) \
  929. RxpTrackReference( RDBSS_REF_TRACK_VNETROOT, __FILE__, __LINE__, VNetRoot );\
  930. RxReference( VNetRoot )
  931. #define RxDereferenceVNetRoot( VNetRoot, LockHoldingState ) \
  932. RxpTrackDereference( RDBSS_REF_TRACK_VNETROOT, __FILE__, __LINE__, VNetRoot ); \
  933. RxDereference( VNetRoot, LockHoldingState )
  934. #define RxReferenceNetFobx(Fobx) \
  935. RxpTrackReference( RDBSS_REF_TRACK_NETFOBX, __FILE__, __LINE__, Fobx ); \
  936. RxReference( Fobx )
  937. #define RxDereferenceNetFobx(Fobx,LockHoldingState) \
  938. RxpTrackDereference( RDBSS_REF_TRACK_NETFOBX, __FILE__, __LINE__, Fobx ); \
  939. RxDereference( Fobx, LockHoldingState )
  940. #define RxReferenceSrvOpen(SrvOpen) \
  941. RxpTrackReference( RDBSS_REF_TRACK_SRVOPEN, __FILE__, __LINE__, SrvOpen ); \
  942. RxReference( SrvOpen )
  943. #define RxDereferenceSrvOpen( SrvOpen, LockHoldingState ) \
  944. RxpTrackDereference( RDBSS_REF_TRACK_SRVOPEN, __FILE__, __LINE__, SrvOpen); \
  945. RxDereference( SrvOpen, LockHoldingState )
  946. #define RxReferenceNetFcb(Fcb) \
  947. RxpTrackReference( RDBSS_REF_TRACK_NETFCB, __FILE__, __LINE__, Fcb ); \
  948. RxpReferenceNetFcb( Fcb )
  949. //
  950. // the following macros manipulate the reference count and also return the
  951. // status of the final derefence or finalize call. This results in the usage
  952. // of the , operator.
  953. //
  954. #define RxDereferenceNetFcb(Fcb) ( \
  955. ((LONG)RxpTrackDereference( RDBSS_REF_TRACK_NETFCB, __FILE__, __LINE__, Fcb )), \
  956. RxpDereferenceNetFcb( Fcb ))
  957. #define RxDereferenceAndFinalizeNetFcb(Fcb,RxContext,RecursiveFinalize,ForceFinalize) ( \
  958. RxpTrackDereference( RDBSS_REF_TRACK_NETFCB, __FILE__, __LINE__, Fcb ), \
  959. RxpDereferenceAndFinalizeNetFcb( Fcb, RxContext, RecursiveFinalize, ForceFinalize )) \
  960. //
  961. // Check for structure alignment errors
  962. //
  963. VOID
  964. RxCheckFcbStructuresForAlignment(
  965. VOID
  966. );
  967. //
  968. // SRV_CALL related routines.
  969. //
  970. PSRV_CALL
  971. RxCreateSrvCall (
  972. IN PRX_CONTEXT RxContext,
  973. IN PUNICODE_STRING Name,
  974. IN PUNICODE_STRING InnerNamePrefix OPTIONAL,
  975. IN PRX_CONNECTION_ID RxConnectionId
  976. );
  977. #define RxWaitForStableSrvCall(SRVCALL,RXCONTEXT) { \
  978. RxDbgTrace( 0, Dbg, ("RxWaitForStableSrvCall -- %lx\n",(SRVCALL)) ); \
  979. RxWaitForStableCondition( &(SRVCALL)->Condition, &(SRVCALL)->TransitionWaitList, (RXCONTEXT), NULL); \
  980. }
  981. #define RxWaitForStableSrvCall_Async(SRVCALL,RXCONTEXT,PNTSTATUS) { \
  982. RxDbgTrace( 0, Dbg, ("RxWaitForStableSrvCall -- %lx\n",(SRVCALL)) ); \
  983. RxWaitForStableCondition( &(SRVCALL)->Condition, &(SRVCALL)->TransitionWaitList, (RXCONTEXT), (PNTSTATUS) ); \
  984. }
  985. #define RxTransitionSrvCall(SRVCALL,CONDITION) \
  986. RxDbgTrace( 0, Dbg, ("RxTransitionSrvCall -- %lx Condition -- %ld\n",(SRVCALL),(CONDITION)) ); \
  987. RxUpdateCondition( (CONDITION), &(SRVCALL)->Condition, &(SRVCALL)->TransitionWaitList )
  988. BOOLEAN
  989. RxFinalizeSrvCall (
  990. OUT PSRV_CALL ThisSrvCall,
  991. IN BOOLEAN ForceFinalize
  992. );
  993. //
  994. // NET_ROOT related routines.
  995. //
  996. PNET_ROOT
  997. RxCreateNetRoot (
  998. IN PSRV_CALL SrvCall,
  999. IN PUNICODE_STRING Name,
  1000. IN ULONG NetRootFlags,
  1001. IN PRX_CONNECTION_ID OPTIONAL RxConnectionId
  1002. );
  1003. VOID
  1004. RxFinishNetRootInitialization (
  1005. IN OUT PNET_ROOT ThisNetRoot,
  1006. IN PMINIRDR_DISPATCH Dispatch,
  1007. IN PUNICODE_STRING InnerNamePrefix,
  1008. IN ULONG FcbSize,
  1009. IN ULONG SrvOpenSize,
  1010. IN ULONG FobxSize,
  1011. IN ULONG NetRootFlags
  1012. );
  1013. #define RxWaitForStableNetRoot(NETROOT,RXCONTEXT) \
  1014. RxDbgTrace(0, Dbg, ("RxWaitForStableNetRoot -- %lx\n",(NETROOT))); \
  1015. RxWaitForStableCondition(&(NETROOT)->Condition,&(NETROOT)->TransitionWaitList,(RXCONTEXT),NULL)
  1016. #define RxTransitionNetRoot(NETROOT,CONDITION) \
  1017. RxDbgTrace(0, Dbg, ("RxTransitionNetRoot -- %lx Condition -- %ld\n",(NETROOT),(CONDITION))); \
  1018. RxUpdateCondition((CONDITION),&(NETROOT)->Condition,&(NETROOT)->TransitionWaitList)
  1019. BOOLEAN
  1020. RxFinalizeNetRoot (
  1021. OUT PNET_ROOT ThisNetRoot,
  1022. IN BOOLEAN RecursiveFinalize,
  1023. IN BOOLEAN ForceFinalize
  1024. );
  1025. //
  1026. // V_NET_ROOT related routines
  1027. //
  1028. NTSTATUS
  1029. RxInitializeVNetRootParameters (
  1030. PRX_CONTEXT RxContext,
  1031. OUT LUID *LogonId,
  1032. OUT PULONG SessionId,
  1033. OUT PUNICODE_STRING *UserNamePtr,
  1034. OUT PUNICODE_STRING *UserDomainNamePtr,
  1035. OUT PUNICODE_STRING *PasswordPtr,
  1036. OUT PULONG Flags
  1037. );
  1038. VOID
  1039. RxUninitializeVNetRootParameters (
  1040. IN PUNICODE_STRING UserName,
  1041. IN PUNICODE_STRING UserDomainName,
  1042. IN PUNICODE_STRING Password,
  1043. OUT PULONG Flags
  1044. );
  1045. PV_NET_ROOT
  1046. RxCreateVNetRoot (
  1047. IN PRX_CONTEXT RxContext,
  1048. IN PNET_ROOT NetRoot,
  1049. IN PUNICODE_STRING CanonicalName,
  1050. IN PUNICODE_STRING LocalNetRootName,
  1051. IN PUNICODE_STRING FilePath,
  1052. IN PRX_CONNECTION_ID RxConnectionId
  1053. );
  1054. BOOLEAN
  1055. RxFinalizeVNetRoot (
  1056. OUT PV_NET_ROOT ThisVNetRoot,
  1057. IN BOOLEAN RecursiveFinalize,
  1058. IN BOOLEAN ForceFinalize
  1059. );
  1060. #define RxWaitForStableVNetRoot(VNETROOT,RXCONTEXT) \
  1061. RxDbgTrace( 0, Dbg, ("RxWaitForStableVNetRoot -- %lx\n",(VNETROOT)) ); \
  1062. RxWaitForStableCondition( &(VNETROOT)->Condition, &(VNETROOT)->TransitionWaitList, (RXCONTEXT), NULL )
  1063. #define RxTransitionVNetRoot(VNETROOT,CONDITION) \
  1064. RxDbgTrace( 0, Dbg, ("RxTransitionVNetRoot -- %lx Condition -- %ld\n", (VNETROOT), (CONDITION)) ); \
  1065. RxUpdateCondition( (CONDITION), &(VNETROOT)->Condition, &(VNETROOT)->TransitionWaitList )
  1066. #ifdef USE_FILESIZE_LOCK
  1067. //
  1068. // FCB related routines.
  1069. //
  1070. #define RxAcquireFileSizeLock(PFCB) { \
  1071. ExAcquireFastMutex( (PFCB)->Specific.Fcb.FileSizeLock ); \
  1072. }
  1073. #define RxReleaseFileSizeLock(PFCB) { \
  1074. ExReleaseFastMutex((PFCB)->Specific.Fcb.FileSizeLock); \
  1075. }
  1076. #endif
  1077. VOID
  1078. RxSetFileSizeWithLock (
  1079. IN OUT PFCB Fcb,
  1080. IN PLONGLONG FileSize
  1081. );
  1082. VOID
  1083. RxGetFileSizeWithLock (
  1084. IN PFCB Fcb,
  1085. OUT PLONGLONG FileSize
  1086. );
  1087. PFCB
  1088. RxCreateNetFcb (
  1089. IN PRX_CONTEXT RxContext,
  1090. IN PIRP Irp,
  1091. IN PV_NET_ROOT VNetRoot,
  1092. IN PUNICODE_STRING Name
  1093. );
  1094. #define RxWaitForStableNetFcb(FCB,RXCONTEXT) \
  1095. RxDbgTrace( 0, Dbg, ("RxWaitForStableNetFcb -- %lx\n",(FCB))); \
  1096. RxWaitForStableCondition( &(FCB)->Condition, &(FCB)->NonPaged->TransitionWaitList, (RXCONTEXT), NULL )
  1097. #define RxTransitionNetFcb(FCB,CONDITION) \
  1098. RxDbgTrace( 0, Dbg, ("RxTransitionNetFcb -- %lx Condition -- %ld\n",(FCB),(CONDITION))); \
  1099. RxUpdateCondition( (CONDITION), &(FCB)->Condition, &(FCB)->NonPaged->TransitionWaitList )
  1100. #define RxFormInitPacket(IP,I1,I1a,I2,I3,I4a,I4b,I5,I6,I7) (\
  1101. IP.pAttributes = I1, \
  1102. IP.pNumLinks = I1a, \
  1103. IP.pCreationTime = I2, \
  1104. IP.pLastAccessTime = I3, \
  1105. IP.pLastWriteTime = I4a, \
  1106. IP.pLastChangeTime = I4b, \
  1107. IP.pAllocationSize = I5, \
  1108. IP.pFileSize = I6, \
  1109. IP.pValidDataLength = I7, \
  1110. &IP)
  1111. #if DBG
  1112. #define ASSERT_CORRECT_FCB_STRUCTURE_DBG_ONLY(___thisfcb) {\
  1113. ASSERT( ___thisfcb->NonPaged == ___thisfcb->CopyOfNonPaged ); \
  1114. ASSERT( ___thisfcb->NonPaged->FcbBackPointer == ___thisfcb ); \
  1115. }
  1116. #else
  1117. #define ASSERT_CORRECT_FCB_STRUCTURE_DBG_ONLY(___thisfcb)
  1118. #endif
  1119. #define ASSERT_CORRECT_FCB_STRUCTURE(THIS_FCB__) { \
  1120. ASSERT( NodeTypeIsFcb(THIS_FCB__)); \
  1121. ASSERT( THIS_FCB__->NonPaged != NULL ); \
  1122. ASSERT( NodeType(THIS_FCB__->NonPaged) == RDBSS_NTC_NONPAGED_FCB); \
  1123. ASSERT_CORRECT_FCB_STRUCTURE_DBG_ONLY(THIS_FCB__) \
  1124. }
  1125. RX_FILE_TYPE
  1126. RxInferFileType (
  1127. IN PRX_CONTEXT RxContext
  1128. );
  1129. VOID
  1130. RxFinishFcbInitialization (
  1131. IN OUT PMRX_FCB Fcb,
  1132. IN RX_FILE_TYPE FileType,
  1133. IN PFCB_INIT_PACKET InitPacket OPTIONAL
  1134. );
  1135. #define RxWaitForStableSrvOpen(SRVOPEN,RXCONTEXT) \
  1136. RxDbgTrace( 0, Dbg, ("RxWaitForStableFcb -- %lx\n",(SRVOPEN)) ); \
  1137. RxWaitForStableCondition( &(SRVOPEN)->Condition, &(SRVOPEN)->TransitionWaitList, (RXCONTEXT), NULL )
  1138. #define RxTransitionSrvOpen(SRVOPEN,CONDITION) \
  1139. RxDbgTrace( 0, Dbg, ("RxTransitionSrvOpen -- %lx Condition -- %ld\n",(SRVOPEN),(CONDITION)) ); \
  1140. RxUpdateCondition( (CONDITION), &(SRVOPEN)->Condition, &(SRVOPEN)->TransitionWaitList )
  1141. VOID
  1142. RxRemoveNameNetFcb (
  1143. OUT PFCB ThisFcb
  1144. );
  1145. VOID
  1146. RxpReferenceNetFcb (
  1147. PFCB Fcb
  1148. );
  1149. LONG
  1150. RxpDereferenceNetFcb (
  1151. PFCB Fcb
  1152. );
  1153. BOOLEAN
  1154. RxpDereferenceAndFinalizeNetFcb (
  1155. OUT PFCB ThisFcb,
  1156. IN PRX_CONTEXT RxContext,
  1157. IN BOOLEAN RecursiveFinalize,
  1158. IN BOOLEAN ForceFinalize
  1159. );
  1160. #if DBG
  1161. extern BOOLEAN RxLoudFcbOpsOnExes;
  1162. BOOLEAN
  1163. RxLoudFcbMsg(
  1164. PUCHAR msg,
  1165. PUNICODE_STRING Name
  1166. );
  1167. #else
  1168. #define RxLoudFcbMsg(a,b) (FALSE)
  1169. #endif
  1170. //
  1171. // SRV_OPEN related methods
  1172. //
  1173. PSRV_OPEN
  1174. RxCreateSrvOpen (
  1175. IN PV_NET_ROOT VNetRoot,
  1176. IN OUT PFCB Fcb
  1177. );
  1178. VOID
  1179. RxTransitionSrvOpenState (
  1180. OUT PSRV_OPEN ThisSrvOpen,
  1181. IN RX_BLOCK_CONDITION Condition
  1182. );
  1183. BOOLEAN
  1184. RxFinalizeSrvOpen (
  1185. OUT PSRV_OPEN ThisSrvOpen,
  1186. IN BOOLEAN RecursiveFinalize,
  1187. IN BOOLEAN ForceFinalize
  1188. );
  1189. #if 0
  1190. #else
  1191. INLINE
  1192. PUNICODE_STRING
  1193. GET_ALREADY_PREFIXED_NAME (
  1194. PMRX_SRV_OPEN SrvOpen,
  1195. PMRX_FCB Fcb)
  1196. {
  1197. PFCB ThisFcb = (PFCB)Fcb;
  1198. #if DBG
  1199. if (SrvOpen != NULL ) {
  1200. ASSERT( NodeType( SrvOpen ) == RDBSS_NTC_SRVOPEN );
  1201. ASSERT( ThisFcb != NULL );
  1202. ASSERT( NodeTypeIsFcb( Fcb) );
  1203. ASSERT( SrvOpen->pFcb == Fcb );
  1204. ASSERT( SrvOpen->pAlreadyPrefixedName == &ThisFcb->PrivateAlreadyPrefixedName );
  1205. }
  1206. #endif
  1207. return( &ThisFcb->PrivateAlreadyPrefixedName);
  1208. }
  1209. #endif
  1210. #define GET_ALREADY_PREFIXED_NAME_FROM_CONTEXT(Rxcontext) \
  1211. (GET_ALREADY_PREFIXED_NAME( (Rxcontext)->pRelevantSrvOpen, (Rxcontext)->pFcb ))
  1212. //
  1213. // FOBX related routines
  1214. //
  1215. PMRX_FOBX
  1216. RxCreateNetFobx (
  1217. OUT PRX_CONTEXT RxContext,
  1218. IN PMRX_SRV_OPEN MrxSrvOpen
  1219. );
  1220. BOOLEAN
  1221. RxFinalizeNetFobx (
  1222. OUT PFOBX ThisFobx,
  1223. IN BOOLEAN RecursiveFinalize,
  1224. IN BOOLEAN ForceFinalize
  1225. );
  1226. #endif // _FCB_STRUCTS_DEFINED_