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.

1770 lines
46 KiB

  1. /*++
  2. Copyright (c) 1989-2000 Microsoft Corporation
  3. Module Name:
  4. CdStruc.h
  5. Abstract:
  6. This module defines the data structures that make up the major internal
  7. part of the Cdfs file system.
  8. In-Memory structures:
  9. The global data structures with the CdDataRecord. 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. | CdData | +--------+
  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 Fcb's for
  31. its children. There can also be detached subtrees due to open operations
  32. by Id where the Fcb's are not connected to the root.
  33. The following diagram shows the root structure.
  34. +--------+ +--------+
  35. | Vcb |---->| Fcb |-----------------------------------------------+
  36. | | | Table |--------------------------------------------+ | |
  37. | |--+ | |-----------------------------------------+ | | |
  38. +--------+ | +--------+ | | |
  39. | | | | | | |
  40. | | | +--------------------+ | | |
  41. | V +---------+ | | | |
  42. | +--------+ | | | | |
  43. | |RootFcb | V V | | |
  44. +->| | +--------+ +--------+ | | |
  45. | |-->|Child | |Child | | | |
  46. +--------+ | Fcb |<-->| Fcb |<--> ... | | |
  47. | | | | | | |
  48. +--------+ +--------+ | | |
  49. | | |
  50. (Freestanding sub-tree) | | |
  51. +--------+ | | |
  52. |OpenById|<-----------------------------------------+ | |
  53. | Dir | +--------+ | |
  54. | |--->|OpenById|<------------------------------+ |
  55. +--------+ | Child | +--------+ |
  56. | Dir |--->|OpenById|<-------------------+
  57. +--------+ | Child |
  58. | File |
  59. +--------+
  60. Attached to each Directory Fcb is a prefix table containing the names
  61. of children of this directory for which there is an Fcb. Not all Fcb's
  62. will necessarily have an entry in this table.
  63. +--------+ +--------+
  64. | Dir | | Prefix |
  65. | Fcb |----->| Table |--------------------+
  66. | | | |-------+ |
  67. +--------+ +--------+ | |
  68. | | | |
  69. | | | |
  70. | V V V
  71. | +--------+ +--------+ +--------+ +--------+
  72. | | Fcb | | Fcb | | Fcb | | Fcb |
  73. +---------->| |<-->| |<-->| |<-->| |
  74. | | | | | | | |
  75. +--------+ +--------+ +--------+ +--------+
  76. Each file object open on a CDROM volume contains two context pointers. The
  77. first will point back to the Fcb for the file object. The second, if present,
  78. points to a Ccb (ContextControlBlock) which contains the per-handle information.
  79. This includes the state of any directory enumeration.
  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 CdData 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. 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 CdData/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. Brian Andrew [BrianAn] 01-July-1995
  136. Revision History:
  137. // @@END_DDKSPLIT
  138. --*/
  139. #ifndef _CDSTRUC_
  140. #define _CDSTRUC_
  141. typedef PVOID PBCB; //**** Bcb's are now part of the cache module
  142. #define BYTE_COUNT_EMBEDDED_NAME (32)
  143. //
  144. // The CD_MCB is used to store the mapping of logical file offset to
  145. // logical disk offset. NOTE - This package only deals with the
  146. // logical 2048 sectors. Translating to 'raw' sectors happens in
  147. // software. We will embed a single MCB_ENTRY in the Fcb since this
  148. // will be the typical case.
  149. //
  150. typedef struct _CD_MCB {
  151. //
  152. // Size and current count of the Mcb entries.
  153. //
  154. ULONG MaximumEntryCount;
  155. ULONG CurrentEntryCount;
  156. //
  157. // Pointer to the start of the Mcb entries.
  158. //
  159. struct _CD_MCB_ENTRY *McbArray;
  160. } CD_MCB;
  161. typedef CD_MCB *PCD_MCB;
  162. typedef struct _CD_MCB_ENTRY {
  163. //
  164. // Starting offset and number of bytes described by this entry.
  165. // The Byte count is rounded to a logical block boundary if this is
  166. // the last block.
  167. //
  168. LONGLONG DiskOffset;
  169. LONGLONG ByteCount;
  170. //
  171. // Starting offset in the file of mapping described by this dirent.
  172. //
  173. LONGLONG FileOffset;
  174. //
  175. // Data length and block length. Data length is the length of each
  176. // data block. Total length is the length of each data block and
  177. // the skip size.
  178. //
  179. LONGLONG DataBlockByteCount;
  180. LONGLONG TotalBlockByteCount;
  181. } CD_MCB_ENTRY;
  182. typedef CD_MCB_ENTRY *PCD_MCB_ENTRY;
  183. //
  184. // Cd name structure. The following structure is used to represent the
  185. // full Cdrom name. This name can be stored in either Unicode or ANSI
  186. // format.
  187. //
  188. typedef struct _CD_NAME {
  189. //
  190. // String containing name without the version number.
  191. // The maximum length field for filename indicates the
  192. // size of the buffer allocated for the two parts of the name.
  193. //
  194. UNICODE_STRING FileName;
  195. //
  196. // String containging the version number.
  197. //
  198. UNICODE_STRING VersionString;
  199. } CD_NAME;
  200. typedef CD_NAME *PCD_NAME;
  201. //
  202. // Following is the splay link structure for the prefix lookup.
  203. // The names can be in either Unicode string or Ansi string format.
  204. //
  205. typedef struct _NAME_LINK {
  206. RTL_SPLAY_LINKS Links;
  207. UNICODE_STRING FileName;
  208. } NAME_LINK;
  209. typedef NAME_LINK *PNAME_LINK;
  210. //
  211. // Prefix entry. There is one of these for each name in the prefix table.
  212. // An Fcb will have one of these embedded for the long name and an optional
  213. // pointer to the short name entry.
  214. //
  215. typedef struct _PREFIX_ENTRY {
  216. //
  217. // Pointer to the Fcb for this entry.
  218. //
  219. struct _FCB *Fcb;
  220. //
  221. // Flags field. Used to indicate if the name is in the prefix table.
  222. //
  223. ULONG PrefixFlags;
  224. //
  225. // Exact case name match.
  226. //
  227. NAME_LINK ExactCaseName;
  228. //
  229. // Case-insensitive name link.
  230. //
  231. NAME_LINK IgnoreCaseName;
  232. WCHAR FileNameBuffer[ BYTE_COUNT_EMBEDDED_NAME ];
  233. } PREFIX_ENTRY;
  234. typedef PREFIX_ENTRY *PPREFIX_ENTRY;
  235. #define PREFIX_FLAG_EXACT_CASE_IN_TREE (0x00000001)
  236. #define PREFIX_FLAG_IGNORE_CASE_IN_TREE (0x00000002)
  237. //
  238. // The CD_DATA record is the top record in the CDROM file system in-memory
  239. // data structure. This structure must be allocated from non-paged pool.
  240. //
  241. typedef struct _CD_DATA {
  242. //
  243. // The type and size of this record (must be CDFS_NTC_DATA_HEADER)
  244. //
  245. NODE_TYPE_CODE NodeTypeCode;
  246. NODE_BYTE_SIZE NodeByteSize;
  247. //
  248. // A pointer to the Driver object we were initialized with
  249. //
  250. PDRIVER_OBJECT DriverObject;
  251. //
  252. // Vcb queue.
  253. //
  254. LIST_ENTRY VcbQueue;
  255. //
  256. // The following fields are used to allocate IRP context structures
  257. // using a lookaside list, and other fixed sized structures from a
  258. // small cache. We use the CdData mutex to protext these structures.
  259. //
  260. ULONG IrpContextDepth;
  261. ULONG IrpContextMaxDepth;
  262. SINGLE_LIST_ENTRY IrpContextList;
  263. //
  264. // Filesystem device object for CDFS.
  265. //
  266. PDEVICE_OBJECT FileSystemDeviceObject;
  267. //
  268. // Following are used to manage the async and delayed close queue.
  269. //
  270. // FspCloseActive - Indicates whether there is a thread processing the
  271. // two close queues.
  272. // ReduceDelayedClose - Indicates that we have hit the upper threshold
  273. // for the delayed close queue and need to reduce it to lower threshold.
  274. //
  275. // AsyncCloseQueue - Queue of IrpContext waiting for async close operation.
  276. // AsyncCloseCount - Number of entries on the async close queue.
  277. //
  278. // DelayedCloseQueue - Queue of IrpContextLite waiting for delayed close
  279. // operation.
  280. // MaxDelayedCloseCount - Trigger delay close work at this threshold.
  281. // MinDelayedCloseCount - Turn off delay close work at this threshold.
  282. // DelayedCloseCount - Number of entries on the delayted close queue.
  283. //
  284. // CloseItem - Workqueue item used to start FspClose thread.
  285. //
  286. LIST_ENTRY AsyncCloseQueue;
  287. ULONG AsyncCloseCount;
  288. BOOLEAN FspCloseActive;
  289. BOOLEAN ReduceDelayedClose;
  290. USHORT PadUshort;
  291. //
  292. // The following fields describe the deferred close file objects.
  293. //
  294. LIST_ENTRY DelayedCloseQueue;
  295. ULONG DelayedCloseCount;
  296. ULONG MaxDelayedCloseCount;
  297. ULONG MinDelayedCloseCount;
  298. //
  299. // Fast mutex used to lock the fields of this structure.
  300. //
  301. PVOID CdDataLockThread;
  302. FAST_MUTEX CdDataMutex;
  303. //
  304. // A resource variable to control access to the global CDFS data record
  305. //
  306. ERESOURCE DataResource;
  307. //
  308. // Cache manager call back structure, which must be passed on each call
  309. // to CcInitializeCacheMap.
  310. //
  311. CACHE_MANAGER_CALLBACKS CacheManagerCallbacks;
  312. CACHE_MANAGER_CALLBACKS CacheManagerVolumeCallbacks;
  313. //
  314. // This is the ExWorkerItem that does both kinds of deferred closes.
  315. //
  316. PIO_WORKITEM CloseItem;
  317. } CD_DATA;
  318. typedef CD_DATA *PCD_DATA;
  319. //
  320. // The Vcb (Volume control block) record corresponds to every
  321. // volume mounted by the file system. They are ordered in a queue off
  322. // of CdData.VcbQueue.
  323. //
  324. // The Vcb will be in several conditions during its lifespan.
  325. //
  326. // NotMounted - Disk is not currently mounted (i.e. removed
  327. // from system) but cleanup and close operations are
  328. // supported.
  329. //
  330. // MountInProgress - State of the Vcb from the time it is
  331. // created until it is successfully mounted or the mount
  332. // fails.
  333. //
  334. // Mounted - Volume is currently in the mounted state.
  335. //
  336. // Invalid - User has invalidated the volume. Only legal operations
  337. // are cleanup and close.
  338. //
  339. // DismountInProgress - We have begun the process of tearing down the
  340. // Vcb. It can be deleted when all the references to it
  341. // have gone away.
  342. //
  343. typedef enum _VCB_CONDITION {
  344. VcbNotMounted = 0,
  345. VcbMountInProgress,
  346. VcbMounted,
  347. VcbInvalid,
  348. VcbDismountInProgress
  349. } VCB_CONDITION;
  350. typedef struct _VCB {
  351. //
  352. // The type and size of this record (must be CDFS_NTC_VCB)
  353. //
  354. NODE_TYPE_CODE NodeTypeCode;
  355. NODE_BYTE_SIZE NodeByteSize;
  356. //
  357. // Vpb for this volume.
  358. //
  359. PVPB Vpb;
  360. //
  361. // Device object for the driver below us.
  362. //
  363. PDEVICE_OBJECT TargetDeviceObject;
  364. //
  365. // File object used to lock the volume.
  366. //
  367. PFILE_OBJECT VolumeLockFileObject;
  368. //
  369. // Link into queue of Vcb's in the CdData structure. We will create a union with
  370. // a LONGLONG to force the Vcb to be quad-aligned.
  371. //
  372. union {
  373. LIST_ENTRY VcbLinks;
  374. LONGLONG Alignment;
  375. };
  376. //
  377. // State flags and condition for the Vcb.
  378. //
  379. ULONG VcbState;
  380. VCB_CONDITION VcbCondition;
  381. //
  382. // Various counts for this Vcb.
  383. //
  384. // VcbCleanup - Open handles left on this system.
  385. // VcbReference - Number of reasons this Vcb is still present.
  386. // VcbUserReference - Number of user file objects still present.
  387. //
  388. ULONG VcbCleanup;
  389. ULONG VcbReference;
  390. ULONG VcbUserReference;
  391. //
  392. // Fcb for the Volume Dasd file, root directory and the Path Table.
  393. //
  394. struct _FCB *VolumeDasdFcb;
  395. struct _FCB *RootIndexFcb;
  396. struct _FCB *PathTableFcb;
  397. //
  398. // Location of current session and offset of volume descriptors.
  399. //
  400. ULONG BaseSector;
  401. ULONG VdSectorOffset;
  402. ULONG PrimaryVdSectorOffset;
  403. //
  404. // Following is a sector from the last non-cached read of an XA file.
  405. // Also the cooked offset on the disk.
  406. //
  407. PVOID XASector;
  408. LONGLONG XADiskOffset;
  409. //
  410. // Vcb resource. This is used to synchronize open/cleanup/close operations.
  411. //
  412. ERESOURCE VcbResource;
  413. //
  414. // File resource. This is used to synchronize all file operations except
  415. // open/cleanup/close.
  416. //
  417. ERESOURCE FileResource;
  418. //
  419. // Vcb fast mutex. This is used to synchronize the fields in the Vcb
  420. // when modified when the Vcb is not held exclusively. Included here
  421. // are the count fields and Fcb table.
  422. //
  423. // We also use this to synchronize changes to the Fcb reference field.
  424. //
  425. FAST_MUTEX VcbMutex;
  426. PVOID VcbLockThread;
  427. //
  428. // The following is used to synchronize the dir notify package.
  429. //
  430. PNOTIFY_SYNC NotifySync;
  431. //
  432. // The following is the head of a list of notify Irps.
  433. //
  434. LIST_ENTRY DirNotifyList;
  435. //
  436. // Logical block size for this volume as well constant values
  437. // associated with the block size.
  438. //
  439. ULONG BlockSize;
  440. ULONG BlockToSectorShift;
  441. ULONG BlockToByteShift;
  442. ULONG BlocksPerSector;
  443. ULONG BlockMask;
  444. ULONG BlockInverseMask;
  445. //
  446. // Fcb table. Synchronized with the Vcb fast mutex.
  447. //
  448. RTL_GENERIC_TABLE FcbTable;
  449. //
  450. // Volume TOC. Cache this information for quick lookup.
  451. //
  452. PCDROM_TOC CdromToc;
  453. ULONG TocLength;
  454. ULONG TrackCount;
  455. ULONG DiskFlags;
  456. //
  457. // Block factor to determine last session information.
  458. //
  459. ULONG BlockFactor;
  460. //
  461. // Media change count from device driver for bulletproof detection
  462. // of media movement
  463. //
  464. ULONG MediaChangeCount;
  465. //
  466. // For raw reads, CDFS must obey the port maximum transfer restrictions.
  467. //
  468. ULONG MaximumTransferRawSectors;
  469. ULONG MaximumPhysicalPages;
  470. //
  471. // Preallocated VPB for swapout, so we are not forced to consider
  472. // must succeed pool.
  473. //
  474. PVPB SwapVpb;
  475. } VCB;
  476. typedef VCB *PVCB;
  477. #define VCB_STATE_HSG (0x00000001)
  478. #define VCB_STATE_ISO (0x00000002)
  479. #define VCB_STATE_JOLIET (0x00000004)
  480. #define VCB_STATE_LOCKED (0x00000010)
  481. #define VCB_STATE_REMOVABLE_MEDIA (0x00000020)
  482. #define VCB_STATE_CDXA (0x00000040)
  483. #define VCB_STATE_AUDIO_DISK (0x00000080)
  484. #define VCB_STATE_NOTIFY_REMOUNT (0x00000100)
  485. #define VCB_STATE_VPB_NOT_ON_DEVICE (0x00000200)
  486. //
  487. // The Volume Device Object is an I/O system device object with a
  488. // workqueue and an VCB record appended to the end. There are multiple
  489. // of these records, one for every mounted volume, and are created during
  490. // a volume mount operation. The work queue is for handling an overload
  491. // of work requests to the volume.
  492. //
  493. typedef struct _VOLUME_DEVICE_OBJECT {
  494. DEVICE_OBJECT DeviceObject;
  495. //
  496. // The following field tells how many requests for this volume have
  497. // either been enqueued to ExWorker threads or are currently being
  498. // serviced by ExWorker threads. If the number goes above
  499. // a certain threshold, put the request on the overflow queue to be
  500. // executed later.
  501. //
  502. ULONG PostedRequestCount;
  503. //
  504. // The following field indicates the number of IRP's waiting
  505. // to be serviced in the overflow queue.
  506. //
  507. ULONG OverflowQueueCount;
  508. //
  509. // The following field contains the queue header of the overflow queue.
  510. // The Overflow queue is a list of IRP's linked via the IRP's ListEntry
  511. // field.
  512. //
  513. LIST_ENTRY OverflowQueue;
  514. //
  515. // The following spinlock protects access to all the above fields.
  516. //
  517. KSPIN_LOCK OverflowQueueSpinLock;
  518. //
  519. // This is the file system specific volume control block.
  520. //
  521. VCB Vcb;
  522. } VOLUME_DEVICE_OBJECT;
  523. typedef VOLUME_DEVICE_OBJECT *PVOLUME_DEVICE_OBJECT;
  524. //
  525. // The following two structures are the separate union structures for
  526. // data and index Fcb's. The path table is actually the same structure
  527. // as the index Fcb since it uses the first few fields.
  528. //
  529. typedef enum _FCB_CONDITION {
  530. FcbGood = 1,
  531. FcbBad,
  532. FcbNeedsToBeVerified
  533. } FCB_CONDITION;
  534. typedef struct _FCB_DATA {
  535. //
  536. // The following field is used by the oplock module
  537. // to maintain current oplock information.
  538. //
  539. OPLOCK Oplock;
  540. //
  541. // The following field is used by the filelock module
  542. // to maintain current byte range locking information.
  543. // A file lock is allocated as needed.
  544. //
  545. PFILE_LOCK FileLock;
  546. } FCB_DATA;
  547. typedef FCB_DATA *PFCB_DATA;
  548. typedef struct _FCB_INDEX {
  549. //
  550. // Internal stream file.
  551. //
  552. PFILE_OBJECT FileObject;
  553. //
  554. // Offset of first entry in stream. This is for case where directory
  555. // or path table does not begin on a sector boundary. This value is
  556. // added to all offset values to determine the real offset.
  557. //
  558. ULONG StreamOffset;
  559. //
  560. // List of child fcbs.
  561. //
  562. LIST_ENTRY FcbQueue;
  563. //
  564. // Ordinal number for this directory. Combine this with the path table offset
  565. // in the FileId and you have a starting point in the path table.
  566. //
  567. ULONG Ordinal;
  568. //
  569. // Children path table start. This is the offset in the path table
  570. // for the first child of the directory. A value of zero indicates
  571. // that we haven't found the first child yet. If there are no child
  572. // directories we will position at a point in the path table so that
  573. // subsequent searches will fail quickly.
  574. //
  575. ULONG ChildPathTableOffset;
  576. ULONG ChildOrdinal;
  577. //
  578. // Root of splay trees for exact and ignore case prefix trees.
  579. //
  580. PRTL_SPLAY_LINKS ExactCaseRoot;
  581. PRTL_SPLAY_LINKS IgnoreCaseRoot;
  582. } FCB_INDEX;
  583. typedef FCB_INDEX *PFCB_INDEX;
  584. typedef struct _FCB_NONPAGED {
  585. //
  586. // Type and size of this record must be CDFS_NTC_FCB_NONPAGED
  587. //
  588. NODE_TYPE_CODE NodeTypeCode;
  589. NODE_BYTE_SIZE NodeByteSize;
  590. //
  591. // The following field contains a record of special pointers used by
  592. // MM and Cache to manipluate section objects. Note that the values
  593. // are set outside of the file system. However the file system on an
  594. // open/create will set the file object's SectionObject field to
  595. // point to this field
  596. //
  597. SECTION_OBJECT_POINTERS SegmentObject;
  598. //
  599. // This is the resource structure for this Fcb.
  600. //
  601. ERESOURCE FcbResource;
  602. //
  603. // This is the FastMutex for this Fcb.
  604. //
  605. FAST_MUTEX FcbMutex;
  606. //
  607. // This is the mutex that is inserted into the FCB_ADVANCED_HEADER
  608. // FastMutex field
  609. //
  610. FAST_MUTEX AdvancedFcbHeaderMutex;
  611. } FCB_NONPAGED;
  612. typedef FCB_NONPAGED *PFCB_NONPAGED;
  613. //
  614. // The Fcb/Dcb record corresponds to every open file and directory, and to
  615. // every directory on an opened path.
  616. //
  617. typedef struct _FCB {
  618. //
  619. // The following field is used for fast I/O. It contains the node
  620. // type code and size, indicates if fast I/O is possible, contains
  621. // allocation, file, and valid data size, a resource, and call back
  622. // pointers for FastIoRead and FastMdlRead.
  623. //
  624. //
  625. // Node type codes for the Fcb must be one of the following.
  626. //
  627. // CDFS_NTC_FCB_PATH_TABLE
  628. // CDFS_NTC_FCB_INDEX
  629. // CDFS_NTC_FCB_DATA
  630. //
  631. //
  632. // Common Fsrtl Header. The named header is for the fieldoff.c output. We
  633. // use the unnamed header internally.
  634. //
  635. union{
  636. FSRTL_ADVANCED_FCB_HEADER Header;
  637. FSRTL_ADVANCED_FCB_HEADER;
  638. };
  639. //
  640. // Vcb for this Fcb.
  641. //
  642. PVCB Vcb;
  643. //
  644. // Parent Fcb for this Fcb. This may be NULL if this file was opened
  645. // by ID, also for the root Fcb.
  646. //
  647. struct _FCB *ParentFcb;
  648. //
  649. // Links to the queue of Fcb's in the parent.
  650. //
  651. LIST_ENTRY FcbLinks;
  652. //
  653. // FileId for this file.
  654. //
  655. FILE_ID FileId;
  656. //
  657. // Counts on this Fcb. Cleanup count represents the number of open handles
  658. // on this Fcb. Reference count represents the number of reasons this Fcb
  659. // is still present. It includes file objects, children Fcb and anyone
  660. // who wants to prevent this Fcb from going away. Cleanup count is synchronized
  661. // with the FcbResource. The reference count is synchronized with the
  662. // VcbMutex.
  663. //
  664. ULONG FcbCleanup;
  665. ULONG FcbReference;
  666. ULONG FcbUserReference;
  667. //
  668. // State flags for this Fcb.
  669. //
  670. ULONG FcbState;
  671. //
  672. // NT style attributes for the Fcb.
  673. //
  674. ULONG FileAttributes;
  675. //
  676. // CDXA attributes for this file.
  677. //
  678. USHORT XAAttributes;
  679. //
  680. // File number from the system use area.
  681. //
  682. UCHAR XAFileNumber;
  683. //
  684. // This is the thread and count for the thread which has locked this
  685. // Fcb.
  686. //
  687. PVOID FcbLockThread;
  688. ULONG FcbLockCount;
  689. //
  690. // Pointer to the Fcb non-paged structures.
  691. //
  692. PFCB_NONPAGED FcbNonpaged;
  693. //
  694. // Share access structure.
  695. //
  696. SHARE_ACCESS ShareAccess;
  697. //
  698. // Mcb for the on disk mapping and a single map entry.
  699. //
  700. CD_MCB_ENTRY McbEntry;
  701. CD_MCB Mcb;
  702. //
  703. // Embed the prefix entry for the longname. Store an optional pointer
  704. // to a prefix structure for the short name.
  705. //
  706. PPREFIX_ENTRY ShortNamePrefix;
  707. PREFIX_ENTRY FileNamePrefix;
  708. //
  709. // Time stamp for this file.
  710. //
  711. LONGLONG CreationTime;
  712. union{
  713. ULONG FcbType;
  714. FCB_DATA;
  715. FCB_INDEX;
  716. };
  717. } FCB;
  718. typedef FCB *PFCB;
  719. #define FCB_STATE_INITIALIZED (0x00000001)
  720. #define FCB_STATE_IN_FCB_TABLE (0x00000002)
  721. #define FCB_STATE_MODE2FORM2_FILE (0x00000004)
  722. #define FCB_STATE_MODE2_FILE (0x00000008)
  723. #define FCB_STATE_DA_FILE (0x00000010)
  724. //
  725. // These file types are read as raw 2352 byte sectors
  726. //
  727. #define FCB_STATE_RAWSECTOR_MASK ( FCB_STATE_MODE2FORM2_FILE | \
  728. FCB_STATE_MODE2_FILE | \
  729. FCB_STATE_DA_FILE )
  730. #define SIZEOF_FCB_DATA \
  731. (FIELD_OFFSET( FCB, FcbType ) + sizeof( FCB_DATA ))
  732. #define SIZEOF_FCB_INDEX \
  733. (FIELD_OFFSET( FCB, FcbType ) + sizeof( FCB_INDEX ))
  734. //
  735. // The Ccb record is allocated for every file object
  736. //
  737. typedef struct _CCB {
  738. //
  739. // Type and size of this record (must be CDFS_NTC_CCB)
  740. //
  741. NODE_TYPE_CODE NodeTypeCode;
  742. NODE_BYTE_SIZE NodeByteSize;
  743. //
  744. // Flags. Indicates flags to apply for the current open.
  745. //
  746. ULONG Flags;
  747. //
  748. // Fcb for the file being opened.
  749. //
  750. PFCB Fcb;
  751. //
  752. // We store state information in the Ccb for a directory
  753. // enumeration on this handle.
  754. //
  755. //
  756. // Offset in the directory stream to base the next enumeration.
  757. //
  758. ULONG CurrentDirentOffset;
  759. CD_NAME SearchExpression;
  760. } CCB;
  761. typedef CCB *PCCB;
  762. #define CCB_FLAG_OPEN_BY_ID (0x00000001)
  763. #define CCB_FLAG_OPEN_RELATIVE_BY_ID (0x00000002)
  764. #define CCB_FLAG_IGNORE_CASE (0x00000004)
  765. #define CCB_FLAG_OPEN_WITH_VERSION (0x00000008)
  766. #define CCB_FLAG_DISMOUNT_ON_CLOSE (0x00000010)
  767. //
  768. // Following flags refer to index enumeration.
  769. //
  770. #define CCB_FLAG_ENUM_NAME_EXP_HAS_WILD (0x00010000)
  771. #define CCB_FLAG_ENUM_VERSION_EXP_HAS_WILD (0x00020000)
  772. #define CCB_FLAG_ENUM_MATCH_ALL (0x00040000)
  773. #define CCB_FLAG_ENUM_VERSION_MATCH_ALL (0x00080000)
  774. #define CCB_FLAG_ENUM_RETURN_NEXT (0x00100000)
  775. #define CCB_FLAG_ENUM_INITIALIZED (0x00200000)
  776. #define CCB_FLAG_ENUM_NOMATCH_CONSTANT_ENTRY (0x00400000)
  777. //
  778. // The Irp Context record is allocated for every orginating Irp. It is
  779. // created by the Fsd dispatch routines, and deallocated by the CdComplete
  780. // request routine
  781. //
  782. typedef struct _IRP_CONTEXT {
  783. //
  784. // Type and size of this record (must be CDFS_NTC_IRP_CONTEXT)
  785. //
  786. NODE_TYPE_CODE NodeTypeCode;
  787. NODE_BYTE_SIZE NodeByteSize;
  788. //
  789. // Originating Irp for the request.
  790. //
  791. PIRP Irp;
  792. //
  793. // Vcb for this operation. When this is NULL it means we were called
  794. // with our filesystem device object instead of a volume device object.
  795. // (Mount will fill this in once the Vcb is created)
  796. //
  797. PVCB Vcb;
  798. //
  799. // Exception encountered during the request. Any error raised explicitly by
  800. // the file system will be stored here. Any other error raised by the system
  801. // is stored here after normalizing it.
  802. //
  803. NTSTATUS ExceptionStatus;
  804. //
  805. // Flags for this request.
  806. //
  807. ULONG Flags;
  808. //
  809. // Real device object. This represents the physical device closest to the media.
  810. //
  811. PDEVICE_OBJECT RealDevice;
  812. //
  813. // Io context for a read request.
  814. // Address of Fcb for teardown oplock in create case.
  815. //
  816. union {
  817. struct _CD_IO_CONTEXT *IoContext;
  818. PFCB *TeardownFcb;
  819. };
  820. //
  821. // Top level irp context for this thread.
  822. //
  823. struct _IRP_CONTEXT *TopLevel;
  824. //
  825. // Major and minor function codes.
  826. //
  827. UCHAR MajorFunction;
  828. UCHAR MinorFunction;
  829. //
  830. // Pointer to the top-level context if this IrpContext is responsible
  831. // for cleaning it up.
  832. //
  833. struct _THREAD_CONTEXT *ThreadContext;
  834. //
  835. // This structure is used for posting to the Ex worker threads.
  836. //
  837. WORK_QUEUE_ITEM WorkQueueItem;
  838. } IRP_CONTEXT;
  839. typedef IRP_CONTEXT *PIRP_CONTEXT;
  840. #define IRP_CONTEXT_FLAG_ON_STACK (0x00000001)
  841. #define IRP_CONTEXT_FLAG_MORE_PROCESSING (0x00000002)
  842. #define IRP_CONTEXT_FLAG_WAIT (0x00000004)
  843. #define IRP_CONTEXT_FLAG_FORCE_POST (0x00000008)
  844. #define IRP_CONTEXT_FLAG_TOP_LEVEL (0x00000010)
  845. #define IRP_CONTEXT_FLAG_TOP_LEVEL_CDFS (0x00000020)
  846. #define IRP_CONTEXT_FLAG_IN_FSP (0x00000040)
  847. #define IRP_CONTEXT_FLAG_IN_TEARDOWN (0x00000080)
  848. #define IRP_CONTEXT_FLAG_ALLOC_IO (0x00000100)
  849. #define IRP_CONTEXT_FLAG_DISABLE_POPUPS (0x00000200)
  850. #define IRP_CONTEXT_FLAG_FORCE_VERIFY (0x00000400)
  851. //
  852. // Flags used for create.
  853. //
  854. #define IRP_CONTEXT_FLAG_FULL_NAME (0x10000000)
  855. #define IRP_CONTEXT_FLAG_TRAIL_BACKSLASH (0x20000000)
  856. //
  857. // The following flags need to be cleared when a request is posted.
  858. //
  859. #define IRP_CONTEXT_FLAGS_CLEAR_ON_POST ( \
  860. IRP_CONTEXT_FLAG_MORE_PROCESSING | \
  861. IRP_CONTEXT_FLAG_WAIT | \
  862. IRP_CONTEXT_FLAG_FORCE_POST | \
  863. IRP_CONTEXT_FLAG_TOP_LEVEL | \
  864. IRP_CONTEXT_FLAG_TOP_LEVEL_CDFS | \
  865. IRP_CONTEXT_FLAG_IN_FSP | \
  866. IRP_CONTEXT_FLAG_IN_TEARDOWN | \
  867. IRP_CONTEXT_FLAG_DISABLE_POPUPS \
  868. )
  869. //
  870. // The following flags need to be cleared when a request is retried.
  871. //
  872. #define IRP_CONTEXT_FLAGS_CLEAR_ON_RETRY ( \
  873. IRP_CONTEXT_FLAG_MORE_PROCESSING | \
  874. IRP_CONTEXT_FLAG_IN_TEARDOWN | \
  875. IRP_CONTEXT_FLAG_DISABLE_POPUPS \
  876. )
  877. //
  878. // The following flags are set each time through the Fsp loop.
  879. //
  880. #define IRP_CONTEXT_FSP_FLAGS ( \
  881. IRP_CONTEXT_FLAG_WAIT | \
  882. IRP_CONTEXT_FLAG_TOP_LEVEL | \
  883. IRP_CONTEXT_FLAG_TOP_LEVEL_CDFS | \
  884. IRP_CONTEXT_FLAG_IN_FSP \
  885. )
  886. //
  887. // Following structure is used to queue a request to the delayed close queue.
  888. // This structure should be the minimum block allocation size.
  889. //
  890. typedef struct _IRP_CONTEXT_LITE {
  891. //
  892. // Type and size of this record (must be CDFS_NTC_IRP_CONTEXT_LITE)
  893. //
  894. NODE_TYPE_CODE NodeTypeCode;
  895. NODE_BYTE_SIZE NodeByteSize;
  896. //
  897. // Fcb for the file object being closed.
  898. //
  899. PFCB Fcb;
  900. //
  901. // List entry to attach to delayed close queue.
  902. //
  903. LIST_ENTRY DelayedCloseLinks;
  904. //
  905. // User reference count for the file object being closed.
  906. //
  907. ULONG UserReference;
  908. //
  909. // Real device object. This represents the physical device closest to the media.
  910. //
  911. PDEVICE_OBJECT RealDevice;
  912. } IRP_CONTEXT_LITE;
  913. typedef IRP_CONTEXT_LITE *PIRP_CONTEXT_LITE;
  914. //
  915. // Context structure for asynchronous I/O calls. Most of these fields
  916. // are actually only required for the ReadMultiple routines, but
  917. // the caller must allocate one as a local variable anyway before knowing
  918. // whether there are multiple requests are not. Therefore, a single
  919. // structure is used for simplicity.
  920. //
  921. typedef struct _CD_IO_CONTEXT {
  922. //
  923. // These two fields are used for multiple run Io
  924. //
  925. LONG IrpCount;
  926. PIRP MasterIrp;
  927. NTSTATUS Status;
  928. BOOLEAN AllocatedContext;
  929. union {
  930. //
  931. // This element handles the asynchronous non-cached Io
  932. //
  933. struct {
  934. PERESOURCE Resource;
  935. ERESOURCE_THREAD ResourceThreadId;
  936. ULONG RequestedByteCount;
  937. };
  938. //
  939. // and this element handles the synchronous non-cached Io.
  940. //
  941. KEVENT SyncEvent;
  942. };
  943. } CD_IO_CONTEXT;
  944. typedef CD_IO_CONTEXT *PCD_IO_CONTEXT;
  945. //
  946. // Following structure is used to track the top level request. Each Cdfs
  947. // Fsd and Fsp entry point will examine the top level irp location in the
  948. // thread local storage to determine if this request is top level and/or
  949. // top level Cdfs. The top level Cdfs request will remember the previous
  950. // value and update that location with a stack location. This location
  951. // can be accessed by recursive Cdfs entry points.
  952. //
  953. typedef struct _THREAD_CONTEXT {
  954. //
  955. // CDFS signature. Used to confirm structure on stack is valid.
  956. //
  957. ULONG Cdfs;
  958. //
  959. // Previous value in top-level thread location. We restore this
  960. // when done.
  961. //
  962. PIRP SavedTopLevelIrp;
  963. //
  964. // Top level Cdfs IrpContext. Initial Cdfs entry point on stack
  965. // will store the IrpContext for the request in this stack location.
  966. //
  967. PIRP_CONTEXT TopLevelIrpContext;
  968. } THREAD_CONTEXT;
  969. typedef THREAD_CONTEXT *PTHREAD_CONTEXT;
  970. //
  971. // The following structure is used for enumerating the entries in the
  972. // path table. We will always map this two sectors at a time so we don't
  973. // have to worry about entries which span sectors. We move through
  974. // one sector at a time though. We will unpin and remap after
  975. // crossing a sector boundary.
  976. //
  977. // The only special case is where we span a cache view. In that case
  978. // we will allocate a buffer and read both pieces into it.
  979. //
  980. // This strategy takes advantage of the CC enhancement which allows
  981. // overlapping ranges.
  982. //
  983. typedef struct _PATH_ENUM_CONTEXT {
  984. //
  985. // Pointer to the current sector and the offset of this sector to
  986. // the beginning of the path table. The Data pointer may be
  987. // a pool block in the case where we cross a cache view
  988. // boundary. Also the length of the data for this block.
  989. //
  990. PVOID Data;
  991. ULONG BaseOffset;
  992. ULONG DataLength;
  993. //
  994. // Bcb for the sector. (We may actually have pinned two sectors)
  995. // This will be NULL for the case where we needed to allocate a
  996. // buffer in the case where we span a cache view.
  997. //
  998. PBCB Bcb;
  999. //
  1000. // Offset to current entry within the current data block.
  1001. //
  1002. ULONG DataOffset;
  1003. //
  1004. // Did we allocate the buffer for the entry.
  1005. //
  1006. BOOLEAN AllocatedData;
  1007. //
  1008. // End of Path Table. This tells us whether the current data
  1009. // block includes the end of the path table. This is the
  1010. // only block where we need to do a careful check about whether
  1011. // the path table entry fits into the buffer.
  1012. //
  1013. // Also once we have reached the end of the path table we don't
  1014. // need to remap the data as we move into the final sector.
  1015. // We always look at the last two sectors together.
  1016. //
  1017. BOOLEAN LastDataBlock;
  1018. } PATH_ENUM_CONTEXT;
  1019. typedef PATH_ENUM_CONTEXT *PPATH_ENUM_CONTEXT;
  1020. #define VACB_MAPPING_MASK (VACB_MAPPING_GRANULARITY - 1)
  1021. #define LAST_VACB_SECTOR_OFFSET (VACB_MAPPING_GRANULARITY - SECTOR_SIZE)
  1022. //
  1023. // Path Entry. This is our representation of the on disk data.
  1024. //
  1025. typedef struct _PATH_ENTRY {
  1026. //
  1027. // Directory number and offset. This is the ordinal and the offset from
  1028. // the beginning of the path table stream for this entry.
  1029. //
  1030. //
  1031. ULONG Ordinal;
  1032. ULONG PathTableOffset;
  1033. //
  1034. // Logical block Offset on the disk for this entry. We already bias
  1035. // this by any Xar blocks.
  1036. //
  1037. ULONG DiskOffset;
  1038. //
  1039. // Length of on-disk path table entry.
  1040. //
  1041. ULONG PathEntryLength;
  1042. //
  1043. // Parent number.
  1044. //
  1045. ULONG ParentOrdinal;
  1046. //
  1047. // DirName length and Id. Typically the pointer here points to the raw on-disk
  1048. // bytes. We will point to a fixed self entry if this is the root directory.
  1049. //
  1050. ULONG DirNameLen;
  1051. PCHAR DirName;
  1052. //
  1053. // Following are the flags used to cleanup this structure.
  1054. //
  1055. ULONG Flags;
  1056. //
  1057. // The following is the filename string and version number strings. We embed a buffer
  1058. // large enough to hold two 8.3 names. One for exact case and one for case insensitive.
  1059. //
  1060. CD_NAME CdDirName;
  1061. CD_NAME CdCaseDirName;
  1062. WCHAR NameBuffer[BYTE_COUNT_EMBEDDED_NAME / sizeof( WCHAR ) * 2];
  1063. } PATH_ENTRY;
  1064. typedef PATH_ENTRY *PPATH_ENTRY;
  1065. #define PATH_ENTRY_FLAG_ALLOC_BUFFER (0x00000001)
  1066. //
  1067. // Compound path entry. This structure combines the on-disk entries
  1068. // with the in-memory structures.
  1069. //
  1070. typedef struct _COMPOUND_PATH_ENTRY {
  1071. PATH_ENUM_CONTEXT PathContext;
  1072. PATH_ENTRY PathEntry;
  1073. } COMPOUND_PATH_ENTRY;
  1074. typedef COMPOUND_PATH_ENTRY *PCOMPOUND_PATH_ENTRY;
  1075. //
  1076. // The following is used for enumerating through a directory via the
  1077. // dirents.
  1078. //
  1079. typedef struct _DIRENT_ENUM_CONTEXT {
  1080. //
  1081. // Pointer the current sector and the offset of this sector within
  1082. // the directory file. Also the data length of this pinned block.
  1083. //
  1084. PVOID Sector;
  1085. ULONG BaseOffset;
  1086. ULONG DataLength;
  1087. //
  1088. // Bcb for the sector.
  1089. //
  1090. PBCB Bcb;
  1091. //
  1092. // Offset to the current dirent within this sector.
  1093. //
  1094. ULONG SectorOffset;
  1095. //
  1096. // Length to next dirent. A zero indicates to move to the next sector.
  1097. //
  1098. ULONG NextDirentOffset;
  1099. } DIRENT_ENUM_CONTEXT;
  1100. typedef DIRENT_ENUM_CONTEXT *PDIRENT_ENUM_CONTEXT;
  1101. //
  1102. // Following structure is used to smooth out the differences in the HSG, ISO
  1103. // and Joliett directory entries.
  1104. //
  1105. typedef struct _DIRENT {
  1106. //
  1107. // Offset in the Directory of this entry. Note this includes
  1108. // any bytes added to the beginning of the directory to pad
  1109. // down to a sector boundary.
  1110. //
  1111. ULONG DirentOffset;
  1112. ULONG DirentLength;
  1113. //
  1114. // Starting offset on the disk including any Xar blocks.
  1115. //
  1116. ULONG StartingOffset;
  1117. //
  1118. // DataLength of the data. If not the last block then this should
  1119. // be an integral number of logical blocks.
  1120. //
  1121. ULONG DataLength;
  1122. //
  1123. // The following field is the time stamp out of the directory entry.
  1124. // Use a pointer into the dirent for this.
  1125. //
  1126. PCHAR CdTime;
  1127. //
  1128. // The following field is the dirent file flags field.
  1129. //
  1130. UCHAR DirentFlags;
  1131. //
  1132. // Following field is a Cdfs flag field used to clean up this structure.
  1133. //
  1134. UCHAR Flags;
  1135. //
  1136. // The following fields indicate the file unit size and interleave gap
  1137. // for interleaved files. Each of these are in logical blocks.
  1138. //
  1139. ULONG FileUnitSize;
  1140. ULONG InterleaveGapSize;
  1141. //
  1142. // System use offset. Zero value indicates no system use area.
  1143. //
  1144. ULONG SystemUseOffset;
  1145. //
  1146. // CDXA attributes and file number for this file.
  1147. //
  1148. USHORT XAAttributes;
  1149. UCHAR XAFileNumber;
  1150. //
  1151. // Filename length and ID. We copy the length (in bytes) and keep
  1152. // a pointer to the start of the name.
  1153. //
  1154. ULONG FileNameLen;
  1155. PCHAR FileName;
  1156. //
  1157. // The following are the filenames stored by name and version numbers.
  1158. // The fixed buffer here can hold two Unicode 8.3 names. This allows
  1159. // us to upcase the name into a fixed buffer.
  1160. //
  1161. CD_NAME CdFileName;
  1162. CD_NAME CdCaseFileName;
  1163. //
  1164. // Data stream type. Indicates if this is audio, XA mode2 form2 or cooked sectors.
  1165. //
  1166. XA_EXTENT_TYPE ExtentType;
  1167. WCHAR NameBuffer[BYTE_COUNT_EMBEDDED_NAME / sizeof( WCHAR ) * 2];
  1168. } DIRENT;
  1169. typedef DIRENT *PDIRENT;
  1170. #define DIRENT_FLAG_ALLOC_BUFFER (0x01)
  1171. #define DIRENT_FLAG_CONSTANT_ENTRY (0x02)
  1172. #define DIRENT_FLAG_NOT_PERSISTENT (0)
  1173. //
  1174. // Following structure combines the on-disk information with the normalized
  1175. // structure.
  1176. //
  1177. typedef struct _COMPOUND_DIRENT {
  1178. DIRENT_ENUM_CONTEXT DirContext;
  1179. DIRENT Dirent;
  1180. } COMPOUND_DIRENT;
  1181. typedef COMPOUND_DIRENT *PCOMPOUND_DIRENT;
  1182. //
  1183. // The following structure is used to enumerate the files in a directory.
  1184. // It contains three DirContext/Dirent pairs and then self pointers to
  1185. // know which of these is begin used how.
  1186. //
  1187. typedef struct _FILE_ENUM_CONTEXT {
  1188. //
  1189. // Pointers to the current compound dirents below.
  1190. //
  1191. // PriorDirent - Initial dirent for the last file encountered.
  1192. // InitialDirent - Initial dirent for the current file.
  1193. // CurrentDirent - Second or later dirent for the current file.
  1194. //
  1195. PCOMPOUND_DIRENT PriorDirent;
  1196. PCOMPOUND_DIRENT InitialDirent;
  1197. PCOMPOUND_DIRENT CurrentDirent;
  1198. //
  1199. // Flags indicating the state of the search.
  1200. //
  1201. ULONG Flags;
  1202. //
  1203. // This is an accumulation of the file sizes of the different extents
  1204. // of a single file.
  1205. //
  1206. LONGLONG FileSize;
  1207. //
  1208. // Short name for this file.
  1209. //
  1210. CD_NAME ShortName;
  1211. WCHAR ShortNameBuffer[ BYTE_COUNT_8_DOT_3 / sizeof( WCHAR ) ];
  1212. //
  1213. // Array of compound dirents.
  1214. //
  1215. COMPOUND_DIRENT Dirents[3];
  1216. } FILE_ENUM_CONTEXT;
  1217. typedef FILE_ENUM_CONTEXT *PFILE_ENUM_CONTEXT;
  1218. #define FILE_CONTEXT_MULTIPLE_DIRENTS (0x00000001)
  1219. //
  1220. // RIFF header. Prepended to the data of a file containing XA sectors.
  1221. // This is a hard-coded structure except that we bias the 'ChunkSize' and
  1222. // 'RawSectors' fields with the file size. We also copy the attributes flag
  1223. // from the system use area in the dirent. We always initialize this
  1224. // structure by copying the XAFileHeader.
  1225. //
  1226. typedef struct _RIFF_HEADER {
  1227. ULONG ChunkId;
  1228. LONG ChunkSize;
  1229. ULONG SignatureCDXA;
  1230. ULONG SignatureFMT;
  1231. ULONG XAChunkSize;
  1232. ULONG OwnerId;
  1233. USHORT Attributes;
  1234. USHORT SignatureXA;
  1235. UCHAR FileNumber;
  1236. UCHAR Reserved[7];
  1237. ULONG SignatureData;
  1238. ULONG RawSectors;
  1239. } RIFF_HEADER;
  1240. typedef RIFF_HEADER *PRIFF_HEADER;
  1241. //
  1242. // Audio play header for CDDA tracks.
  1243. //
  1244. typedef struct _AUDIO_PLAY_HEADER {
  1245. ULONG Chunk;
  1246. ULONG ChunkSize;
  1247. ULONG SignatureCDDA;
  1248. ULONG SignatureFMT;
  1249. ULONG FMTChunkSize;
  1250. USHORT FormatTag;
  1251. USHORT TrackNumber;
  1252. ULONG DiskID;
  1253. ULONG StartingSector;
  1254. ULONG SectorCount;
  1255. UCHAR TrackAddress[4];
  1256. UCHAR TrackLength[4];
  1257. } AUDIO_PLAY_HEADER;
  1258. typedef AUDIO_PLAY_HEADER *PAUDIO_PLAY_HEADER;
  1259. //
  1260. // Some macros for supporting the use of a Generic Table
  1261. // containing all the FCB/DCBs and indexed by their FileId.
  1262. //
  1263. // For directories:
  1264. //
  1265. // The HighPart contains the path table offset of this directory in the
  1266. // path table.
  1267. //
  1268. // The LowPart contains zero except for the upper bit which is
  1269. // set to indicate that this is a directory.
  1270. //
  1271. // For files:
  1272. //
  1273. // The HighPart contains the path table offset of the parent directory
  1274. // in the path table.
  1275. //
  1276. // The LowPart contains the byte offset of the dirent in the parent
  1277. // directory file.
  1278. //
  1279. // A directory is always entered into the Fcb Table as if it's
  1280. // dirent offset was zero. This enables any child to look in the FcbTable
  1281. // for it's parent by searching with the same HighPart but with zero
  1282. // as the value for LowPart.
  1283. //
  1284. // The Id field is a LARGE_INTEGER where the High and Low parts can be
  1285. // accessed separately.
  1286. //
  1287. // The following macros are used to access the Fid fields.
  1288. //
  1289. // CdQueryFidDirentOffset - Accesses the Dirent offset field
  1290. // CdQueryFidPathTableNumber - Accesses the PathTable offset field
  1291. // CdSetFidDirentOffset - Sets the Dirent offset field
  1292. // CdSetFidPathTableNumber - Sets the PathTable ordinal field
  1293. // CdFidIsDirectory - Queries if directory bit is set
  1294. // CdFidSetDirectory - Sets directory bit
  1295. //
  1296. #define FID_DIR_MASK 0x80000000 // high order bit means directory.
  1297. #define CdQueryFidDirentOffset(I) ((I).LowPart & ~FID_DIR_MASK)
  1298. #define CdQueryFidPathTableOffset(I) ((I).HighPart)
  1299. #define CdSetFidDirentOffset(I,D) ((I).LowPart = D)
  1300. #define CdSetFidPathTableOffset(I,P) ((I).HighPart = P)
  1301. #define CdFidIsDirectory(I) FlagOn( (I).LowPart, FID_DIR_MASK )
  1302. #define CdFidSetDirectory(I) SetFlag( (I).LowPart, FID_DIR_MASK )
  1303. #define CdSetFidFromParentAndDirent(I,F,D) { \
  1304. CdSetFidPathTableOffset( (I), CdQueryFidPathTableOffset( (F)->FileId )); \
  1305. CdSetFidDirentOffset( (I), (D)->DirentOffset ); \
  1306. if (FlagOn( (D)->DirentFlags, CD_ATTRIBUTE_DIRECTORY )) { \
  1307. CdFidSetDirectory((I)); \
  1308. } \
  1309. }
  1310. #endif // _CDSTRUC_