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

1771 lines
48 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. ULONG RaisedAtLineFile;
  805. //
  806. // Flags for this request.
  807. //
  808. ULONG Flags;
  809. //
  810. // Real device object. This represents the physical device closest to the media.
  811. //
  812. PDEVICE_OBJECT RealDevice;
  813. //
  814. // Io context for a read request.
  815. // Address of Fcb for teardown oplock in create case.
  816. //
  817. union {
  818. struct _CD_IO_CONTEXT *IoContext;
  819. PFCB *TeardownFcb;
  820. };
  821. //
  822. // Top level irp context for this thread.
  823. //
  824. struct _IRP_CONTEXT *TopLevel;
  825. //
  826. // Major and minor function codes.
  827. //
  828. UCHAR MajorFunction;
  829. UCHAR MinorFunction;
  830. //
  831. // Pointer to the top-level context if this IrpContext is responsible
  832. // for cleaning it up.
  833. //
  834. struct _THREAD_CONTEXT *ThreadContext;
  835. //
  836. // This structure is used for posting to the Ex worker threads.
  837. //
  838. WORK_QUEUE_ITEM WorkQueueItem;
  839. } IRP_CONTEXT;
  840. typedef IRP_CONTEXT *PIRP_CONTEXT;
  841. #define IRP_CONTEXT_FLAG_ON_STACK (0x00000001)
  842. #define IRP_CONTEXT_FLAG_MORE_PROCESSING (0x00000002)
  843. #define IRP_CONTEXT_FLAG_WAIT (0x00000004)
  844. #define IRP_CONTEXT_FLAG_FORCE_POST (0x00000008)
  845. #define IRP_CONTEXT_FLAG_TOP_LEVEL (0x00000010)
  846. #define IRP_CONTEXT_FLAG_TOP_LEVEL_CDFS (0x00000020)
  847. #define IRP_CONTEXT_FLAG_IN_FSP (0x00000040)
  848. #define IRP_CONTEXT_FLAG_IN_TEARDOWN (0x00000080)
  849. #define IRP_CONTEXT_FLAG_ALLOC_IO (0x00000100)
  850. #define IRP_CONTEXT_FLAG_DISABLE_POPUPS (0x00000200)
  851. #define IRP_CONTEXT_FLAG_FORCE_VERIFY (0x00000400)
  852. //
  853. // Flags used for create.
  854. //
  855. #define IRP_CONTEXT_FLAG_FULL_NAME (0x10000000)
  856. #define IRP_CONTEXT_FLAG_TRAIL_BACKSLASH (0x20000000)
  857. //
  858. // The following flags need to be cleared when a request is posted.
  859. //
  860. #define IRP_CONTEXT_FLAGS_CLEAR_ON_POST ( \
  861. IRP_CONTEXT_FLAG_MORE_PROCESSING | \
  862. IRP_CONTEXT_FLAG_WAIT | \
  863. IRP_CONTEXT_FLAG_FORCE_POST | \
  864. IRP_CONTEXT_FLAG_TOP_LEVEL | \
  865. IRP_CONTEXT_FLAG_TOP_LEVEL_CDFS | \
  866. IRP_CONTEXT_FLAG_IN_FSP | \
  867. IRP_CONTEXT_FLAG_IN_TEARDOWN | \
  868. IRP_CONTEXT_FLAG_DISABLE_POPUPS \
  869. )
  870. //
  871. // The following flags need to be cleared when a request is retried.
  872. //
  873. #define IRP_CONTEXT_FLAGS_CLEAR_ON_RETRY ( \
  874. IRP_CONTEXT_FLAG_MORE_PROCESSING | \
  875. IRP_CONTEXT_FLAG_IN_TEARDOWN | \
  876. IRP_CONTEXT_FLAG_DISABLE_POPUPS \
  877. )
  878. //
  879. // The following flags are set each time through the Fsp loop.
  880. //
  881. #define IRP_CONTEXT_FSP_FLAGS ( \
  882. IRP_CONTEXT_FLAG_WAIT | \
  883. IRP_CONTEXT_FLAG_TOP_LEVEL | \
  884. IRP_CONTEXT_FLAG_TOP_LEVEL_CDFS | \
  885. IRP_CONTEXT_FLAG_IN_FSP \
  886. )
  887. //
  888. // Following structure is used to queue a request to the delayed close queue.
  889. // This structure should be the minimum block allocation size.
  890. //
  891. typedef struct _IRP_CONTEXT_LITE {
  892. //
  893. // Type and size of this record (must be CDFS_NTC_IRP_CONTEXT_LITE)
  894. //
  895. NODE_TYPE_CODE NodeTypeCode;
  896. NODE_BYTE_SIZE NodeByteSize;
  897. //
  898. // Fcb for the file object being closed.
  899. //
  900. PFCB Fcb;
  901. //
  902. // List entry to attach to delayed close queue.
  903. //
  904. LIST_ENTRY DelayedCloseLinks;
  905. //
  906. // User reference count for the file object being closed.
  907. //
  908. ULONG UserReference;
  909. //
  910. // Real device object. This represents the physical device closest to the media.
  911. //
  912. PDEVICE_OBJECT RealDevice;
  913. } IRP_CONTEXT_LITE;
  914. typedef IRP_CONTEXT_LITE *PIRP_CONTEXT_LITE;
  915. //
  916. // Context structure for asynchronous I/O calls. Most of these fields
  917. // are actually only required for the ReadMultiple routines, but
  918. // the caller must allocate one as a local variable anyway before knowing
  919. // whether there are multiple requests are not. Therefore, a single
  920. // structure is used for simplicity.
  921. //
  922. typedef struct _CD_IO_CONTEXT {
  923. //
  924. // These two fields are used for multiple run Io
  925. //
  926. LONG IrpCount;
  927. PIRP MasterIrp;
  928. NTSTATUS Status;
  929. BOOLEAN AllocatedContext;
  930. union {
  931. //
  932. // This element handles the asynchronous non-cached Io
  933. //
  934. struct {
  935. PERESOURCE Resource;
  936. ERESOURCE_THREAD ResourceThreadId;
  937. ULONG RequestedByteCount;
  938. };
  939. //
  940. // and this element handles the synchronous non-cached Io.
  941. //
  942. KEVENT SyncEvent;
  943. };
  944. } CD_IO_CONTEXT;
  945. typedef CD_IO_CONTEXT *PCD_IO_CONTEXT;
  946. //
  947. // Following structure is used to track the top level request. Each Cdfs
  948. // Fsd and Fsp entry point will examine the top level irp location in the
  949. // thread local storage to determine if this request is top level and/or
  950. // top level Cdfs. The top level Cdfs request will remember the previous
  951. // value and update that location with a stack location. This location
  952. // can be accessed by recursive Cdfs entry points.
  953. //
  954. typedef struct _THREAD_CONTEXT {
  955. //
  956. // CDFS signature. Used to confirm structure on stack is valid.
  957. //
  958. ULONG Cdfs;
  959. //
  960. // Previous value in top-level thread location. We restore this
  961. // when done.
  962. //
  963. PIRP SavedTopLevelIrp;
  964. //
  965. // Top level Cdfs IrpContext. Initial Cdfs entry point on stack
  966. // will store the IrpContext for the request in this stack location.
  967. //
  968. PIRP_CONTEXT TopLevelIrpContext;
  969. } THREAD_CONTEXT;
  970. typedef THREAD_CONTEXT *PTHREAD_CONTEXT;
  971. //
  972. // The following structure is used for enumerating the entries in the
  973. // path table. We will always map this two sectors at a time so we don't
  974. // have to worry about entries which span sectors. We move through
  975. // one sector at a time though. We will unpin and remap after
  976. // crossing a sector boundary.
  977. //
  978. // The only special case is where we span a cache view. In that case
  979. // we will allocate a buffer and read both pieces into it.
  980. //
  981. // This strategy takes advantage of the CC enhancement which allows
  982. // overlapping ranges.
  983. //
  984. typedef struct _PATH_ENUM_CONTEXT {
  985. //
  986. // Pointer to the current sector and the offset of this sector to
  987. // the beginning of the path table. The Data pointer may be
  988. // a pool block in the case where we cross a cache view
  989. // boundary. Also the length of the data for this block.
  990. //
  991. PVOID Data;
  992. ULONG BaseOffset;
  993. ULONG DataLength;
  994. //
  995. // Bcb for the sector. (We may actually have pinned two sectors)
  996. // This will be NULL for the case where we needed to allocate a
  997. // buffer in the case where we span a cache view.
  998. //
  999. PBCB Bcb;
  1000. //
  1001. // Offset to current entry within the current data block.
  1002. //
  1003. ULONG DataOffset;
  1004. //
  1005. // Did we allocate the buffer for the entry.
  1006. //
  1007. BOOLEAN AllocatedData;
  1008. //
  1009. // End of Path Table. This tells us whether the current data
  1010. // block includes the end of the path table. This is the
  1011. // only block where we need to do a careful check about whether
  1012. // the path table entry fits into the buffer.
  1013. //
  1014. // Also once we have reached the end of the path table we don't
  1015. // need to remap the data as we move into the final sector.
  1016. // We always look at the last two sectors together.
  1017. //
  1018. BOOLEAN LastDataBlock;
  1019. } PATH_ENUM_CONTEXT;
  1020. typedef PATH_ENUM_CONTEXT *PPATH_ENUM_CONTEXT;
  1021. #define VACB_MAPPING_MASK (VACB_MAPPING_GRANULARITY - 1)
  1022. #define LAST_VACB_SECTOR_OFFSET (VACB_MAPPING_GRANULARITY - SECTOR_SIZE)
  1023. //
  1024. // Path Entry. This is our representation of the on disk data.
  1025. //
  1026. typedef struct _PATH_ENTRY {
  1027. //
  1028. // Directory number and offset. This is the ordinal and the offset from
  1029. // the beginning of the path table stream for this entry.
  1030. //
  1031. //
  1032. ULONG Ordinal;
  1033. ULONG PathTableOffset;
  1034. //
  1035. // Logical block Offset on the disk for this entry. We already bias
  1036. // this by any Xar blocks.
  1037. //
  1038. ULONG DiskOffset;
  1039. //
  1040. // Length of on-disk path table entry.
  1041. //
  1042. ULONG PathEntryLength;
  1043. //
  1044. // Parent number.
  1045. //
  1046. ULONG ParentOrdinal;
  1047. //
  1048. // DirName length and Id. Typically the pointer here points to the raw on-disk
  1049. // bytes. We will point to a fixed self entry if this is the root directory.
  1050. //
  1051. ULONG DirNameLen;
  1052. PCHAR DirName;
  1053. //
  1054. // Following are the flags used to cleanup this structure.
  1055. //
  1056. ULONG Flags;
  1057. //
  1058. // The following is the filename string and version number strings. We embed a buffer
  1059. // large enough to hold two 8.3 names. One for exact case and one for case insensitive.
  1060. //
  1061. CD_NAME CdDirName;
  1062. CD_NAME CdCaseDirName;
  1063. WCHAR NameBuffer[BYTE_COUNT_EMBEDDED_NAME / sizeof( WCHAR ) * 2];
  1064. } PATH_ENTRY;
  1065. typedef PATH_ENTRY *PPATH_ENTRY;
  1066. #define PATH_ENTRY_FLAG_ALLOC_BUFFER (0x00000001)
  1067. //
  1068. // Compound path entry. This structure combines the on-disk entries
  1069. // with the in-memory structures.
  1070. //
  1071. typedef struct _COMPOUND_PATH_ENTRY {
  1072. PATH_ENUM_CONTEXT PathContext;
  1073. PATH_ENTRY PathEntry;
  1074. } COMPOUND_PATH_ENTRY;
  1075. typedef COMPOUND_PATH_ENTRY *PCOMPOUND_PATH_ENTRY;
  1076. //
  1077. // The following is used for enumerating through a directory via the
  1078. // dirents.
  1079. //
  1080. typedef struct _DIRENT_ENUM_CONTEXT {
  1081. //
  1082. // Pointer the current sector and the offset of this sector within
  1083. // the directory file. Also the data length of this pinned block.
  1084. //
  1085. PVOID Sector;
  1086. ULONG BaseOffset;
  1087. ULONG DataLength;
  1088. //
  1089. // Bcb for the sector.
  1090. //
  1091. PBCB Bcb;
  1092. //
  1093. // Offset to the current dirent within this sector.
  1094. //
  1095. ULONG SectorOffset;
  1096. //
  1097. // Length to next dirent. A zero indicates to move to the next sector.
  1098. //
  1099. ULONG NextDirentOffset;
  1100. } DIRENT_ENUM_CONTEXT;
  1101. typedef DIRENT_ENUM_CONTEXT *PDIRENT_ENUM_CONTEXT;
  1102. //
  1103. // Following structure is used to smooth out the differences in the HSG, ISO
  1104. // and Joliett directory entries.
  1105. //
  1106. typedef struct _DIRENT {
  1107. //
  1108. // Offset in the Directory of this entry. Note this includes
  1109. // any bytes added to the beginning of the directory to pad
  1110. // down to a sector boundary.
  1111. //
  1112. ULONG DirentOffset;
  1113. ULONG DirentLength;
  1114. //
  1115. // Starting offset on the disk including any Xar blocks.
  1116. //
  1117. ULONG StartingOffset;
  1118. //
  1119. // DataLength of the data. If not the last block then this should
  1120. // be an integral number of logical blocks.
  1121. //
  1122. ULONG DataLength;
  1123. //
  1124. // The following field is the time stamp out of the directory entry.
  1125. // Use a pointer into the dirent for this.
  1126. //
  1127. PCHAR CdTime;
  1128. //
  1129. // The following field is the dirent file flags field.
  1130. //
  1131. UCHAR DirentFlags;
  1132. //
  1133. // Following field is a Cdfs flag field used to clean up this structure.
  1134. //
  1135. UCHAR Flags;
  1136. //
  1137. // The following fields indicate the file unit size and interleave gap
  1138. // for interleaved files. Each of these are in logical blocks.
  1139. //
  1140. ULONG FileUnitSize;
  1141. ULONG InterleaveGapSize;
  1142. //
  1143. // System use offset. Zero value indicates no system use area.
  1144. //
  1145. ULONG SystemUseOffset;
  1146. //
  1147. // CDXA attributes and file number for this file.
  1148. //
  1149. USHORT XAAttributes;
  1150. UCHAR XAFileNumber;
  1151. //
  1152. // Filename length and ID. We copy the length (in bytes) and keep
  1153. // a pointer to the start of the name.
  1154. //
  1155. ULONG FileNameLen;
  1156. PCHAR FileName;
  1157. //
  1158. // The following are the filenames stored by name and version numbers.
  1159. // The fixed buffer here can hold two Unicode 8.3 names. This allows
  1160. // us to upcase the name into a fixed buffer.
  1161. //
  1162. CD_NAME CdFileName;
  1163. CD_NAME CdCaseFileName;
  1164. //
  1165. // Data stream type. Indicates if this is audio, XA mode2 form2 or cooked sectors.
  1166. //
  1167. XA_EXTENT_TYPE ExtentType;
  1168. WCHAR NameBuffer[BYTE_COUNT_EMBEDDED_NAME / sizeof( WCHAR ) * 2];
  1169. } DIRENT;
  1170. typedef DIRENT *PDIRENT;
  1171. #define DIRENT_FLAG_ALLOC_BUFFER (0x01)
  1172. #define DIRENT_FLAG_CONSTANT_ENTRY (0x02)
  1173. #define DIRENT_FLAG_NOT_PERSISTENT (0)
  1174. //
  1175. // Following structure combines the on-disk information with the normalized
  1176. // structure.
  1177. //
  1178. typedef struct _COMPOUND_DIRENT {
  1179. DIRENT_ENUM_CONTEXT DirContext;
  1180. DIRENT Dirent;
  1181. } COMPOUND_DIRENT;
  1182. typedef COMPOUND_DIRENT *PCOMPOUND_DIRENT;
  1183. //
  1184. // The following structure is used to enumerate the files in a directory.
  1185. // It contains three DirContext/Dirent pairs and then self pointers to
  1186. // know which of these is begin used how.
  1187. //
  1188. typedef struct _FILE_ENUM_CONTEXT {
  1189. //
  1190. // Pointers to the current compound dirents below.
  1191. //
  1192. // PriorDirent - Initial dirent for the last file encountered.
  1193. // InitialDirent - Initial dirent for the current file.
  1194. // CurrentDirent - Second or later dirent for the current file.
  1195. //
  1196. PCOMPOUND_DIRENT PriorDirent;
  1197. PCOMPOUND_DIRENT InitialDirent;
  1198. PCOMPOUND_DIRENT CurrentDirent;
  1199. //
  1200. // Flags indicating the state of the search.
  1201. //
  1202. ULONG Flags;
  1203. //
  1204. // This is an accumulation of the file sizes of the different extents
  1205. // of a single file.
  1206. //
  1207. LONGLONG FileSize;
  1208. //
  1209. // Short name for this file.
  1210. //
  1211. CD_NAME ShortName;
  1212. WCHAR ShortNameBuffer[ BYTE_COUNT_8_DOT_3 / sizeof( WCHAR ) ];
  1213. //
  1214. // Array of compound dirents.
  1215. //
  1216. COMPOUND_DIRENT Dirents[3];
  1217. } FILE_ENUM_CONTEXT;
  1218. typedef FILE_ENUM_CONTEXT *PFILE_ENUM_CONTEXT;
  1219. #define FILE_CONTEXT_MULTIPLE_DIRENTS (0x00000001)
  1220. //
  1221. // RIFF header. Prepended to the data of a file containing XA sectors.
  1222. // This is a hard-coded structure except that we bias the 'ChunkSize' and
  1223. // 'RawSectors' fields with the file size. We also copy the attributes flag
  1224. // from the system use area in the dirent. We always initialize this
  1225. // structure by copying the XAFileHeader.
  1226. //
  1227. typedef struct _RIFF_HEADER {
  1228. ULONG ChunkId;
  1229. LONG ChunkSize;
  1230. ULONG SignatureCDXA;
  1231. ULONG SignatureFMT;
  1232. ULONG XAChunkSize;
  1233. ULONG OwnerId;
  1234. USHORT Attributes;
  1235. USHORT SignatureXA;
  1236. UCHAR FileNumber;
  1237. UCHAR Reserved[7];
  1238. ULONG SignatureData;
  1239. ULONG RawSectors;
  1240. } RIFF_HEADER;
  1241. typedef RIFF_HEADER *PRIFF_HEADER;
  1242. //
  1243. // Audio play header for CDDA tracks.
  1244. //
  1245. typedef struct _AUDIO_PLAY_HEADER {
  1246. ULONG Chunk;
  1247. ULONG ChunkSize;
  1248. ULONG SignatureCDDA;
  1249. ULONG SignatureFMT;
  1250. ULONG FMTChunkSize;
  1251. USHORT FormatTag;
  1252. USHORT TrackNumber;
  1253. ULONG DiskID;
  1254. ULONG StartingSector;
  1255. ULONG SectorCount;
  1256. UCHAR TrackAddress[4];
  1257. UCHAR TrackLength[4];
  1258. } AUDIO_PLAY_HEADER;
  1259. typedef AUDIO_PLAY_HEADER *PAUDIO_PLAY_HEADER;
  1260. //
  1261. // Some macros for supporting the use of a Generic Table
  1262. // containing all the FCB/DCBs and indexed by their FileId.
  1263. //
  1264. // For directories:
  1265. //
  1266. // The HighPart contains the path table offset of this directory in the
  1267. // path table.
  1268. //
  1269. // The LowPart contains zero except for the upper bit which is
  1270. // set to indicate that this is a directory.
  1271. //
  1272. // For files:
  1273. //
  1274. // The HighPart contains the path table offset of the parent directory
  1275. // in the path table.
  1276. //
  1277. // The LowPart contains the byte offset of the dirent in the parent
  1278. // directory file.
  1279. //
  1280. // A directory is always entered into the Fcb Table as if it's
  1281. // dirent offset was zero. This enables any child to look in the FcbTable
  1282. // for it's parent by searching with the same HighPart but with zero
  1283. // as the value for LowPart.
  1284. //
  1285. // The Id field is a LARGE_INTEGER where the High and Low parts can be
  1286. // accessed separately.
  1287. //
  1288. // The following macros are used to access the Fid fields.
  1289. //
  1290. // CdQueryFidDirentOffset - Accesses the Dirent offset field
  1291. // CdQueryFidPathTableNumber - Accesses the PathTable offset field
  1292. // CdSetFidDirentOffset - Sets the Dirent offset field
  1293. // CdSetFidPathTableNumber - Sets the PathTable ordinal field
  1294. // CdFidIsDirectory - Queries if directory bit is set
  1295. // CdFidSetDirectory - Sets directory bit
  1296. //
  1297. #define FID_DIR_MASK 0x80000000 // high order bit means directory.
  1298. #define CdQueryFidDirentOffset(I) ((I).LowPart & ~FID_DIR_MASK)
  1299. #define CdQueryFidPathTableOffset(I) ((I).HighPart)
  1300. #define CdSetFidDirentOffset(I,D) ((I).LowPart = D)
  1301. #define CdSetFidPathTableOffset(I,P) ((I).HighPart = P)
  1302. #define CdFidIsDirectory(I) FlagOn( (I).LowPart, FID_DIR_MASK )
  1303. #define CdFidSetDirectory(I) SetFlag( (I).LowPart, FID_DIR_MASK )
  1304. #define CdSetFidFromParentAndDirent(I,F,D) { \
  1305. CdSetFidPathTableOffset( (I), CdQueryFidPathTableOffset( (F)->FileId )); \
  1306. CdSetFidDirentOffset( (I), (D)->DirentOffset ); \
  1307. if (FlagOn( (D)->DirentFlags, CD_ATTRIBUTE_DIRECTORY )) { \
  1308. CdFidSetDirectory((I)); \
  1309. } \
  1310. }
  1311. #endif // _CDSTRUC_