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.

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