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.

299 lines
10 KiB

  1. /*++
  2. Copyright (c) 1989-2000 Microsoft Corporation
  3. Module Name:
  4. CdData.c
  5. Abstract:
  6. This module declares the global data used by the Cdfs file system.
  7. // @@BEGIN_DDKSPLIT
  8. Author:
  9. Brian Andrew [BrianAn] 01-July-1995
  10. Revision History:
  11. // @@END_DDKSPLIT
  12. --*/
  13. #ifndef _CDDATA_
  14. #define _CDDATA_
  15. //
  16. // Global data structures
  17. //
  18. extern CD_DATA CdData;
  19. extern FAST_IO_DISPATCH CdFastIoDispatch;
  20. //
  21. // Global constants
  22. //
  23. //
  24. // This is the number of times a mounted Vcb will be referenced on behalf
  25. // of the system. The counts include the following references.
  26. //
  27. // 1 reference - shows the volume is mounted
  28. // 1 reference - 1 for VolumeDasdFcb.
  29. // 2 references - 1 for RootIndexFcb, 1 for internal stream.
  30. // 2 references - 1 for PathTableFcb, 1 for internal stream.
  31. //
  32. // For user references we add one for the reference in each of the internal
  33. // Fcb's.
  34. //
  35. #define CDFS_RESIDUAL_REFERENCE (6)
  36. #define CDFS_RESIDUAL_USER_REFERENCE (3)
  37. //
  38. // Reserved directory strings
  39. //
  40. extern WCHAR CdUnicodeSelfArray[];
  41. extern WCHAR CdUnicodeParentArray[];
  42. extern UNICODE_STRING CdUnicodeDirectoryNames[];
  43. //
  44. // Volume descriptor identifier strings.
  45. //
  46. extern CHAR CdHsgId[];
  47. extern CHAR CdIsoId[];
  48. extern CHAR CdXaId[];
  49. //
  50. // Volume label for audio disks.
  51. //
  52. extern WCHAR CdAudioLabel[];
  53. extern USHORT CdAudioLabelLength;
  54. //
  55. // Pseudo file names for audio disks.
  56. //
  57. extern CHAR CdAudioFileName[];
  58. extern UCHAR CdAudioFileNameLength;
  59. extern ULONG CdAudioDirentSize;
  60. extern ULONG CdAudioDirentsPerSector;
  61. extern ULONG CdAudioSystemUseOffset;
  62. #define AUDIO_NAME_ONES_OFFSET (6)
  63. #define AUDIO_NAME_TENS_OFFSET (5)
  64. //
  65. // Escape sequences for mounting Unicode volumes.
  66. //
  67. extern PCHAR CdJolietEscape[];
  68. //
  69. // Hardcoded header for RIFF files.
  70. //
  71. extern LONG CdXAFileHeader[];
  72. extern LONG CdAudioPlayHeader[];
  73. extern LONG CdXAAudioPhileHeader[];
  74. //
  75. // Turn on pseudo-asserts if CD_FREE_ASSERTS is defined.
  76. //
  77. #if !DBG
  78. #ifdef CD_FREE_ASSERTS
  79. #undef ASSERT
  80. #undef ASSERTMSG
  81. #define ASSERT(exp) if (!(exp)) { extern BOOLEAN KdDebuggerEnabled; DbgPrint("%s:%d %s\n",__FILE__,__LINE__,#exp); if (KdDebuggerEnabled) { DbgBreakPoint(); } }
  82. #define ASSERTMSG(msg,exp) if (!(exp)) { extern BOOLEAN KdDebuggerEnabled; DbgPrint("%s:%d %s %s\n",__FILE__,__LINE__,msg,#exp); if (KdDebuggerEnabled) { DbgBreakPoint(); } }
  83. #endif
  84. #endif
  85. //
  86. // The following assertion macros ensure that the indicated structure
  87. // is valid
  88. //
  89. // ASSERT_STRUCT( IN PVOID Struct, IN CSHORT NodeType );
  90. // ASSERT_OPTIONAL_STRUCT( IN PVOID Struct OPTIONAL, IN CSHORT NodeType );
  91. //
  92. // ASSERT_VCB( IN PVCB Vcb );
  93. // ASSERT_OPTIONAL_VCB( IN PVCB Vcb OPTIONAL );
  94. //
  95. // ASSERT_FCB( IN PFCB Fcb );
  96. // ASSERT_OPTIONAL_FCB( IN PFCB Fcb OPTIONAL );
  97. //
  98. // ASSERT_FCB_NONPAGED( IN PFCB_NONPAGED FcbNonpaged );
  99. // ASSERT_OPTIONAL_FCB( IN PFCB_NONPAGED FcbNonpaged OPTIONAL );
  100. //
  101. // ASSERT_CCB( IN PSCB Ccb );
  102. // ASSERT_OPTIONAL_CCB( IN PSCB Ccb OPTIONAL );
  103. //
  104. // ASSERT_IRP_CONTEXT( IN PIRP_CONTEXT IrpContext );
  105. // ASSERT_OPTIONAL_IRP_CONTEXT( IN PIRP_CONTEXT IrpContext OPTIONAL );
  106. //
  107. // ASSERT_IRP( IN PIRP Irp );
  108. // ASSERT_OPTIONAL_IRP( IN PIRP Irp OPTIONAL );
  109. //
  110. // ASSERT_FILE_OBJECT( IN PFILE_OBJECT FileObject );
  111. // ASSERT_OPTIONAL_FILE_OBJECT( IN PFILE_OBJECT FileObject OPTIONAL );
  112. //
  113. // The following macros are used to check the current thread owns
  114. // the indicated resource
  115. //
  116. // ASSERT_EXCLUSIVE_RESOURCE( IN PERESOURCE Resource );
  117. //
  118. // ASSERT_SHARED_RESOURCE( IN PERESOURCE Resource );
  119. //
  120. // ASSERT_RESOURCE_NOT_MINE( IN PERESOURCE Resource );
  121. //
  122. // The following macros are used to check whether the current thread
  123. // owns the resoures in the given structures.
  124. //
  125. // ASSERT_EXCLUSIVE_CDDATA
  126. //
  127. // ASSERT_EXCLUSIVE_VCB( IN PVCB Vcb );
  128. //
  129. // ASSERT_SHARED_VCB( IN PVCB Vcb );
  130. //
  131. // ASSERT_EXCLUSIVE_FCB( IN PFCB Fcb );
  132. //
  133. // ASSERT_SHARED_FCB( IN PFCB Fcb );
  134. //
  135. // ASSERT_EXCLUSIVE_FILE( IN PFCB Fcb );
  136. //
  137. // ASSERT_SHARED_FILE( IN PFCB Fcb );
  138. //
  139. // ASSERT_LOCKED_VCB( IN PVCB Vcb );
  140. //
  141. // ASSERT_NOT_LOCKED_VCB( IN PVCB Vcb );
  142. //
  143. // ASSERT_LOCKED_FCB( IN PFCB Fcb );
  144. //
  145. // ASSERT_NOT_LOCKED_FCB( IN PFCB Fcb );
  146. //
  147. //
  148. // Turn on the sanity checks if this is DBG or CD_FREE_ASSERTS
  149. //
  150. #if DBG
  151. #undef CD_SANITY
  152. #define CD_SANITY
  153. #endif
  154. #ifdef CD_SANITY
  155. extern BOOLEAN CdTestRaisedStatus;
  156. #define DebugBreakOnStatus(S) { \
  157. if (CdTestRaisedStatus) { \
  158. if ((S) == STATUS_DISK_CORRUPT_ERROR || (S) == STATUS_FILE_CORRUPT_ERROR) { \
  159. DbgPrint( "CDFS: Breaking on possible media corruption (S = %08x)\n", (S)); \
  160. DbgPrint( "CDFS: Contact CDFS.SYS component owner for triage.\n"); \
  161. DbgPrint( "CDFS: 'eb %p 0' to disable this alert\n", &CdTestRaisedStatus ); \
  162. DbgBreakPoint(); \
  163. } \
  164. } \
  165. }
  166. #define ASSERT_STRUCT(S,T) ASSERT( SafeNodeType( S ) == (T) )
  167. #define ASSERT_OPTIONAL_STRUCT(S,T) ASSERT( ((S) == NULL) || (SafeNodeType( S ) == (T)) )
  168. #define ASSERT_VCB(V) ASSERT_STRUCT( (V), CDFS_NTC_VCB )
  169. #define ASSERT_OPTIONAL_VCB(V) ASSERT_OPTIONAL_STRUCT( (V), CDFS_NTC_VCB )
  170. #define ASSERT_FCB(F) \
  171. ASSERT( (SafeNodeType( F ) == CDFS_NTC_FCB_DATA ) || \
  172. (SafeNodeType( F ) == CDFS_NTC_FCB_INDEX ) || \
  173. (SafeNodeType( F ) == CDFS_NTC_FCB_PATH_TABLE ) )
  174. #define ASSERT_OPTIONAL_FCB(F) \
  175. ASSERT( ((F) == NULL) || \
  176. (SafeNodeType( F ) == CDFS_NTC_FCB_DATA ) || \
  177. (SafeNodeType( F ) == CDFS_NTC_FCB_INDEX ) || \
  178. (SafeNodeType( F ) == CDFS_NTC_FCB_PATH_TABLE ) )
  179. #define ASSERT_FCB_NONPAGED(FN) ASSERT_STRUCT( (FN), CDFS_NTC_FCB_NONPAGED )
  180. #define ASSERT_OPTIONAL_FCB_NONPAGED(FN) ASSERT_OPTIONAL_STRUCT( (FN), CDFS_NTC_FCB_NONPAGED )
  181. #define ASSERT_CCB(C) ASSERT_STRUCT( (C), CDFS_NTC_CCB )
  182. #define ASSERT_OPTIONAL_CCB(C) ASSERT_OPTIONAL_STRUCT( (C), CDFS_NTC_CCB )
  183. #define ASSERT_IRP_CONTEXT(IC) ASSERT_STRUCT( (IC), CDFS_NTC_IRP_CONTEXT )
  184. #define ASSERT_OPTIONAL_IRP_CONTEXT(IC) ASSERT_OPTIONAL_STRUCT( (IC), CDFS_NTC_IRP_CONTEXT )
  185. #define ASSERT_IRP(I) ASSERT_STRUCT( (I), IO_TYPE_IRP )
  186. #define ASSERT_OPTIONAL_IRP(I) ASSERT_OPTIONAL_STRUCT( (I), IO_TYPE_IRP )
  187. #define ASSERT_FILE_OBJECT(FO) ASSERT_STRUCT( (FO), IO_TYPE_FILE )
  188. #define ASSERT_OPTIONAL_FILE_OBJECT(FO) ASSERT_OPTIONAL_STRUCT( (FO), IO_TYPE_FILE )
  189. #define ASSERT_EXCLUSIVE_RESOURCE(R) ASSERT( ExIsResourceAcquiredExclusiveLite( R ))
  190. #define ASSERT_SHARED_RESOURCE(R) ASSERT( ExIsResourceAcquiredSharedLite( R ))
  191. #define ASSERT_RESOURCE_NOT_MINE(R) ASSERT( !ExIsResourceAcquiredSharedLite( R ))
  192. #define ASSERT_EXCLUSIVE_CDDATA ASSERT( ExIsResourceAcquiredExclusiveLite( &CdData.DataResource ))
  193. #define ASSERT_EXCLUSIVE_VCB(V) ASSERT( ExIsResourceAcquiredExclusiveLite( &(V)->VcbResource ))
  194. #define ASSERT_SHARED_VCB(V) ASSERT( ExIsResourceAcquiredSharedLite( &(V)->VcbResource ))
  195. #define ASSERT_EXCLUSIVE_FCB(F) ASSERT( ExIsResourceAcquiredExclusiveLite( &(F)->FcbNonpaged->FcbResource ))
  196. #define ASSERT_SHARED_FCB(F) ASSERT( ExIsResourceAcquiredSharedLite( &(F)->FcbNonpaged->FcbResource ))
  197. #define ASSERT_EXCLUSIVE_FILE(F) ASSERT( ExIsResourceAcquiredExclusiveLite( (F)->Resource ))
  198. #define ASSERT_SHARED_FILE(F) ASSERT( ExIsResourceAcquiredSharedLite( (F)->Resource ))
  199. #define ASSERT_LOCKED_VCB(V) ASSERT( (V)->VcbLockThread == PsGetCurrentThread() )
  200. #define ASSERT_NOT_LOCKED_VCB(V) ASSERT( (V)->VcbLockThread != PsGetCurrentThread() )
  201. #define ASSERT_LOCKED_FCB(F) ASSERT( !FlagOn( (F)->FcbState, FCB_STATE_IN_FCB_TABLE) || ((F)->FcbLockThread == PsGetCurrentThread()))
  202. #define ASSERT_NOT_LOCKED_FCB(F) ASSERT( (F)->FcbLockThread != PsGetCurrentThread() )
  203. #else
  204. #define DebugBreakOnStatus(S) { NOTHING; }
  205. #define ASSERT_STRUCT(S,T) { NOTHING; }
  206. #define ASSERT_OPTIONAL_STRUCT(S,T) { NOTHING; }
  207. #define ASSERT_VCB(V) { NOTHING; }
  208. #define ASSERT_OPTIONAL_VCB(V) { NOTHING; }
  209. #define ASSERT_FCB(F) { NOTHING; }
  210. #define ASSERT_OPTIONAL_FCB(F) { NOTHING; }
  211. #define ASSERT_FCB_NONPAGED(FN) { NOTHING; }
  212. #define ASSERT_OPTIONAL_FCB(FN) { NOTHING; }
  213. #define ASSERT_CCB(C) { NOTHING; }
  214. #define ASSERT_OPTIONAL_CCB(C) { NOTHING; }
  215. #define ASSERT_IRP_CONTEXT(IC) { NOTHING; }
  216. #define ASSERT_OPTIONAL_IRP_CONTEXT(IC) { NOTHING; }
  217. #define ASSERT_IRP(I) { NOTHING; }
  218. #define ASSERT_OPTIONAL_IRP(I) { NOTHING; }
  219. #define ASSERT_FILE_OBJECT(FO) { NOTHING; }
  220. #define ASSERT_OPTIONAL_FILE_OBJECT(FO) { NOTHING; }
  221. #define ASSERT_EXCLUSIVE_RESOURCE(R) { NOTHING; }
  222. #define ASSERT_SHARED_RESOURCE(R) { NOTHING; }
  223. #define ASSERT_RESOURCE_NOT_MINE(R) { NOTHING; }
  224. #define ASSERT_EXCLUSIVE_CDDATA { NOTHING; }
  225. #define ASSERT_EXCLUSIVE_VCB(V) { NOTHING; }
  226. #define ASSERT_SHARED_VCB(V) { NOTHING; }
  227. #define ASSERT_EXCLUSIVE_FCB(F) { NOTHING; }
  228. #define ASSERT_SHARED_FCB(F) { NOTHING; }
  229. #define ASSERT_EXCLUSIVE_FILE(F) { NOTHING; }
  230. #define ASSERT_SHARED_FILE(F) { NOTHING; }
  231. #define ASSERT_LOCKED_VCB(V) { NOTHING; }
  232. #define ASSERT_NOT_LOCKED_VCB(V) { NOTHING; }
  233. #define ASSERT_LOCKED_FCB(F) { NOTHING; }
  234. #define ASSERT_NOT_LOCKED_FCB(F) { NOTHING; }
  235. #endif
  236. #endif // _CDDATA_