Source code of Windows XP (NT5)
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.

1608 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. // this thread is one who has acquired the FCB for CreateSection. it is used
  531. // to deduce whether certain operations (notably queryfileinfo) have preacquired
  532. // the resources and will, therefore, run without blocking.
  533. //
  534. PETHREAD CreateSectionThread;
  535. //
  536. // used to check by mini redirs in order to decide whether to update the FCB
  537. //
  538. ULONG ulFileSizeVersion;
  539. //
  540. // The following union is cased off of the node type code for the fcb.
  541. // There is a seperate case for the directory versus file fcbs.
  542. //
  543. union {
  544. //
  545. // A File Control Block (Fcb)
  546. //
  547. struct {
  548. //
  549. // The following field will be used by the oplock module
  550. // to maintain current oplock information. BUT we dont do it
  551. // yet
  552. //
  553. // OPLOCK Oplock;
  554. //
  555. // The following field is used by the filelock module
  556. // to maintain current byte range locking information.
  557. //
  558. FILE_LOCK FileLock;
  559. //
  560. // This pointer is used to detect writes that eminated in the
  561. // cache manager's lazywriter. It prevents lazy writer threads,
  562. // who already have the Fcb shared, from trying to acquire it
  563. // exclusive, and thus causing a deadlock.
  564. //
  565. PVOID LazyWriteThread;
  566. //
  567. // do this wierdly so that I can call stuff be the inner or outer names
  568. //
  569. union {
  570. #ifndef __cplusplus
  571. LOWIO_PER_FCB_INFO;
  572. #endif // __cplusplus
  573. LOWIO_PER_FCB_INFO LowIoPerFcbInfo;
  574. };
  575. #ifdef USE_FILESIZE_LOCK
  576. PFAST_MUTEX FileSizeLock;
  577. #endif
  578. } Fcb;
  579. } Specific;
  580. //
  581. // The following field is used to verify that the Ea's for a file
  582. // have not changed between calls to query for Ea's. It is compared
  583. // with a similar field in a Fobx.
  584. //
  585. // IMPORTANT!! **** DO NOT MOVE THIS FIELD ****
  586. //
  587. // The slack space in the union above is computed from
  588. // the field offset of the EaModificationCount.
  589. //
  590. ULONG EaModificationCount;
  591. #if DBG
  592. PNON_PAGED_FCB CopyOfNonPaged; // copy of NonPaged so we can zap the real pointer and still find it
  593. #endif
  594. #ifdef RDBSS_TRACKER
  595. ULONG FcbAcquires[RX_FCBTRACKER_CASE_MAXIMUM]; // there are four types
  596. ULONG FcbReleases[RX_FCBTRACKER_CASE_MAXIMUM];
  597. #else
  598. #error tracker must be defined
  599. #endif
  600. PCHAR PagingIoResourceFile;
  601. ULONG PagingIoResourceLine;
  602. } FCB, *PFCB;
  603. //
  604. // Here are the Fcb state fields.
  605. //
  606. #define FCB_STATE_SRVOPEN_USED ( 0x80000000 )
  607. #define FCB_STATE_FOBX_USED ( 0x40000000 )
  608. #define FCB_STATE_ADDEDBACKSLASH ( 0x20000000 )
  609. #define FCB_STATE_NAME_ALREADY_REMOVED ( 0x10000000 )
  610. #define FCB_STATE_WRITECACHEING_ENABLED ( 0x08000000 )
  611. #define FCB_STATE_WRITEBUFFERING_ENABLED ( 0x04000000 )
  612. #define FCB_STATE_READCACHEING_ENABLED ( 0x02000000 )
  613. #define FCB_STATE_READBUFFERING_ENABLED ( 0x01000000 )
  614. #define FCB_STATE_OPENSHARING_ENABLED ( 0x00800000 )
  615. #define FCB_STATE_COLLAPSING_ENABLED ( 0x00400000 )
  616. #define FCB_STATE_LOCK_BUFFERING_ENABLED ( 0x00200000 )
  617. #define FCB_STATE_FILESIZECACHEING_ENABLED ( 0x00100000 )
  618. #define FCB_STATE_FILETIMECACHEING_ENABLED ( 0x00080000 )
  619. #define FCB_STATE_TIME_AND_SIZE_ALREADY_SET ( 0x00040000 )
  620. #define FCB_STATE_SPECIAL_PATH ( 0x00020000 )
  621. #define FCB_STATE_FILE_IS_SHADOWED ( 0x00010000 )
  622. #define FCB_STATE_FILE_IS_DISK_COMPRESSED ( 0x00008000 )
  623. #define FCB_STATE_FILE_IS_BUF_COMPRESSED ( 0x00004000 )
  624. #define FCB_STATE_BUFFERSTATE_CHANGING ( 0x00002000 )
  625. #define FCB_STATE_FAKEFCB ( 0x00001000 )
  626. #define FCB_STATE_DELAY_CLOSE ( 0x00000800 )
  627. #define FCB_STATE_READAHEAD_DEFERRED ( 0x00000100 )
  628. #define FCB_STATE_ORPHANED ( 0x00000080 )
  629. #define FCB_STATE_BUFFERING_STATE_CHANGE_PENDING ( 0x00000040 )
  630. #define FCB_STATE_TEMPORARY ( 0x00000020 )
  631. #define FCB_STATE_DISABLE_LOCAL_BUFFERING ( 0x00000010 )
  632. #define FCB_STATE_LWIO_ENABLED ( 0x00000008 )
  633. #define FCB_STATE_PAGING_FILE ( 0x00000004 )
  634. #define FCB_STATE_TRUNCATE_ON_CLOSE ( 0x00000002 )
  635. #define FCB_STATE_DELETE_ON_CLOSE ( 0x00000001 )
  636. #define FCB_STATE_BUFFERING_STATE_MASK \
  637. (( FCB_STATE_WRITECACHEING_ENABLED \
  638. | FCB_STATE_WRITEBUFFERING_ENABLED \
  639. | FCB_STATE_READCACHEING_ENABLED \
  640. | FCB_STATE_READBUFFERING_ENABLED \
  641. | FCB_STATE_OPENSHARING_ENABLED \
  642. | FCB_STATE_COLLAPSING_ENABLED \
  643. | FCB_STATE_LOCK_BUFFERING_ENABLED \
  644. | FCB_STATE_FILESIZECACHEING_ENABLED \
  645. | FCB_STATE_FILETIMECACHEING_ENABLED ))
  646. //
  647. // This is the MAX recursive resource limit.
  648. //
  649. #define MAX_FCB_ASYNC_ACQUIRE (0xf000)
  650. typedef struct _FCB_INIT_PACKET {
  651. PULONG pAttributes; // in the fcb this is DirentRxFlags;
  652. PULONG pNumLinks; // in the fcb this is NumberOfLinks;
  653. PLARGE_INTEGER pCreationTime; // these fields are the same as for the Fcb
  654. PLARGE_INTEGER pLastAccessTime;
  655. PLARGE_INTEGER pLastWriteTime;
  656. PLARGE_INTEGER pLastChangeTime;
  657. PLARGE_INTEGER pAllocationSize; // common header fields
  658. PLARGE_INTEGER pFileSize;
  659. PLARGE_INTEGER pValidDataLength;
  660. } FCB_INIT_PACKET;
  661. //
  662. // A SRV_OPEN contains
  663. // 0) signature and refcount
  664. // a) backpointer to the FCB
  665. // b) backpointer to the NET_ROOT //maybe
  666. // c) a list of FOXB structures
  667. // d) access rights and collapsability status
  668. // .
  669. // .
  670. // z) whatever additional storage is request by the minirdr (or creator of the block).
  671. //
  672. // The SRV_OPEN points to a structure describing a spevific open on the
  673. // server; multiple file objects and fileobject extensions (FOBXs) can
  674. // share the same srvopen if the access rights are correct. For example,
  675. // this would be where the FID is stored for SMBs. A list of these hangs
  676. // from the FCB. Similarly, all fileobject extensionss that share the same
  677. // serverside open are listed together here. Also here is information
  678. // about whether a new open of this FCB can share this serverside open
  679. // context; obviously the guys that pass the test on the list.
  680. //
  681. //
  682. // The SRVOPEN flags are split into two groups, i.e., visible to mini rdrs and invisible to mini rdrs.
  683. // The visible ones are defined above and the definitions for the invisible ones can be found
  684. // in fcb.h. The convention that has been adopted is that the lower 16 flags will be visible
  685. // to the mini rdr and the upper 16 flags will be reserved for the wrapper. This needs to be
  686. // enforced in defining new flags.
  687. //
  688. #define SRVOPEN_FLAG_ENCLOSED_ALLOCATED (0x10000)
  689. #define SRVOPEN_FLAG_FOBX_USED (0x20000)
  690. #define SRVOPEN_FLAG_SHAREACCESS_UPDATED (0x40000)
  691. #ifdef __cplusplus
  692. typedef struct _SRV_OPEN : public MRX_SRV_OPEN {
  693. #else // !__cplusplus
  694. typedef struct _SRV_OPEN {
  695. //
  696. // the portion of SRV_OPEN visible to all the mini redirectors.
  697. //
  698. union {
  699. MRX_SRV_OPEN;
  700. struct {
  701. MRX_NORMAL_NODE_HEADER spacer;
  702. PFCB Fcb; // the Fcb for this srv_open
  703. };
  704. };
  705. #endif // !__cplusplus
  706. BOOLEAN UpperFinalizationDone;
  707. //
  708. // the current condition of the SRV_OPEN, good/bad/in transition
  709. //
  710. RX_BLOCK_CONDITION Condition;
  711. //
  712. // Buffering state manager token
  713. //
  714. LONG BufferingToken;
  715. //
  716. // List Entry to thread together all the FCB instances marked
  717. // for garbage collection/scavenging.
  718. //
  719. LIST_ENTRY ScavengerFinalizationList;
  720. //
  721. // The list of contexts whose processing has been suspended pending the state
  722. // transition of the SRV_OPEN.
  723. //
  724. LIST_ENTRY TransitionWaitList;
  725. //
  726. // List Head for the list of FOBXs associated with this SRV_OPEN
  727. //
  728. LIST_ENTRY FobxList;
  729. //
  730. // The colocated instance of FOBX that is allocated whenever a SRV_OPEN
  731. // instance is allocated.
  732. //
  733. PFOBX InternalFobx;
  734. //
  735. // the data structure for maintaining the mapping between the key
  736. // associated with the SRV_OPEN instance by the mini redirector and
  737. // the SRV_OPEN instance
  738. //
  739. union {
  740. LIST_ENTRY SrvOpenKeyList;
  741. ULONG SequenceNumber;
  742. };
  743. NTSTATUS OpenStatus;
  744. } SRV_OPEN, *PSRV_OPEN;
  745. #define RxWriteCacheingAllowed(Fcb,SrvOpen) \
  746. (FlagOn( (Fcb)->FcbState, FCB_STATE_WRITECACHEING_ENABLED ) && \
  747. !FlagOn( (SrvOpen)->Flags, SRVOPEN_FLAG_DONTUSE_WRITE_CACHEING ))
  748. #define SRVOPEN_INIT_KEY (0)
  749. //
  750. // A FOBX contains
  751. // 0) signature and refcount
  752. // a) backpointer to the FCB
  753. // b) backpointer to the SRV_OPEN
  754. // c) context information about this open
  755. // ...
  756. // z) whatever additional storage is request by the minirdr (or creator of the block).
  757. //
  758. // The FOBX points to the "fileobject extension", i.e. all the stuff that
  759. // is per fileobject is not stored there because the IO system provides
  760. // fixed size filesystem objects (not a dig BTW, that's just the decision).
  761. // The FOBX for any file object is referenced by the FsContext2 field in
  762. // the fileobject. Even tho the FOBX is ordinarily a terminus in the
  763. // structure, it is currently refcounted anyway.
  764. // The FOBX flags are split into two groups, i.e., visible to mini rdrs and invisible to mini rdrs.
  765. // The visible ones are defined above and the definitions for the invisible ones can be found
  766. // in fcb.h. The convention that has been adopted is that the lower 16 flags will be visible
  767. // to the mini rdr and the upper 16 flags will be reserved for the wrapper. This needs to be
  768. // enforced in defining new flags.
  769. //
  770. #define FOBX_FLAG_MATCH_ALL (0x10000)
  771. //
  772. // This tells us whether we allocated buffers to hold search templates.
  773. //
  774. #define FOBX_FLAG_FREE_UNICODE (0x20000)
  775. //
  776. // These flags prevents cleanup from updating the modify time, etc.
  777. //
  778. #define FOBX_FLAG_USER_SET_LAST_WRITE (0x40000)
  779. #define FOBX_FLAG_USER_SET_LAST_ACCESS (0x80000)
  780. #define FOBX_FLAG_USER_SET_CREATION (0x100000)
  781. #define FOBX_FLAG_USER_SET_LAST_CHANGE (0x200000)
  782. //
  783. // This bit says the file object associated with this Fobx was opened for
  784. // read only access.
  785. //
  786. #define FOBX_FLAG_READ_ONLY (0x400000)
  787. //
  788. // the delete on close flag is used to track a file object that was opened with delete-on-close;
  789. // when this object is closed, we copy the bit to the fcb and make it global
  790. //
  791. #define FOBX_FLAG_DELETE_ON_CLOSE (0x800000)
  792. //
  793. // this bits is used by minirdrs that do not have NT semantics. for example, the smbmini has
  794. // to close a file before it can try a rename or delete. after the operation, we prevent people from
  795. // getting back in.
  796. //
  797. #define FOBX_FLAG_SRVOPEN_CLOSED (0x1000000)
  798. //
  799. // this bit is used to tell whether the original name was a UNC name so that
  800. // we can return the name the same way
  801. //
  802. #define FOBX_FLAG_UNC_NAME (0x2000000)
  803. //
  804. // this flag tells if this fobx is allocated as part of a larger structure
  805. //
  806. #define FOBX_FLAG_ENCLOSED_ALLOCATED (0x4000000)
  807. //
  808. // this flag specfies if the FOBX was included in the count of dormant
  809. // files against the server.
  810. //
  811. #define FOBX_FLAG_MARKED_AS_DORMANT (0x8000000)
  812. //
  813. // this flag notes down the fact that some writes have been issued on this FOBX
  814. // this is used to issue flushes on close
  815. //
  816. #define FOBX_FLAG_WRITES_ISSUED (0x10000000)
  817. #ifdef __cplusplus
  818. typedef struct _FOBX : public MRX_FOBX {
  819. #else // !__cplusplus
  820. typedef struct _FOBX {
  821. //
  822. // the portion of FOBX visible to the mini redirectors
  823. //
  824. union {
  825. MRX_FOBX;
  826. struct {
  827. MRX_NORMAL_NODE_HEADER spacer;
  828. PSRV_OPEN SrvOpen;
  829. };
  830. };
  831. #endif // __cplusplus
  832. //
  833. // a serial number....it wraps but not often
  834. //
  835. ULONG FobxSerialNumber;
  836. //
  837. // list entry to wire the FOBX to the list of FOBXs maintained in
  838. // the associated SRV_OPEN
  839. //
  840. LIST_ENTRY FobxQLinks;
  841. //
  842. // list entry to gather all the FOBX instance marked for garbage collection
  843. // scavenging
  844. //
  845. LIST_ENTRY ScavengerFinalizationList;
  846. //
  847. // list entry to thread together all the FOBXs which have a pending close
  848. // operation.
  849. //
  850. LIST_ENTRY ClosePendingList;
  851. BOOLEAN UpperFinalizationDone;
  852. BOOLEAN ContainsWildCards;
  853. BOOLEAN fOpenCountDecremented;
  854. //
  855. // Parameters depending on the type of file opened, pipe/file etc.
  856. //
  857. union {
  858. struct {
  859. union {
  860. #ifndef __cplusplus
  861. MRX_PIPE_HANDLE_INFORMATION;
  862. #endif // __cplusplus
  863. MRX_PIPE_HANDLE_INFORMATION PipeHandleInformation;
  864. };
  865. LARGE_INTEGER CollectDataTime;
  866. ULONG CollectDataSize;
  867. THROTTLING_STATE ThrottlingState; // for peek and read om msgmodepipes
  868. //
  869. // these serialization Qs must be together
  870. // and read must be the first
  871. //
  872. LIST_ENTRY ReadSerializationQueue;
  873. LIST_ENTRY WriteSerializationQueue;
  874. } NamedPipe;
  875. struct {
  876. RXVBO PredictedReadOffset;
  877. RXVBO PredictedWriteOffset;
  878. THROTTLING_STATE LockThrottlingState; // for locks
  879. LARGE_INTEGER LastLockOffset;
  880. LARGE_INTEGER LastLockRange;
  881. } DiskFile;
  882. } Specific;
  883. } FOBX, *PFOBX;
  884. #define FOBX_NUMBER_OF_SERIALIZATION_QUEUES 2
  885. //
  886. // The RDBSS wrapper relies upon ref. counting to mark the instances of
  887. // various data structures. The following macros implement a debugging
  888. // mechanism to track/log the reference counts associated with various
  889. // data structures. A fine grained control to monitor each data structure
  890. // separately is provided. Each of these can be further controlled to either
  891. // print the tracking info or log it.
  892. //
  893. #define RDBSS_REF_TRACK_SRVCALL (0x00000001)
  894. #define RDBSS_REF_TRACK_NETROOT (0x00000002)
  895. #define RDBSS_REF_TRACK_VNETROOT (0x00000004)
  896. #define RDBSS_REF_TRACK_NETFOBX (0x00000008)
  897. #define RDBSS_REF_TRACK_NETFCB (0x00000010)
  898. #define RDBSS_REF_TRACK_SRVOPEN (0x00000020)
  899. #define RX_LOG_REF_TRACKING (0x80000000)
  900. #define RX_PRINT_REF_TRACKING (0x40000000)
  901. //
  902. // The reference count tracking mechanism is activated by setting the following
  903. // variable to the appropriate value defined above.
  904. //
  905. extern ULONG RdbssReferenceTracingValue;
  906. //
  907. // Macros for tracking the line number and the file of each reference and
  908. // derefernce on the data structure. on Non DBG builds they are defined as
  909. // NOTHING. For each data structure the appropriate reference/dereference
  910. // macro is defined, These should be used instead of raw manipulation of
  911. // the reference counts.
  912. //
  913. #ifdef DBG
  914. VOID
  915. RxpTrackReference (
  916. ULONG TraceType,
  917. PCHAR FileName,
  918. ULONG Line,
  919. PVOID Instance
  920. );
  921. BOOLEAN
  922. RxpTrackDereference (
  923. ULONG TraceType,
  924. PCHAR FileName,
  925. ULONG Line,
  926. PVOID Instance
  927. );
  928. #else
  929. #define RxpTrackReference(Type,File,Line,Instance) NOTHING
  930. #define RxpTrackDereference(Type,File,Line,Instance) NOTHING
  931. #endif
  932. #define REF_TRACING_ON(TraceMask) (TraceMask & RdbssReferenceTracingValue)
  933. #define PRINT_REF_COUNT(TYPE,Count) \
  934. if (REF_TRACING_ON( RDBSS_REF_TRACK_ ## TYPE ) && \
  935. (RdbssReferenceTracingValue & RX_PRINT_REF_TRACKING)) { \
  936. DbgPrint("%ld\n",Count); \
  937. }
  938. #define RxReferenceSrvCallAtDpc(SrvCall) \
  939. RxpTrackReference( RDBSS_REF_TRACK_SRVCALL, __FILE__, __LINE__, SrvCall ); \
  940. ASSERT( SrvCall->NodeReferenceCount > 1 ); \
  941. InterlockedIncrement( &SrvCall->NodeReferenceCount )
  942. #define RxReferenceSrvCall(SrvCall) \
  943. RxpTrackReference( RDBSS_REF_TRACK_SRVCALL, __FILE__, __LINE__, SrvCall ); \
  944. RxReference( SrvCall )
  945. #define RxDereferenceSrvCall(SrvCall,LockHoldingState) \
  946. RxpTrackDereference( RDBSS_REF_TRACK_SRVCALL, __FILE__, __LINE__, SrvCall ); \
  947. RxDereference(SrvCall, LockHoldingState )
  948. #define RxReferenceNetRoot(NetRoot) \
  949. RxpTrackReference( RDBSS_REF_TRACK_NETROOT, __FILE__, __LINE__, NetRoot ); \
  950. RxReference( NetRoot )
  951. #define RxDereferenceNetRoot( NetRoot, LockHoldingState ) \
  952. RxpTrackDereference( RDBSS_REF_TRACK_NETROOT, __FILE__, __LINE__, NetRoot );\
  953. RxDereference( NetRoot, LockHoldingState )
  954. #define RxReferenceVNetRoot(VNetRoot) \
  955. RxpTrackReference( RDBSS_REF_TRACK_VNETROOT, __FILE__, __LINE__, VNetRoot );\
  956. RxReference( VNetRoot )
  957. #define RxDereferenceVNetRoot( VNetRoot, LockHoldingState ) \
  958. RxpTrackDereference( RDBSS_REF_TRACK_VNETROOT, __FILE__, __LINE__, VNetRoot ); \
  959. RxDereference( VNetRoot, LockHoldingState )
  960. #define RxReferenceNetFobx(Fobx) \
  961. RxpTrackReference( RDBSS_REF_TRACK_NETFOBX, __FILE__, __LINE__, Fobx ); \
  962. RxReference( Fobx )
  963. #define RxDereferenceNetFobx(Fobx,LockHoldingState) \
  964. RxpTrackDereference( RDBSS_REF_TRACK_NETFOBX, __FILE__, __LINE__, Fobx ); \
  965. RxDereference( Fobx, LockHoldingState )
  966. #define RxReferenceSrvOpen(SrvOpen) \
  967. RxpTrackReference( RDBSS_REF_TRACK_SRVOPEN, __FILE__, __LINE__, SrvOpen ); \
  968. RxReference( SrvOpen )
  969. #define RxDereferenceSrvOpen( SrvOpen, LockHoldingState ) \
  970. RxpTrackDereference( RDBSS_REF_TRACK_SRVOPEN, __FILE__, __LINE__, SrvOpen); \
  971. RxDereference( SrvOpen, LockHoldingState )
  972. #define RxReferenceNetFcb(Fcb) \
  973. RxpTrackReference( RDBSS_REF_TRACK_NETFCB, __FILE__, __LINE__, Fcb ); \
  974. RxpReferenceNetFcb( Fcb )
  975. //
  976. // the following macros manipulate the reference count and also return the
  977. // status of the final derefence or finalize call. This results in the usage
  978. // of the , operator.
  979. //
  980. #define RxDereferenceNetFcb(Fcb) ( \
  981. ((LONG)RxpTrackDereference( RDBSS_REF_TRACK_NETFCB, __FILE__, __LINE__, Fcb )), \
  982. RxpDereferenceNetFcb( Fcb ))
  983. #define RxDereferenceAndFinalizeNetFcb(Fcb,RxContext,RecursiveFinalize,ForceFinalize) ( \
  984. RxpTrackDereference( RDBSS_REF_TRACK_NETFCB, __FILE__, __LINE__, Fcb ), \
  985. RxpDereferenceAndFinalizeNetFcb( Fcb, RxContext, RecursiveFinalize, ForceFinalize )) \
  986. //
  987. // Check for structure alignment errors
  988. //
  989. VOID
  990. RxCheckFcbStructuresForAlignment(
  991. VOID
  992. );
  993. //
  994. // SRV_CALL related routines.
  995. //
  996. PSRV_CALL
  997. RxCreateSrvCall (
  998. IN PRX_CONTEXT RxContext,
  999. IN PUNICODE_STRING Name,
  1000. IN PUNICODE_STRING InnerNamePrefix OPTIONAL,
  1001. IN PRX_CONNECTION_ID RxConnectionId
  1002. );
  1003. #define RxWaitForStableSrvCall(SRVCALL,RXCONTEXT) { \
  1004. RxDbgTrace( 0, Dbg, ("RxWaitForStableSrvCall -- %lx\n",(SRVCALL)) ); \
  1005. RxWaitForStableCondition( &(SRVCALL)->Condition, &(SRVCALL)->TransitionWaitList, (RXCONTEXT), NULL); \
  1006. }
  1007. #define RxWaitForStableSrvCall_Async(SRVCALL,RXCONTEXT,PNTSTATUS) { \
  1008. RxDbgTrace( 0, Dbg, ("RxWaitForStableSrvCall -- %lx\n",(SRVCALL)) ); \
  1009. RxWaitForStableCondition( &(SRVCALL)->Condition, &(SRVCALL)->TransitionWaitList, (RXCONTEXT), (PNTSTATUS) ); \
  1010. }
  1011. #define RxTransitionSrvCall(SRVCALL,CONDITION) \
  1012. RxDbgTrace( 0, Dbg, ("RxTransitionSrvCall -- %lx Condition -- %ld\n",(SRVCALL),(CONDITION)) ); \
  1013. RxUpdateCondition( (CONDITION), &(SRVCALL)->Condition, &(SRVCALL)->TransitionWaitList )
  1014. BOOLEAN
  1015. RxFinalizeSrvCall (
  1016. OUT PSRV_CALL ThisSrvCall,
  1017. IN BOOLEAN RecursiveFinalize,
  1018. IN BOOLEAN ForceFinalize
  1019. );
  1020. //
  1021. // NET_ROOT related routines.
  1022. //
  1023. PNET_ROOT
  1024. RxCreateNetRoot (
  1025. IN PSRV_CALL SrvCall,
  1026. IN PUNICODE_STRING Name,
  1027. IN ULONG NetRootFlags,
  1028. IN PRX_CONNECTION_ID OPTIONAL RxConnectionId
  1029. );
  1030. VOID
  1031. RxFinishNetRootInitialization (
  1032. IN OUT PNET_ROOT ThisNetRoot,
  1033. IN PMINIRDR_DISPATCH Dispatch,
  1034. IN PUNICODE_STRING InnerNamePrefix,
  1035. IN ULONG FcbSize,
  1036. IN ULONG SrvOpenSize,
  1037. IN ULONG FobxSize,
  1038. IN ULONG NetRootFlags
  1039. );
  1040. #define RxWaitForStableNetRoot(NETROOT,RXCONTEXT) \
  1041. RxDbgTrace(0, Dbg, ("RxWaitForStableNetRoot -- %lx\n",(NETROOT))); \
  1042. RxWaitForStableCondition(&(NETROOT)->Condition,&(NETROOT)->TransitionWaitList,(RXCONTEXT),NULL)
  1043. #define RxTransitionNetRoot(NETROOT,CONDITION) \
  1044. RxDbgTrace(0, Dbg, ("RxTransitionNetRoot -- %lx Condition -- %ld\n",(NETROOT),(CONDITION))); \
  1045. RxUpdateCondition((CONDITION),&(NETROOT)->Condition,&(NETROOT)->TransitionWaitList)
  1046. BOOLEAN
  1047. RxFinalizeNetRoot (
  1048. OUT PNET_ROOT ThisNetRoot,
  1049. IN BOOLEAN RecursiveFinalize,
  1050. IN BOOLEAN ForceFinalize
  1051. );
  1052. //
  1053. // V_NET_ROOT related routines
  1054. //
  1055. NTSTATUS
  1056. RxInitializeVNetRootParameters (
  1057. PRX_CONTEXT RxContext,
  1058. OUT LUID *LogonId,
  1059. OUT PULONG SessionId,
  1060. OUT PUNICODE_STRING *UserNamePtr,
  1061. OUT PUNICODE_STRING *UserDomainNamePtr,
  1062. OUT PUNICODE_STRING *PasswordPtr,
  1063. OUT PULONG Flags
  1064. );
  1065. VOID
  1066. RxUninitializeVNetRootParameters (
  1067. IN PUNICODE_STRING UserName,
  1068. IN PUNICODE_STRING UserDomainName,
  1069. IN PUNICODE_STRING Password,
  1070. OUT PULONG Flags
  1071. );
  1072. PV_NET_ROOT
  1073. RxCreateVNetRoot (
  1074. IN PRX_CONTEXT RxContext,
  1075. IN PNET_ROOT NetRoot,
  1076. IN PUNICODE_STRING CanonicalName,
  1077. IN PUNICODE_STRING LocalNetRootName,
  1078. IN PUNICODE_STRING FilePath,
  1079. IN PRX_CONNECTION_ID RxConnectionId
  1080. );
  1081. BOOLEAN
  1082. RxFinalizeVNetRoot (
  1083. OUT PV_NET_ROOT ThisVNetRoot,
  1084. IN BOOLEAN RecursiveFinalize,
  1085. IN BOOLEAN ForceFinalize
  1086. );
  1087. #define RxWaitForStableVNetRoot(VNETROOT,RXCONTEXT) \
  1088. RxDbgTrace( 0, Dbg, ("RxWaitForStableVNetRoot -- %lx\n",(VNETROOT)) ); \
  1089. RxWaitForStableCondition( &(VNETROOT)->Condition, &(VNETROOT)->TransitionWaitList, (RXCONTEXT), NULL )
  1090. #define RxTransitionVNetRoot(VNETROOT,CONDITION) \
  1091. RxDbgTrace( 0, Dbg, ("RxTransitionVNetRoot -- %lx Condition -- %ld\n", (VNETROOT), (CONDITION)) ); \
  1092. RxUpdateCondition( (CONDITION), &(VNETROOT)->Condition, &(VNETROOT)->TransitionWaitList )
  1093. #ifdef USE_FILESIZE_LOCK
  1094. //
  1095. // FCB related routines.
  1096. //
  1097. #define RxAcquireFileSizeLock(PFCB) { \
  1098. ExAcquireFastMutex( (PFCB)->Specific.Fcb.FileSizeLock ); \
  1099. }
  1100. #define RxReleaseFileSizeLock(PFCB) { \
  1101. ExReleaseFastMutex((PFCB)->Specific.Fcb.FileSizeLock); \
  1102. }
  1103. #endif
  1104. VOID
  1105. RxSetFileSizeWithLock (
  1106. IN OUT PFCB Fcb,
  1107. IN PLONGLONG FileSize
  1108. );
  1109. VOID
  1110. RxGetFileSizeWithLock (
  1111. IN PFCB Fcb,
  1112. OUT PLONGLONG FileSize
  1113. );
  1114. PFCB
  1115. RxCreateNetFcb (
  1116. OUT PRX_CONTEXT RxContext,
  1117. IN PV_NET_ROOT VNetRoot,
  1118. IN PUNICODE_STRING Name
  1119. );
  1120. #define RxWaitForStableNetFcb(FCB,RXCONTEXT) \
  1121. RxDbgTrace(0, Dbg, ("RxWaitForStableNetFcb -- %lx\n",(FCB))); \
  1122. RxWaitForStableCondition( &(FCB)->Condition, &(FCB)->NonPaged->TransitionWaitList, (RXCONTEXT), NULL )
  1123. #define RxTransitionNetFcb(FCB,CONDITION) \
  1124. RxDbgTrace(0, Dbg, ("RxTransitionNetFcb -- %lx Condition -- %ld\n",(FCB),(CONDITION))); \
  1125. RxUpdateCondition( (CONDITION), &(FCB)->Condition, &(FCB)->NonPaged->TransitionWaitList )
  1126. #define RxFormInitPacket(IP,I1,I1a,I2,I3,I4a,I4b,I5,I6,I7) (\
  1127. IP.pAttributes = I1, \
  1128. IP.pNumLinks = I1a, \
  1129. IP.pCreationTime = I2, \
  1130. IP.pLastAccessTime = I3, \
  1131. IP.pLastWriteTime = I4a, \
  1132. IP.pLastChangeTime = I4b, \
  1133. IP.pAllocationSize = I5, \
  1134. IP.pFileSize = I6, \
  1135. IP.pValidDataLength = I7, \
  1136. &IP)
  1137. #if DBG
  1138. #define ASSERT_CORRECT_FCB_STRUCTURE_DBG_ONLY(___thisfcb) {\
  1139. ASSERT( ___thisfcb->NonPaged == ___thisfcb->CopyOfNonPaged ); \
  1140. ASSERT( ___thisfcb->NonPaged->FcbBackPointer == ___thisfcb ); \
  1141. }
  1142. #else
  1143. #define ASSERT_CORRECT_FCB_STRUCTURE_DBG_ONLY(___thisfcb)
  1144. #endif
  1145. #define ASSERT_CORRECT_FCB_STRUCTURE(THIS_FCB__) { \
  1146. ASSERT( NodeTypeIsFcb(THIS_FCB__)); \
  1147. ASSERT( THIS_FCB__->NonPaged != NULL ); \
  1148. ASSERT( NodeType(THIS_FCB__->NonPaged) == RDBSS_NTC_NONPAGED_FCB); \
  1149. ASSERT_CORRECT_FCB_STRUCTURE_DBG_ONLY(THIS_FCB__) \
  1150. }
  1151. RX_FILE_TYPE
  1152. RxInferFileType (
  1153. IN PRX_CONTEXT RxContext
  1154. );
  1155. VOID
  1156. RxFinishFcbInitialization (
  1157. IN OUT PMRX_FCB Fcb,
  1158. IN RX_FILE_TYPE FileType,
  1159. IN PFCB_INIT_PACKET InitPacket OPTIONAL
  1160. );
  1161. #define RxWaitForStableSrvOpen(SRVOPEN,RXCONTEXT) \
  1162. RxDbgTrace( 0, Dbg, ("RxWaitForStableFcb -- %lx\n",(SRVOPEN)) ); \
  1163. RxWaitForStableCondition( &(SRVOPEN)->Condition, &(SRVOPEN)->TransitionWaitList, (RXCONTEXT), NULL )
  1164. #define RxTransitionSrvOpen(SRVOPEN,CONDITION) \
  1165. RxDbgTrace( 0, Dbg, ("RxTransitionSrvOpen -- %lx Condition -- %ld\n",(SRVOPEN),(CONDITION)) ); \
  1166. RxUpdateCondition( (CONDITION), &(SRVOPEN)->Condition, &(SRVOPEN)->TransitionWaitList )
  1167. VOID
  1168. RxRemoveNameNetFcb (
  1169. OUT PFCB ThisFcb
  1170. );
  1171. VOID
  1172. RxpReferenceNetFcb (
  1173. PFCB Fcb
  1174. );
  1175. LONG
  1176. RxpDereferenceNetFcb (
  1177. PFCB Fcb
  1178. );
  1179. BOOLEAN
  1180. RxpDereferenceAndFinalizeNetFcb (
  1181. OUT PFCB ThisFcb,
  1182. IN PRX_CONTEXT RxContext,
  1183. IN BOOLEAN RecursiveFinalize,
  1184. IN BOOLEAN ForceFinalize
  1185. );
  1186. #if DBG
  1187. extern BOOLEAN RxLoudFcbOpsOnExes;
  1188. BOOLEAN
  1189. RxLoudFcbMsg(
  1190. PUCHAR msg,
  1191. PUNICODE_STRING Name
  1192. );
  1193. #else
  1194. #define RxLoudFcbMsg(a,b) (FALSE)
  1195. #endif
  1196. //
  1197. // SRV_OPEN related methods
  1198. //
  1199. PSRV_OPEN
  1200. RxCreateSrvOpen (
  1201. IN PV_NET_ROOT VNetRoot,
  1202. IN OUT PFCB Fcb
  1203. );
  1204. VOID
  1205. RxTransitionSrvOpenState (
  1206. OUT PSRV_OPEN ThisSrvOpen,
  1207. IN RX_BLOCK_CONDITION Condition
  1208. );
  1209. BOOLEAN
  1210. RxFinalizeSrvOpen (
  1211. OUT PSRV_OPEN ThisSrvOpen,
  1212. IN BOOLEAN RecursiveFinalize,
  1213. IN BOOLEAN ForceFinalize
  1214. );
  1215. #if 0
  1216. #else
  1217. INLINE
  1218. PUNICODE_STRING
  1219. GET_ALREADY_PREFIXED_NAME (
  1220. PMRX_SRV_OPEN SrvOpen,
  1221. PMRX_FCB Fcb)
  1222. {
  1223. PFCB ThisFcb = (PFCB)Fcb;
  1224. #if DBG
  1225. if (SrvOpen != NULL ) {
  1226. ASSERT( NodeType( SrvOpen ) == RDBSS_NTC_SRVOPEN );
  1227. ASSERT( ThisFcb != NULL );
  1228. ASSERT( NodeTypeIsFcb( Fcb) );
  1229. ASSERT( SrvOpen->pFcb == Fcb );
  1230. ASSERT( SrvOpen->pAlreadyPrefixedName == &ThisFcb->PrivateAlreadyPrefixedName );
  1231. }
  1232. #endif
  1233. return( &ThisFcb->PrivateAlreadyPrefixedName);
  1234. }
  1235. #endif
  1236. #define GET_ALREADY_PREFIXED_NAME_FROM_CONTEXT(Rxcontext) \
  1237. (GET_ALREADY_PREFIXED_NAME( (Rxcontext)->pRelevantSrvOpen, (Rxcontext)->pFcb ))
  1238. //
  1239. // FOBX related routines
  1240. //
  1241. PMRX_FOBX
  1242. RxCreateNetFobx (
  1243. OUT PRX_CONTEXT RxContext,
  1244. IN PMRX_SRV_OPEN MrxSrvOpen
  1245. );
  1246. BOOLEAN
  1247. RxFinalizeNetFobx (
  1248. OUT PFOBX ThisFobx,
  1249. IN BOOLEAN RecursiveFinalize,
  1250. IN BOOLEAN ForceFinalize
  1251. );
  1252. #endif // _FCB_STRUCTS_DEFINED_