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.

1830 lines
50 KiB

  1. /*++
  2. Copyright (c) 1989-2000 Microsoft Corporation
  3. Module Name:
  4. UdfStruc.h
  5. Abstract:
  6. This module defines the data structures that make up the major internal
  7. parts of the Udfs file system.
  8. In-Memory structures:
  9. The global data structures with the UdfDataRecord. It contains a pointer
  10. to a File System Device object and a queue of Vcb's. There is a Vcb for
  11. every currently or previously mounted volumes. We may be in the process
  12. of tearing down the Vcb's which have been dismounted. The Vcb's are
  13. allocated as an extension to a volume device object.
  14. +---------+
  15. | UdfData | +--------+
  16. | | --> |FilSysDo|
  17. | | | |
  18. | | <+ +--------+
  19. +---------+ |
  20. |
  21. | +--------+ +--------+
  22. | |VolDo | |VolDo |
  23. | | | | |
  24. | +--------+ +--------+
  25. +> |Vcb | <-> |Vcb | <-> ...
  26. | | | |
  27. +--------+ +--------+
  28. Each Vcb contains a table of all the Fcbs for the volume indexed by
  29. their FileId. Each Vcb contains a pointer to the root directory of
  30. the volume. Each directory Fcb contains a queue of child Lcb's for
  31. its children. Each Lcb is queued onto both its parent and child Fcb.
  32. There can also be detached subtrees due to open operations by Id where
  33. the Fcb's are not connected to the root.
  34. The following diagram shows the root structure.
  35. +--------+ +--------+
  36. | Vcb |---->| Fcb |-------------------------------------------------------------------+
  37. | | | Table |----------------------------------------------------------------+ |
  38. | |--+ | |-------------------------------------------------------------+ | |
  39. +--------+ | +--------+ | | |
  40. | | | | | | |
  41. | | | +---------------------------------------------+ | | |
  42. | V +-----------------------+ | | | |
  43. | +--------+ | | | | |
  44. | |RootFcb | V V | | |
  45. +->| | +-----+ +--------+ +--------+ | | |
  46. | |<-->| Lcb |<-->|Child | +-----+ |Child | | | |
  47. +--------+ +-----+ | Fcb |<-->| Lcb |<-->| Fcb |<--> ... | | |
  48. | | +-----+ | | | | |
  49. +--------+ +--------+ | | |
  50. | | |
  51. (Freestanding sub-tree) | | |
  52. +--------+ | | |
  53. |OpenById|<-------------------------------------------------------------+ | |
  54. | Dir | +--------+ | |
  55. | |--->|OpenById|<--------------------------------------------------+ |
  56. +--------+ | Child | +--------+ |
  57. | Dir |--->|OpenById|<---------------------------------------+
  58. +--------+ | Child |
  59. | File |
  60. +--------+
  61. Attached to each Directory Fcb is an prefix table containing the
  62. Lcbs pointing to children of this directory for which there is an Fcb.
  63. +--------+ +--------+
  64. | Dir | | Prefix |
  65. | Fcb |----->| Table |--------------------+
  66. | | | |-------+ |
  67. +--------+ +--------+ | |
  68. ^ | | |
  69. | | | |
  70. | V V V
  71. | +--------+ +--------+ +--------+
  72. | | Lcb | | Lcb | | Lcb |
  73. +---------->| |<-->| |<-->| |
  74. +--------+ +--------+ +--------+
  75. Each file object open on a UDF volume contains two context pointers. The
  76. first will point back to the Fcb for the file object. The second, if present,
  77. points to a Ccb (ContextControlBlock) which contains the per-handle information.
  78. This includes the state of any directory enumeration and the Lcb used to open
  79. this file object.
  80. +--------+ +--------+ +--------+
  81. | Fcb |<------| File | | Ccb |
  82. | | | Object|--->| |
  83. | | | | | |
  84. +--------+ +--------+ +--------+
  85. ^ ^
  86. | | +--------+ +--------+
  87. | | | File | | Ccb |
  88. | +---------| Object|--->| |
  89. | | | | |
  90. | +--------+ +--------+
  91. |
  92. | +--------+
  93. | |Stream |
  94. +--------------| File |
  95. | Object|
  96. +--------+
  97. Synchronization:
  98. 1. A resource in the UdfData synchronizes access to the Vcb queue. This
  99. is used during mount/verify/dismount operations.
  100. 2. A resource in the Vcb is used to synchronize access to Vcb for
  101. open/close operations. Typically acquired shared, it
  102. is acquired exclusively to lock out these operations.
  103. 3. A second resource in the Vcb is used to synchronize all file operations.
  104. Typically acquired shared, it is acquired exclusively to lock
  105. out all file operations. Acquiring both Vcb resources will lock
  106. the entire volume.
  107. 4. A resource in the nonpaged Fcb will synchronize open/close operations
  108. on an Fcb.
  109. 5. A fast mutex in the Vcb will protect access to the Fcb table and
  110. the open counts in the Vcb. It is also used to modify the reference
  111. counts in all Fcbs/Lcbs. This mutex cannot be acquired
  112. exclusely and is an end resource.
  113. 6. A fast mutex in the Fcb will synchronize access to all Fcb fields
  114. which aren't synchronized in some other way. A thread may acquire
  115. mutexes for multiple Fcb's as long as it works it way toward the
  116. root of the tree. This mutex can also be acquired recursively.
  117. 7. Normal locking order is UdfData/Vcb/Fcb starting at any point in this
  118. chain. The Vcb is required prior to acquiring resources for multiple
  119. files. Shared ownership of the Vcb is sufficient in this case.
  120. 8. Normal locking order when acquiring multiple Fcb's is from some
  121. starting Fcb and walking towards the root of tree. Create typically
  122. walks down the tree. In this case we will attempt to acquire the
  123. next node optimistically and if that fails we will reference
  124. the current node in the tree, release it and acquire the next node.
  125. At that point it will be safe to reacquire the parent node.
  126. 9. Locking order for the Fcb (via the fast mutex) will be from leaf of
  127. tree back towards the root. No other resource may be acquired
  128. after locking the Vcb (other than in-page reads).
  129. 10. Cleanup operations only lock the Vcb and Fcb long enough to change the
  130. critical counts and share access fields. No reason to synchronize
  131. otherwise. None of the structures can go away from beneath us
  132. in this case.
  133. // @@BEGIN_DDKSPLIT
  134. Author:
  135. Dan Lovinger [DanLo] 31-May-1996
  136. Revision History:
  137. Tom Jolly [TomJolly] 1-March-2000 UDF 2.01 support
  138. // @@END_DDKSPLIT
  139. --*/
  140. #ifndef _UDFSTRUC_
  141. #define _UDFSTRUC_
  142. typedef PVOID PBCB;
  143. //
  144. // The following structure is used to encapsulate the converted timestamps for
  145. // straightforward referencing.
  146. //
  147. typedef struct _TIMESTAMP_BUNDLE {
  148. LARGE_INTEGER CreationTime;
  149. LARGE_INTEGER AccessTime;
  150. LARGE_INTEGER ModificationTime;
  151. } TIMESTAMP_BUNDLE, *PTIMESTAMP_BUNDLE;
  152. //
  153. // Stack snapshot stuff.
  154. //
  155. typedef struct _STACK_SNAP {
  156. PVOID BufferPage;
  157. ULONG Mj;
  158. ULONG Mn;
  159. NTSTATUS ExceptionCode;
  160. ULONG_PTR StackLow;
  161. ULONG_PTR StackHigh;
  162. PETHREAD Thread;
  163. } STACK_SNAP, *PSTACK_SNAP;
  164. #define UDF_IRPCONTEXT_BACKTRACE_DEPTH 32
  165. //
  166. // The UDF_DATA record is the top record in the UDF file system in-memory
  167. // data structure. This structure must be allocated from non-paged pool.
  168. //
  169. #define NUMBER_OF_FS_OBJECTS 2
  170. typedef struct _UDF_DATA {
  171. //
  172. // The type and size of this record (must be UDFS_NTC_DATA_HEADER)
  173. //
  174. NODE_TYPE_CODE NodeTypeCode;
  175. NODE_BYTE_SIZE NodeByteSize;
  176. //
  177. // A pointer to the Driver object we were initialized with
  178. //
  179. PDRIVER_OBJECT DriverObject;
  180. //
  181. // Vcb queue.
  182. //
  183. LIST_ENTRY VcbQueue;
  184. //
  185. // The following fields are used to allocate IRP context structures
  186. // using a lookaside list, and other fixed sized structures from a
  187. // small cache. We use the CdData mutex to protext these structures.
  188. //
  189. ULONG IrpContextDepth;
  190. ULONG IrpContextMaxDepth;
  191. SINGLE_LIST_ENTRY IrpContextList;
  192. //
  193. // Filesystem device objects for UDFS.
  194. //
  195. PDEVICE_OBJECT FileSystemDeviceObjects[NUMBER_OF_FS_OBJECTS];
  196. //
  197. // Following are used to manage the async and delayed close queue.
  198. //
  199. // FspCloseActive - Indicates whether there is a thread processing the
  200. // two close queues.
  201. // ReduceDelayedClose - Indicates that we have hit the upper threshold
  202. // for the delayed close queue and need to reduce it to lower threshold.
  203. //
  204. // AsyncCloseQueue - Queue of IrpContext waiting for async close operation.
  205. // AsyncCloseCount - Number of entries on the async close queue.
  206. //
  207. // DelayedCloseQueue - Queue of IrpContextLite waiting for delayed close
  208. // operation.
  209. // MaxDelayedCloseCount - Trigger delay close work at this threshold.
  210. // MinDelayedCloseCount - Turn off delay close work at this threshold.
  211. // DelayedCloseCount - Number of entries on the delayted close queue.
  212. //
  213. // CloseItem - Workqueue item used to start FspClose thread.
  214. //
  215. LIST_ENTRY AsyncCloseQueue;
  216. ULONG AsyncCloseCount;
  217. BOOLEAN FspCloseActive;
  218. BOOLEAN ReduceDelayedClose;
  219. USHORT PadUshort;
  220. //
  221. // The following fields describe the deferred close file objects.
  222. //
  223. LIST_ENTRY DelayedCloseQueue;
  224. ULONG DelayedCloseCount;
  225. ULONG MaxDelayedCloseCount;
  226. ULONG MinDelayedCloseCount;
  227. //
  228. // Fast mutex used to lock the fields of this structure.
  229. //
  230. PVOID UdfDataLockThread;
  231. FAST_MUTEX UdfDataMutex;
  232. //
  233. // A resource variable to control access to the global UDFS data record
  234. //
  235. ERESOURCE DataResource;
  236. //
  237. // Cache manager call back structure, which must be passed on each call
  238. // to CcInitializeCacheMap.
  239. //
  240. CACHE_MANAGER_CALLBACKS CacheManagerCallbacks;
  241. CACHE_MANAGER_CALLBACKS CacheManagerVolumeCallbacks;
  242. //
  243. // This is the ExWorkerItem that does both kinds of deferred closes.
  244. //
  245. WORK_QUEUE_ITEM CloseItem;
  246. #ifdef UDF_CAPTURE_BACKTRACES
  247. //
  248. // Information captured from the 2 most recent exceptions filtered.
  249. //
  250. STACK_SNAP A;
  251. STACK_SNAP B;
  252. BOOLEAN CurrentSnapIsA;
  253. FAST_MUTEX ExceptionInfoMutex;
  254. #endif
  255. } UDF_DATA, *PUDF_DATA;
  256. //
  257. // A PARTITION will record the VSN/LSN -> PSN retrieval information for a
  258. // partition reference. Since we do not support multi-volume 13346/UDF,
  259. // we will omit noting the volume sequence number that would tell us which
  260. // piece of media contained the partition.
  261. //
  262. // There are currently three types of partitions used during operation: physical,
  263. // sparable and virtual. However, since sparing merely adds another last layer
  264. // of quick indirection, we consider them as a minor extension of a physical
  265. // partition.
  266. //
  267. typedef enum _PARTITION_TYPE {
  268. Uninitialized,
  269. Physical,
  270. Virtual
  271. } PARTITION_TYPE, *PPARTITION_TYPE;
  272. //
  273. // A Physical partition corresponds to a single extent of the volume.
  274. //
  275. typedef struct _PARTITION_PHYSICAL {
  276. //
  277. // Starting Psn and length in sectors
  278. //
  279. ULONG Start;
  280. ULONG Length;
  281. //
  282. // The partition number is specified by the LVD, and refers to
  283. // a specific partition descriptor on the media. We use this
  284. // in the second pass of partition discovery.
  285. //
  286. ULONG PartitionNumber;
  287. PNSR_PART PartitionDescriptor;
  288. //
  289. // Spared partition map, saved temporarily between
  290. // logical volume descriptor analysis and partition
  291. // descriptor discover/pcb completion.
  292. //
  293. PPARTMAP_SPARABLE SparingMap;
  294. } PARTITION_PHYSICAL, *PPARTITION_PHYSICAL;
  295. //
  296. // A Virtual partition is a remapping from VSN to LSN on a given Physical
  297. // partition. The remapping is done through the VAT FCB.
  298. //
  299. typedef struct _PARTITION_VIRTUAL{
  300. //
  301. // The maximum Vbn in the virtual partition.
  302. //
  303. ULONG Length;
  304. //
  305. // A virtual partition refers to its "host" physical partition by partition
  306. // number, which we translate to a partition reference during the second pass
  307. // of partition discovery.
  308. //
  309. // Example: if the virtual partition is reference 1, hosted on partition 156
  310. // (which is reference 0 for this logical volume), then NSRLBA 100/1 would
  311. // refer to the block on partition ref 0 as mapped in the VAT at entry 100.
  312. //
  313. USHORT RelatedReference;
  314. } PARTITION_VIRTUAL, *PPARTITION_VIRTUAL;
  315. //
  316. // There is exactly one PARTITION per partition. It is responsible for mapping
  317. // from some form of logical sector to a physical sector.
  318. //
  319. typedef struct _UDF_PARTITION {
  320. //
  321. // This is the type of partition.
  322. //
  323. PARTITION_TYPE Type;
  324. union {
  325. PARTITION_PHYSICAL Physical;
  326. PARTITION_VIRTUAL Virtual;
  327. };
  328. } UDF_PARTITION, *PUDF_PARTITION;
  329. //
  330. // The Pcb (Partition control block) record corresponds to the partitions
  331. // which collectively form the mounted volume. Exactly one of these is
  332. // linked off of the Vcb.
  333. //
  334. typedef struct _PCB {
  335. //
  336. // The type and size of this record (must be UDFS_NTC_PCB)
  337. //
  338. NODE_TYPE_CODE NodeTypeCode;
  339. NODE_BYTE_SIZE NodeByteSize;
  340. //
  341. // This is the number of partitions in the map
  342. //
  343. USHORT Partitions;
  344. //
  345. // A bitmask of flags.
  346. //
  347. USHORT Flags;
  348. //
  349. // Sparing Mcb, if this volume has sparing.
  350. //
  351. PLARGE_MCB SparingMcb;
  352. //
  353. // This is the mapping table. A PCB will be dynamically sized
  354. // according to the number of partitions forming the volume.
  355. //
  356. UDF_PARTITION Partition[0];
  357. } PCB, *PPCB;
  358. //
  359. // Indicate what kinds of partitions are contained for quick checks.
  360. //
  361. #define PCB_FLAG_PHYSICAL_PARTITION 0x0001
  362. #define PCB_FLAG_VIRTUAL_PARTITION 0x0002
  363. #define PCB_FLAG_SPARABLE_PARTITION 0x0004
  364. //
  365. // The Vmcb structure is a double mapped structure for mapping
  366. // between VBNs and LBNs using the MCB structures. The whole structure
  367. // is also protected by a private mutex. This record must be allocated
  368. // from non-paged pool.
  369. //
  370. //
  371. // We use an #if to snip out historical code in the Vmcb package that
  372. // dealt with write issues, leaving it for the future.
  373. //
  374. #define VMCB_WRITE_SUPPORT 0
  375. typedef struct _VMCB {
  376. //
  377. // The type and size of this record (must be UDFS_NTC_VMCB)
  378. //
  379. NODE_TYPE_CODE NodeTypeCode;
  380. NODE_BYTE_SIZE NodeByteSize;
  381. ERESOURCE Resource;
  382. MCB VbnIndexed; // maps VBNs to LBNs
  383. MCB LbnIndexed; // maps LBNs to VBNs
  384. ULONG MaximumLbn;
  385. ULONG SectorSize;
  386. } VMCB, *PVMCB;
  387. #define UDF_INVALID_VSN -1
  388. //
  389. // The Vcb (Volume control block) record corresponds to every
  390. // volume mounted by the file system. They are ordered in a queue off
  391. // of UdfData.VcbQueue.
  392. //
  393. // The Vcb will be in several conditions during its lifespan.
  394. //
  395. // NotMounted - Disk is not currently mounted (i.e. removed
  396. // from system) but cleanup and close operations are
  397. // supported.
  398. //
  399. // MountInProgress - State of the Vcb from the time it is
  400. // created until it is successfully mounted or the mount
  401. // fails.
  402. //
  403. // Mounted - Volume is currently in the mounted state.
  404. //
  405. // Invalid - User has invalidated the volume. Only legal operations
  406. // are cleanup and close.
  407. //
  408. // DismountInProgress - We have begun the process of tearing down the
  409. // Vcb. It can be deleted when all the references to it
  410. // have gone away.
  411. //
  412. typedef enum _VCB_CONDITION {
  413. VcbNotMounted = 0,
  414. VcbMountInProgress,
  415. VcbMounted,
  416. VcbInvalid,
  417. VcbDismountInProgress
  418. } VCB_CONDITION;
  419. typedef struct _VCB {
  420. //
  421. // The type and size of this record (must be UDFS_NTC_VCB)
  422. //
  423. NODE_TYPE_CODE NodeTypeCode;
  424. NODE_BYTE_SIZE NodeByteSize;
  425. //
  426. // Vpb for this volume.
  427. //
  428. PVPB Vpb;
  429. //
  430. // Pcb for this volume.
  431. //
  432. PPCB Pcb;
  433. //
  434. // Device object for the driver below us.
  435. //
  436. PDEVICE_OBJECT TargetDeviceObject;
  437. //
  438. // Link into queue of Vcb's in the UdfData structure. We will create a union with
  439. // a LONGLONG to force the Vcb to be quad-aligned.
  440. //
  441. union {
  442. LIST_ENTRY VcbLinks;
  443. LONGLONG Alignment;
  444. };
  445. //
  446. // State flags and condition for the Vcb.
  447. //
  448. ULONG VcbState;
  449. VCB_CONDITION VcbCondition;
  450. //
  451. // File object used to lock the volume.
  452. //
  453. PFILE_OBJECT VolumeLockFileObject;
  454. //
  455. // Media change count from device driver for bulletproof detection
  456. // of media movement
  457. //
  458. ULONG MediaChangeCount;
  459. //
  460. // Logical block size for this volume.
  461. //
  462. ULONG SectorSize;
  463. //
  464. // Associated shift size
  465. //
  466. ULONG SectorShift;
  467. //
  468. // LSN of the bounds that CD-UDF defines.
  469. //
  470. // S - start of the session that contains the AVD @ +256
  471. // N - end of the disc, another chance to find AVD @ -256,
  472. // and discovery of the VAT ICB.
  473. //
  474. // N may be unset until late in the mount sequence for a volume, since
  475. // the device may not respond to CD-style TOC requests, and only then
  476. // be a guess based on the partitons we find. S will be zero except in
  477. // the case of CD-UDF. In a mounted system, S will correspond to where
  478. // we started finding the volume descriptors that let us proceed.
  479. //
  480. ULONG BoundS;
  481. ULONG BoundN;
  482. //
  483. // Various counts for this Vcb.
  484. //
  485. // VcbCleanup - Open handles left on this system.
  486. // VcbReference - Number of reasons this Vcb is still present.
  487. // VcbUserReference - Number of user file objects still present.
  488. //
  489. ULONG VcbCleanup;
  490. ULONG VcbReference;
  491. ULONG VcbUserReference;
  492. //
  493. // These are the number of times a mounted Vcb will be referenced on behalf
  494. // of the system. See commentary in udfdata.h.
  495. //
  496. ULONG VcbResidualReference;
  497. ULONG VcbResidualUserReference;
  498. //
  499. // Fcb for the Volume Dasd file, root directory and the Vmcb-mapped Metadata stream.
  500. // The VAT Fcb is only created on CD UDF media, for the Virtual Allocation Table.
  501. //
  502. struct _FCB *VolumeDasdFcb;
  503. struct _FCB *RootIndexFcb;
  504. struct _FCB *MetadataFcb;
  505. struct _FCB *VatFcb;
  506. //
  507. // Offset from the beginning of the VAT stream to the first entry (UDF 2.0x has a header
  508. // at the beginning of the VAT), and number of entries in the VAT.
  509. //
  510. ULONG OffsetToFirstVATEntry;
  511. ULONG VATEntryCount;
  512. //
  513. // Vmcb for the metadata stream
  514. //
  515. VMCB Vmcb;
  516. //
  517. // Vmcb resource. This is used to synchronize mapping/purge operations on
  518. // the vmcb stream. Must be acquired shared around any map/unpin or ccread
  519. // on the vmcb, and exclusive for ccpurge. All mappings made in the current
  520. // thread must be dropped before attempting to acquire exclusive.
  521. //
  522. ERESOURCE VmcbMappingResource;
  523. //
  524. // Vcb resource. This is used to synchronize open/cleanup/close operations.
  525. //
  526. ERESOURCE VcbResource;
  527. //
  528. // File resource. This is used to synchronize all file operations except
  529. // open/cleanup/close.
  530. //
  531. ERESOURCE FileResource;
  532. //
  533. // Vcb fast mutex. This is used to synchronize the fields in the Vcb
  534. // when modified when the Vcb is not held exclusively. Included here
  535. // are the count fields and Fcb table.
  536. //
  537. // We also use this to synchronize changes to the Fcb reference field.
  538. //
  539. FAST_MUTEX VcbMutex;
  540. PVOID VcbLockThread;
  541. //
  542. // The following is used to synchronize the dir notify package.
  543. //
  544. PNOTIFY_SYNC NotifySync;
  545. //
  546. // The following is the head of a list of notify Irps.
  547. //
  548. LIST_ENTRY DirNotifyList;
  549. //
  550. // Fcb table. Synchronized with the Vcb fast mutex.
  551. //
  552. RTL_GENERIC_TABLE FcbTable;
  553. //
  554. // Preallocated VPB for swapout, so we are not forced to consider
  555. // must succeed pool.
  556. //
  557. PVPB SwapVpb;
  558. //
  559. // Information telling us what version of UDF we expect this disc to
  560. // conform to. NsrVersion will be one of VsdIdentNSR02 or VsdIdentNSR03
  561. // UdfXXXRead will be one of UDF_VERSION_XXX.
  562. //
  563. USHORT NsrVersion;
  564. USHORT UdfRevision;
  565. } VCB, *PVCB;
  566. #define VCB_STATE_LOCKED (0x00000001)
  567. #define VCB_STATE_REMOVABLE_MEDIA (0x00000002)
  568. #define VCB_STATE_NOTIFY_REMOUNT (0x00000004)
  569. #define VCB_STATE_METHOD_2_FIXUP (0x00000008)
  570. #define VCB_STATE_VMCB_INIT (0x00000010)
  571. #define VCB_STATE_VPB_NOT_ON_DEVICE (0x00000020)
  572. #define UDF_NSR_NO_VRS_FOUND 0xffff
  573. //
  574. // The Volume Device Object is an I/O system device object with a
  575. // workqueue and an VCB record appended to the end. There are multiple
  576. // of these records, one for every mounted volume, and are created during
  577. // a volume mount operation. The work queue is for handling an overload
  578. // of work requests to the volume.
  579. //
  580. typedef struct _VOLUME_DEVICE_OBJECT {
  581. DEVICE_OBJECT DeviceObject;
  582. //
  583. // The following field tells how many requests for this volume have
  584. // either been enqueued to ExWorker threads or are currently being
  585. // serviced by ExWorker threads. If the number goes above
  586. // a certain threshold, put the request on the overflow queue to be
  587. // executed later.
  588. //
  589. ULONG PostedRequestCount;
  590. //
  591. // The following field indicates the number of IRP's waiting
  592. // to be serviced in the overflow queue.
  593. //
  594. ULONG OverflowQueueCount;
  595. //
  596. // The following field contains the queue header of the overflow queue.
  597. // The Overflow queue is a list of IRP's linked via the IRP's ListEntry
  598. // field.
  599. //
  600. LIST_ENTRY OverflowQueue;
  601. //
  602. // The following spinlock protects access to all the above fields.
  603. //
  604. KSPIN_LOCK OverflowQueueSpinLock;
  605. //
  606. // This is the file system specific volume control block.
  607. //
  608. VCB Vcb;
  609. } VOLUME_DEVICE_OBJECT, *PVOLUME_DEVICE_OBJECT;
  610. //
  611. // Udfs file id is a large integer. This corresponds to the FileInternalInformation
  612. // query type and is used for internal FCB indexing.
  613. //
  614. typedef LARGE_INTEGER FILE_ID, *PFILE_ID;
  615. //
  616. // Lcb (Link Control Block), which corresponds to a link from a directory (or in
  617. // the future, other container objects) to a file (UDF File Identifier). There is
  618. // one of these for each name tuple in a prefix table.
  619. //
  620. typedef struct _LCB {
  621. //
  622. // Type and size of this record (must be UDFS_NTC_LCB)
  623. //
  624. NODE_TYPE_CODE NodeTypeCode;
  625. NODE_BYTE_SIZE NodeByteSize;
  626. //
  627. // Pointer to the Parent Fcb for this entry and queue for Parent to
  628. // find all referencing Lcbs. Corresponds to Fcb->ChildLcbQueue.
  629. //
  630. LIST_ENTRY ParentFcbLinks;
  631. struct _FCB *ParentFcb;
  632. //
  633. // Pointer to Child (referenced) Fcb for this entry and queue for Child
  634. // to find all referencing Lcbs. Corresponds to Fcb->ParentLcbQueue.
  635. //
  636. LIST_ENTRY ChildFcbLinks;
  637. struct _FCB *ChildFcb;
  638. //
  639. // Number of extra realtime references made to this Lcb.
  640. //
  641. ULONG Reference;
  642. //
  643. // Flags indicating the state of this Lcb.
  644. //
  645. ULONG Flags;
  646. //
  647. // File attributes to be merged with the child Fcb. UDF seperates interesting
  648. // information into the FID and FE so, properly, the name link (corresponding to
  649. // a FID) must record some extra information.
  650. //
  651. ULONG FileAttributes;
  652. //
  653. // Splay links in the prefix tree.
  654. //
  655. RTL_SPLAY_LINKS Links;
  656. //
  657. // The name of this link.
  658. //
  659. UNICODE_STRING FileName;
  660. } LCB, *PLCB;
  661. #define LCB_FLAG_IGNORE_CASE 0x00000001
  662. #define LCB_FLAG_SHORT_NAME 0x00000002
  663. #define LCB_FLAG_POOL_ALLOCATED 0x00000004
  664. //
  665. // We build a lookaside of Lcb capable of holding a reasonably sized name.
  666. //
  667. #define SIZEOF_LOOKASIDE_LCB ( sizeof( LCB ) + ( sizeof( WCHAR ) * 16 ))
  668. //
  669. // The following two structures are the separate union structures for
  670. // data and index Fcb's.
  671. //
  672. typedef enum _FCB_CONDITION {
  673. FcbGood = 1,
  674. FcbBad,
  675. FcbNeedsToBeVerified
  676. } FCB_CONDITION;
  677. typedef struct _FCB_NONPAGED {
  678. //
  679. // Type and size of this record must be UDFS_NTC_FCB_NONPAGED
  680. //
  681. NODE_TYPE_CODE NodeTypeCode;
  682. NODE_BYTE_SIZE NodeByteSize;
  683. //
  684. // The following field contains a record of special pointers used by
  685. // MM and Cache to manipluate section objects. Note that the values
  686. // are set outside of the file system. However the file system on an
  687. // open/create will set the file object's SectionObject field to
  688. // point to this field
  689. //
  690. SECTION_OBJECT_POINTERS SegmentObject;
  691. //
  692. // This is the resource structure for this Fcb.
  693. //
  694. ERESOURCE FcbResource;
  695. //
  696. // This is the FastMutex for this Fcb.
  697. //
  698. FAST_MUTEX FcbMutex;
  699. //
  700. // This is the mutex that is inserted into the FCB_ADVANCED_HEADER
  701. // FastMutex field
  702. //
  703. FAST_MUTEX AdvancedFcbHeaderMutex;
  704. } FCB_NONPAGED;
  705. typedef FCB_NONPAGED *PFCB_NONPAGED;
  706. typedef struct _FCB_DATA {
  707. //
  708. // The following field is used by the oplock module
  709. // to maintain current oplock information.
  710. //
  711. OPLOCK Oplock;
  712. //
  713. // The following field is used by the filelock module
  714. // to maintain current byte range locking information.
  715. // A file lock is allocated as needed.
  716. //
  717. PFILE_LOCK FileLock;
  718. } FCB_DATA, *PFCB_DATA;
  719. typedef struct _FCB_INDEX {
  720. //
  721. // Internal stream file for the directory.
  722. //
  723. PFILE_OBJECT FileObject;
  724. //
  725. // Root of splay trees for exact and ignore case prefix trees.
  726. //
  727. PRTL_SPLAY_LINKS ExactCaseRoot;
  728. PRTL_SPLAY_LINKS IgnoreCaseRoot;
  729. } FCB_INDEX, *PFCB_INDEX;
  730. //
  731. // The Fcb/Dcb record corresponds to every open file and directory, and to
  732. // every directory on an opened path.
  733. //
  734. typedef struct _FCB_CORE {
  735. //
  736. // The following field is used for fast I/O. It contains the node
  737. // type code and size, indicates if fast I/O is possible, contains
  738. // allocation, file, and valid data size, a resource, and call back
  739. // pointers for FastIoRead and FastMdlRead.
  740. //
  741. //
  742. // Node type codes for the Fcb must be one of the following.
  743. //
  744. // UDFS_NTC_FCB_INDEX
  745. // UDFS_NTC_FCB_DATA
  746. //
  747. //
  748. // Common Fsrtl Header. The named header is for the fieldoff.c output. We
  749. // use the unnamed header internally.
  750. //
  751. union {
  752. FSRTL_ADVANCED_FCB_HEADER Header;
  753. FSRTL_ADVANCED_FCB_HEADER;
  754. };
  755. //
  756. // Vcb for this Fcb.
  757. //
  758. PVCB Vcb;
  759. //
  760. // Queues of Lcbs that are on this Fcb: Parent - edges that lead in
  761. // Child - edges that lead out
  762. //
  763. // We anticipate supporting the streaming extension to UDF 2.0, so we
  764. // leave the ChildLcbQueue here which in the case of a stream-rich file
  765. // will contain a solitary Lcb leading to the stream directory.
  766. //
  767. LIST_ENTRY ParentLcbQueue;
  768. LIST_ENTRY ChildLcbQueue;
  769. //
  770. // Length of Root ICB Extent for this object. Coupled with the information
  771. // in the FileId, this will allow discovery of the active File Entry for this
  772. // Fcb at any time.
  773. //
  774. ULONG RootExtentLength;
  775. //
  776. // FileId for this file.
  777. //
  778. FILE_ID FileId;
  779. //
  780. // Counts on this Fcb. Cleanup count represents the number of open handles
  781. // on this Fcb. Reference count represents the number of reasons this Fcb
  782. // is still present. It includes file objects, children Fcb and anyone
  783. // who wants to prevent this Fcb from going away. Cleanup count is synchronized
  784. // with the FcbResource. The reference count is synchronized with the
  785. // VcbMutex.
  786. //
  787. ULONG FcbCleanup;
  788. ULONG FcbReference;
  789. ULONG FcbUserReference;
  790. //
  791. // State flags for this Fcb.
  792. //
  793. ULONG FcbState;
  794. //
  795. // NT style attributes for the Fcb.
  796. //
  797. ULONG FileAttributes;
  798. //
  799. // This is the thread and count for the thread which has locked this
  800. // Fcb.
  801. //
  802. PVOID FcbLockThread;
  803. ULONG FcbLockCount;
  804. //
  805. // Information for Lsn->Psn mapping. If the file data is embedded, we have a
  806. // lookup into the metadata stream for the single logical block and an offset
  807. // of the data within that block. If the file data is is external, we have a
  808. // regular Mapping Control Block.
  809. //
  810. // Metadata structures are mapped through the volume-level Metadata Fcb which
  811. // uses the volume's VMCB.
  812. //
  813. union {
  814. LARGE_MCB Mcb;
  815. struct EMBEDDED_MAPPING {
  816. ULONG EmbeddedVsn;
  817. ULONG EmbeddedOffset;
  818. };
  819. };
  820. //
  821. // This is the nonpaged data for the Fcb
  822. //
  823. PFCB_NONPAGED FcbNonpaged;
  824. //
  825. // Share access structure.
  826. //
  827. SHARE_ACCESS ShareAccess;
  828. //
  829. // We cache a few fields from the FE so that various operations do not have to
  830. // hit the disk (query, etc.).
  831. //
  832. //
  833. // Time stamps for this file.
  834. //
  835. TIMESTAMP_BUNDLE Timestamps;
  836. //
  837. // Link count on this file.
  838. //
  839. USHORT LinkCount;
  840. //
  841. // Icb.Icbtag.Filetype
  842. //
  843. UCHAR UdfIcbFileType;
  844. } FCB_CORE, *PFCB_CORE;
  845. //
  846. // Split the Fcb into Core / Type specific structures, for the benefit of debugger
  847. // extensions. which try and read the largest possible size of a union...
  848. //
  849. typedef struct _FCB {
  850. FCB_CORE;
  851. union {
  852. ULONG FcbType;
  853. FCB_INDEX;
  854. FCB_DATA;
  855. };
  856. } FCB, *PFCB;
  857. #define FCB_STATE_INITIALIZED (0x00000001)
  858. #define FCB_STATE_IN_FCB_TABLE (0x00000002)
  859. #define FCB_STATE_VMCB_MAPPING (0x00000004)
  860. #define FCB_STATE_EMBEDDED_DATA (0x00000008)
  861. #define FCB_STATE_MCB_INITIALIZED (0x00000010)
  862. #define FCB_STATE_ALLOW_ONEGIG_WORKAROUND (0x00000020)
  863. #define SIZEOF_FCB_DATA \
  864. (FIELD_OFFSET( FCB, FcbType ) + sizeof( FCB_DATA ))
  865. #define SIZEOF_FCB_INDEX \
  866. (FIELD_OFFSET( FCB, FcbType ) + sizeof( FCB_INDEX ))
  867. //
  868. // The Ccb record is allocated for every user file object
  869. //
  870. typedef struct _CCB {
  871. //
  872. // Type and size of this record (must be UDFS_NTC_CCB)
  873. //
  874. NODE_TYPE_CODE NodeTypeCode;
  875. NODE_BYTE_SIZE NodeByteSize;
  876. //
  877. // Flags. Indicates flags to apply for the current open.
  878. //
  879. ULONG Flags;
  880. //
  881. // Fcb for the file being opened.
  882. //
  883. PFCB Fcb;
  884. //
  885. // Lcb for the file being opened.
  886. //
  887. PLCB Lcb;
  888. //
  889. // We store state information in the Ccb for a directory
  890. // enumeration on this handle.
  891. //
  892. //
  893. // Offset in the virtual directory stream to base the next enumeration.
  894. //
  895. // A small number (in fact, possibly one) of file indices are reserved for
  896. // synthesized directory entries (like '.'). Past that point, CurrentFileIndex -
  897. // UDF_MAX_SYNTHESIZED_FILEINDEX is a byte offset in the stream.
  898. //
  899. LONGLONG CurrentFileIndex;
  900. UNICODE_STRING SearchExpression;
  901. //
  902. // Highest ULONG-representable FileIndex so far found in the directory stream.
  903. // This corresponds to the highest FileIndex returnable in a query structure.
  904. //
  905. ULONG HighestReturnableFileIndex;
  906. } CCB, *PCCB;
  907. #define CCB_FLAG_OPEN_BY_ID (0x00000001)
  908. #define CCB_FLAG_OPEN_RELATIVE_BY_ID (0x00000002)
  909. #define CCB_FLAG_IGNORE_CASE (0x00000004)
  910. #define CCB_FLAG_DISMOUNT_ON_CLOSE (0x00000008)
  911. #define CCB_FLAG_ALLOW_EXTENDED_DASD_IO (0x00000010)
  912. //
  913. // Following flags refer to index enumeration.
  914. //
  915. #define CCB_FLAG_ENUM_NAME_EXP_HAS_WILD (0x00010000)
  916. #define CCB_FLAG_ENUM_MATCH_ALL (0x00020000)
  917. #define CCB_FLAG_ENUM_RETURN_NEXT (0x00040000)
  918. #define CCB_FLAG_ENUM_INITIALIZED (0x00080000)
  919. #define CCB_FLAG_ENUM_NOMATCH_CONSTANT_ENTRY (0x00100000)
  920. //
  921. // The Irp Context record is allocated for every orginating Irp. It is
  922. // created by the Fsd dispatch routines, and deallocated by the UdfComplete
  923. // request routine
  924. //
  925. typedef struct _IRP_CONTEXT {
  926. //
  927. // Type and size of this record (must be UDFS_NTC_IRP_CONTEXT)
  928. //
  929. NODE_TYPE_CODE NodeTypeCode;
  930. NODE_BYTE_SIZE NodeByteSize;
  931. //
  932. // Originating Irp for the request.
  933. //
  934. PIRP Irp;
  935. //
  936. // Vcb for this operation. When this is NULL it means we were called
  937. // with our filesystem device object instead of a volume device object.
  938. // (Mount will fill this in once the Vcb is created)
  939. //
  940. PVCB Vcb;
  941. //
  942. // Exception encountered during the request. Any error raised explicitly by
  943. // the file system will be stored here. Any other error raised by the system
  944. // is stored here after normalizing it.
  945. //
  946. NTSTATUS ExceptionStatus;
  947. ULONG RaisedAtFileLine;
  948. //
  949. // Flags for this request.
  950. //
  951. ULONG Flags;
  952. //
  953. // Real device object. This represents the physical device closest to the media.
  954. //
  955. PDEVICE_OBJECT RealDevice;
  956. //
  957. // Io context for a read request.
  958. // Address of Fcb for teardown oplock in create case.
  959. //
  960. union {
  961. struct _UDF_IO_CONTEXT *IoContext;
  962. PFCB *TeardownFcb;
  963. };
  964. //
  965. // Top level irp context for this thread.
  966. //
  967. struct _IRP_CONTEXT *TopLevel;
  968. //
  969. // Major and minor function codes.
  970. //
  971. UCHAR MajorFunction;
  972. UCHAR MinorFunction;
  973. //
  974. // Pointer to the top-level context if this IrpContext is responsible
  975. // for cleaning it up.
  976. //
  977. struct _THREAD_CONTEXT *ThreadContext;
  978. //
  979. // This structure is used for posting to the Ex worker threads.
  980. //
  981. WORK_QUEUE_ITEM WorkQueueItem;
  982. } IRP_CONTEXT, *PIRP_CONTEXT;
  983. #define IRP_CONTEXT_FLAG_ON_STACK (0x00000001)
  984. #define IRP_CONTEXT_FLAG_MORE_PROCESSING (0x00000002)
  985. #define IRP_CONTEXT_FLAG_WAIT (0x00000004)
  986. #define IRP_CONTEXT_FLAG_FORCE_POST (0x00000008)
  987. #define IRP_CONTEXT_FLAG_TOP_LEVEL (0x00000010)
  988. #define IRP_CONTEXT_FLAG_TOP_LEVEL_UDFS (0x00000020)
  989. #define IRP_CONTEXT_FLAG_IN_FSP (0x00000040)
  990. #define IRP_CONTEXT_FLAG_IN_TEARDOWN (0x00000080)
  991. #define IRP_CONTEXT_FLAG_ALLOC_IO (0x00000100)
  992. #define IRP_CONTEXT_FLAG_DISABLE_POPUPS (0x00000200)
  993. #define IRP_CONTEXT_FLAG_FORCE_VERIFY (0x00000400)
  994. //
  995. // Flags used for create.
  996. //
  997. #define IRP_CONTEXT_FLAG_FULL_NAME (0x10000000)
  998. #define IRP_CONTEXT_FLAG_TRAIL_BACKSLASH (0x20000000)
  999. //
  1000. // The following flags need to be cleared when a request is posted.
  1001. //
  1002. #define IRP_CONTEXT_FLAGS_CLEAR_ON_POST ( \
  1003. IRP_CONTEXT_FLAG_MORE_PROCESSING | \
  1004. IRP_CONTEXT_FLAG_WAIT | \
  1005. IRP_CONTEXT_FLAG_FORCE_POST | \
  1006. IRP_CONTEXT_FLAG_TOP_LEVEL | \
  1007. IRP_CONTEXT_FLAG_TOP_LEVEL_UDFS | \
  1008. IRP_CONTEXT_FLAG_IN_FSP | \
  1009. IRP_CONTEXT_FLAG_IN_TEARDOWN | \
  1010. IRP_CONTEXT_FLAG_DISABLE_POPUPS \
  1011. )
  1012. //
  1013. // The following flags need to be cleared when a request is retried.
  1014. //
  1015. #define IRP_CONTEXT_FLAGS_CLEAR_ON_RETRY ( \
  1016. IRP_CONTEXT_FLAG_MORE_PROCESSING | \
  1017. IRP_CONTEXT_FLAG_IN_TEARDOWN | \
  1018. IRP_CONTEXT_FLAG_DISABLE_POPUPS \
  1019. )
  1020. //
  1021. // The following flags are set each time through the Fsp loop.
  1022. //
  1023. #define IRP_CONTEXT_FSP_FLAGS ( \
  1024. IRP_CONTEXT_FLAG_WAIT | \
  1025. IRP_CONTEXT_FLAG_TOP_LEVEL | \
  1026. IRP_CONTEXT_FLAG_TOP_LEVEL_UDFS | \
  1027. IRP_CONTEXT_FLAG_IN_FSP \
  1028. )
  1029. //
  1030. // Following structure is used to queue a request to the delayed close queue.
  1031. // This structure should be the minimum block allocation size.
  1032. //
  1033. typedef struct _IRP_CONTEXT_LITE {
  1034. //
  1035. // Type and size of this record (must be UDFS_NTC_IRP_CONTEXT_LITE)
  1036. //
  1037. NODE_TYPE_CODE NodeTypeCode;
  1038. NODE_BYTE_SIZE NodeByteSize;
  1039. //
  1040. // Fcb for the file object being closed.
  1041. //
  1042. PFCB Fcb;
  1043. //
  1044. // List entry to attach to delayed close queue.
  1045. //
  1046. LIST_ENTRY DelayedCloseLinks;
  1047. //
  1048. // User reference count for the file object being closed.
  1049. //
  1050. ULONG UserReference;
  1051. //
  1052. // Real device object. This represents the physical device closest to the media.
  1053. //
  1054. PDEVICE_OBJECT RealDevice;
  1055. } IRP_CONTEXT_LITE, *PIRP_CONTEXT_LITE;
  1056. //
  1057. // Context structure for asynchronous I/O calls. Most of these fields
  1058. // are actually only required for the ReadMultiple routines, but
  1059. // the caller must allocate one as a local variable anyway before knowing
  1060. // whether there are multiple requests are not. Therefore, a single
  1061. // structure is used for simplicity.
  1062. //
  1063. typedef struct _UDF_IO_CONTEXT {
  1064. //
  1065. // These two fields are used for multiple run Io
  1066. //
  1067. LONG IrpCount;
  1068. PIRP MasterIrp;
  1069. NTSTATUS Status;
  1070. BOOLEAN AllocatedContext;
  1071. union {
  1072. //
  1073. // This element handles the asynchronous non-cached Io
  1074. //
  1075. struct {
  1076. PERESOURCE Resource;
  1077. ERESOURCE_THREAD ResourceThreadId;
  1078. ULONG RequestedByteCount;
  1079. };
  1080. //
  1081. // and this element handles the synchronous non-cached Io.
  1082. //
  1083. KEVENT SyncEvent;
  1084. };
  1085. } UDF_IO_CONTEXT, *PUDF_IO_CONTEXT;
  1086. //
  1087. // Following structure is used to track the top level request. Each Udfs
  1088. // Fsd and Fsp entry point will examine the top level irp location in the
  1089. // thread local storage to determine if this request is top level and/or
  1090. // top level Udfs. The top level Udfs request will remember the previous
  1091. // value and update that location with a stack location. This location
  1092. // can be accessed by recursive Udfs entry points.
  1093. //
  1094. typedef struct _THREAD_CONTEXT {
  1095. //
  1096. // UDFS signature. Used to confirm structure on stack is valid.
  1097. //
  1098. ULONG Udfs;
  1099. //
  1100. // Previous value in top-level thread location. We restore this
  1101. // when done.
  1102. //
  1103. PIRP SavedTopLevelIrp;
  1104. //
  1105. // Top level Udfs IrpContext. Initial Udfs entry point on stack
  1106. // will store the IrpContext for the request in this stack location.
  1107. //
  1108. PIRP_CONTEXT TopLevelIrpContext;
  1109. } THREAD_CONTEXT, *PTHREAD_CONTEXT;
  1110. //
  1111. // Following structure is used to build up static data for parse tables
  1112. //
  1113. typedef struct _PARSE_KEYVALUE {
  1114. PCHAR Key;
  1115. ULONG Value;
  1116. } PARSE_KEYVALUE, *PPARSE_KEYVALUE;
  1117. //
  1118. // Some macros for supporting the use of a Generic Table
  1119. // containing all the FCB and indexed by their FileId.
  1120. //
  1121. // The ISO 13346 lb_addr of the ICB hierarchy of the object
  1122. //
  1123. // { ULONG BlockNo; USHORT PartitionId }
  1124. //
  1125. // is encoded in the LowPart (BlockNo) and low 16 bits of the
  1126. // HighPart (PartitionId). The top 16 bits are reserved and are
  1127. // currently used to indicate the type of the object being referenced
  1128. // (file or directory).
  1129. //
  1130. // NOTE: this FileId prevents us from being able crack the name of
  1131. // object since an ICB hierarchy's contained direct File Entrys do
  1132. // not (and cannot) contain backpointers to the containing directory.
  1133. // In order to be able to crack paths, we need to be able to do a
  1134. // directory/dirent offset, which cannot fit in 64bits of FileId.
  1135. // A FileId must be 64bits since we export this in the FileInternalInforation
  1136. // query.
  1137. //
  1138. // Also, even through we are restricted to a single partition in this
  1139. // implementation, getting those "spare" 16bits isn't good enough to let us
  1140. // point directly into a directory's File Identifier. Files and by extension
  1141. // directories can exceed 2^32 bytes/entries. Once we have pointed at the
  1142. // parent dir, we are out of bits.
  1143. //
  1144. // The Id field is a LARGE_INTEGER where the High and Low parts can be
  1145. // accessed separately.
  1146. //
  1147. // The following macros are used to access the Fid fields.
  1148. //
  1149. // CdQueryFidDirentOffset - Accesses the Dirent offset field
  1150. // CdQueryFidPathTableNumber - Accesses the PathTable offset field
  1151. // CdSetFidDirentOffset - Sets the Dirent offset field
  1152. // CdSetFidPathTableNumber - Sets the PathTable ordinal field
  1153. // CdFidIsDirectory - Queries if directory bit is set
  1154. // CdFidSetDirectory - Sets directory bit
  1155. //
  1156. #define FID_DIR_MASK 0x80000000 // high order bit means directory.
  1157. #define UdfSetFidFromLbAddr(I, LBA) { (I).LowPart = (LBA).Lbn; \
  1158. (I).HighPart = (ULONG) (LBA).Partition; }
  1159. #define UdfGetFidLbn(I) ((I).LowPart)
  1160. #define UdfGetFidPartition(I) ((USHORT) (((I).HighPart & ~FID_DIR_MASK) & MAXUSHORT))
  1161. #define UdfGetFidReservedZero(I) ((I).HighPart & ~(FID_DIR_MASK|MAXUSHORT))
  1162. #define UdfSetFidFile(I) ClearFlag( (I).HighPart, FID_DIR_MASK )
  1163. #define UdfSetFidDirectory(I) SetFlag( (I).HighPart, FID_DIR_MASK )
  1164. #define UdfIsFidFile(I) BooleanFlagOff( (I).HighPart, FID_DIR_MASK )
  1165. #define UdfIsFidDirectory(I) BooleanFlagOn( (I).HighPart, FID_DIR_MASK )
  1166. #define UdfSetFidFromFidAndFe(I, FID, FE ) { \
  1167. UdfSetFidFromLbAddr((I), (FID)->Icb.Start); \
  1168. if ((FE) && ((FE)->Icbtag.FileType == ICBTAG_FILE_T_DIRECTORY)) { \
  1169. UdfSetFidDirectory((I)); \
  1170. } \
  1171. }
  1172. //
  1173. // Context structures for browsing through structures
  1174. //
  1175. //
  1176. // A mapped view is a useful bundle to hold information about a physical
  1177. // view of the disk.
  1178. //
  1179. typedef struct _MAPPED_PVIEW {
  1180. //
  1181. // A mapped extent and CC control block
  1182. //
  1183. PVOID View;
  1184. PBCB Bcb;
  1185. //
  1186. // Extent location
  1187. //
  1188. USHORT Partition;
  1189. ULONG Lbn;
  1190. ULONG Length;
  1191. //
  1192. // In the case of mappings through the metadata stream, store the Vsn currently
  1193. // mapped to the Lbn
  1194. //
  1195. ULONG Vsn;
  1196. } MAPPED_PVIEW, *PMAPPED_PVIEW;
  1197. //
  1198. // Enumeration contexts for various operations.
  1199. //
  1200. //
  1201. // The following is used for crawling ICB hierarchies searching
  1202. // for some notion of an active entry.
  1203. //
  1204. typedef struct _ICB_SEARCH_CONTEXT {
  1205. //
  1206. // Vcb the search is occuring on.
  1207. //
  1208. PVCB Vcb;
  1209. //
  1210. // Type of Icb being searched for.
  1211. //
  1212. USHORT IcbType;
  1213. //
  1214. // The Active is most prevailing ICB so far found.
  1215. //
  1216. MAPPED_PVIEW Active;
  1217. //
  1218. // The current logical block extent being read from the disk.
  1219. //
  1220. MAPPED_PVIEW Current;
  1221. } ICB_SEARCH_CONTEXT, *PICB_SEARCH_CONTEXT;
  1222. //
  1223. // The following is used for crawling Extended Attributes extending off of
  1224. // a direct ICB
  1225. //
  1226. typedef enum _EA_SEARCH_TYPE {
  1227. EaEnumBad = 0,
  1228. EaEnumISO,
  1229. EaEnumImplementation,
  1230. EaEnumApplication
  1231. } EA_SEARCH_TYPE, *PEA_SEARCH_TYPE;
  1232. typedef struct _EA_SEARCH_CONTEXT {
  1233. //
  1234. // Reference to an elaborated ICB_SEARCH_CONTEXT which gives us a handle
  1235. // onto a direct ICB to crawl.
  1236. //
  1237. PICB_SEARCH_CONTEXT IcbContext;
  1238. //
  1239. // The current Ea being looked at.
  1240. //
  1241. PVOID Ea;
  1242. //
  1243. // Bytes remaining in the EA view
  1244. //
  1245. ULONG Remaining;
  1246. //
  1247. // EA being searched for. We only support looking for ISO at this time.
  1248. //
  1249. ULONG EAType;
  1250. USHORT EASubType;
  1251. } EA_SEARCH_CONTEXT, *PEA_SEARCH_CONTEXT;
  1252. //
  1253. // The following is used to crawl the list of allocation extent descriptors attached
  1254. // to an ICB.
  1255. //
  1256. typedef struct _ALLOC_ENUM_CONTEXT {
  1257. //
  1258. // Reference to an elaborated ICB_ENUM_CONTEXT which gives us a handle
  1259. // onto a direct ICB to crawl.
  1260. //
  1261. PICB_SEARCH_CONTEXT IcbContext;
  1262. //
  1263. // The current allocation descriptor being looked at.
  1264. //
  1265. PVOID Alloc;
  1266. //
  1267. // Type of allocation descriptors in this enumeration
  1268. //
  1269. ULONG AllocType;
  1270. //
  1271. // Bytes remaining in this view.
  1272. //
  1273. ULONG Remaining;
  1274. } ALLOC_ENUM_CONTEXT, *PALLOC_ENUM_CONTEXT;
  1275. //
  1276. // The following is used to crawl a logical directory.
  1277. //
  1278. typedef struct _DIR_ENUM_CONTEXT {
  1279. //
  1280. // The current view in the enumeration.
  1281. //
  1282. PVOID View;
  1283. PBCB Bcb;
  1284. //
  1285. // Offset of the view from the beginning of the directory.
  1286. //
  1287. LARGE_INTEGER BaseOffset;
  1288. //
  1289. // Length of the view which is valid and the current
  1290. // offset in it.
  1291. //
  1292. ULONG ViewLength;
  1293. ULONG ViewOffset;
  1294. //
  1295. // Pointer to the current FID.
  1296. //
  1297. PNSR_FID Fid;
  1298. //
  1299. // Offset to the next fid from the beginning of the view.
  1300. //
  1301. ULONG NextFidOffset;
  1302. //
  1303. // Flags indicating the state of the enumeration.
  1304. //
  1305. ULONG Flags;
  1306. //
  1307. // Converted names from the FID. Case name is "case appropriate" for
  1308. // the operation.
  1309. //
  1310. UNICODE_STRING ObjectName;
  1311. UNICODE_STRING CaseObjectName;
  1312. //
  1313. // Real object name in pure form (not rendered to NT legal form)
  1314. //
  1315. UNICODE_STRING PureObjectName;
  1316. //
  1317. // Short name for the object.
  1318. //
  1319. UNICODE_STRING ShortObjectName;
  1320. //
  1321. // Currently allocated space for the name. The previous strings are
  1322. // carved out of this single buffer.
  1323. //
  1324. PVOID NameBuffer;
  1325. //
  1326. // Size of currently allocated name buffer for the lfn names.
  1327. //
  1328. USHORT AllocLength;
  1329. } DIR_ENUM_CONTEXT, *PDIR_ENUM_CONTEXT;
  1330. //
  1331. // Flags for noting where in the enumeration we are.
  1332. //
  1333. #define DIR_CONTEXT_FLAG_SEEN_NONCONSTANT 0x0001
  1334. #define DIR_CONTEXT_FLAG_SEEN_PARENT 0x0002
  1335. //
  1336. // Flag indicating current Fid was buffered into pool.
  1337. //
  1338. #define DIR_CONTEXT_FLAG_FID_BUFFERED 0x0004
  1339. #endif // _CDSTRUC_