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.

391 lines
15 KiB

  1. /*++
  2. Copyright (c) 1989-2000 Microsoft Corporation
  3. Module Name:
  4. UdfData.h
  5. Abstract:
  6. This module declares the global data used by the Udfs file system.
  7. // @@BEGIN_DDKSPLIT
  8. Author:
  9. Dan Lovinger [DanLo] 20-May-1996
  10. Revision History:
  11. Tom Jolly [TomJolly] 1-March-2000 UDF 2.01 support
  12. // @@END_DDKSPLIT
  13. --*/
  14. #ifndef _UDFDATA_
  15. #define _UDFDATA_
  16. //
  17. // Global data structures
  18. //
  19. extern UDF_DATA UdfData;
  20. extern FAST_IO_DISPATCH UdfFastIoDispatch;
  21. //
  22. // Global constants
  23. //
  24. //
  25. // These are the number of times a mounted Vcb will be referenced on behalf
  26. // of the system. The counts include the following references.
  27. //
  28. // 1 reference - shows the volume is mounted
  29. // 1 reference - 1 for VolumeDasdFcb.
  30. // 2 references - 1 for RootIndexFcb, 1 for internal stream.
  31. // 2 references - 1 for MetadataFcb, 1 for internal stream.
  32. //
  33. // AND THEN, IF THIS IS CD-UDF
  34. //
  35. // 2 references - 1 for the VatFcb, 1 for the internal stream.
  36. //
  37. // For user references we add one for the reference in each of the internal
  38. // Fcbs.
  39. //
  40. #define UDFS_BASE_RESIDUAL_REFERENCE (6)
  41. #define UDFS_BASE_RESIDUAL_USER_REFERENCE (3)
  42. #define UDFS_CDUDF_RESIDUAL_REFERENCE (2)
  43. #define UDFS_CDUDF_RESIDUAL_USER_REFERENCE (1)
  44. //
  45. // The UDFS signature for thread contexts
  46. //
  47. #define UDFS_SIGNATURE 0x53464455
  48. //
  49. // Reserved directory strings
  50. //
  51. #define SELF_ENTRY 0
  52. #define PARENT_ENTRY 1
  53. extern WCHAR UdfUnicodeSelfArray[];
  54. extern WCHAR UdfUnicodeParentArray[];
  55. extern LARGE_INTEGER UdfCorruptFileTime;
  56. extern UNICODE_STRING UdfUnicodeDirectoryNames[];
  57. //
  58. // Static Identifier strings
  59. //
  60. extern STRING UdfCS0Identifier;
  61. extern STRING UdfDomainIdentifier;
  62. extern STRING UdfVirtualPartitionDomainIdentifier;
  63. extern STRING UdfVatTableIdentifier;
  64. extern STRING UdfSparablePartitionDomainIdentifier;
  65. extern STRING UdfSparingTableIdentifier;
  66. extern STRING UdfNSR02Identifier;
  67. extern STRING UdfNSR03Identifier;
  68. //
  69. // Lookup tables for rudimentary parsing of strings we will
  70. // discover in on-disk structures
  71. //
  72. extern PARSE_KEYVALUE VsdIdentParseTable[];
  73. extern PARSE_KEYVALUE NsrPartContIdParseTable[];
  74. //
  75. // Lookaside lists
  76. //
  77. extern NPAGED_LOOKASIDE_LIST UdfFcbNonPagedLookasideList;
  78. extern NPAGED_LOOKASIDE_LIST UdfIrpContextLookasideList;
  79. extern PAGED_LOOKASIDE_LIST UdfCcbLookasideList;
  80. extern PAGED_LOOKASIDE_LIST UdfFcbIndexLookasideList;
  81. extern PAGED_LOOKASIDE_LIST UdfFcbDataLookasideList;
  82. extern PAGED_LOOKASIDE_LIST UdfLcbLookasideList;
  83. //
  84. // 16bit CRC table
  85. //
  86. extern PUSHORT UdfCrcTable;
  87. //
  88. // Turn on pseudo-asserts if UDFS_FREE_ASSERTS is defined.
  89. //
  90. #if (!DBG && defined( UDFS_FREE_ASSERTS )) || defined( UDFSDBG )
  91. #undef ASSERT
  92. #undef ASSERTMSG
  93. #define ASSERT(exp) \
  94. ((exp) ? TRUE : \
  95. (DbgPrint( "%s:%d %s\n",__FILE__,__LINE__,#exp ), \
  96. DbgBreakPoint(), \
  97. TRUE))
  98. #define ASSERTMSG(msg,exp) \
  99. ((exp) ? TRUE : \
  100. (DbgPrint( "%s:%d %s %s\n",__FILE__,__LINE__,msg,#exp ), \
  101. DbgBreakPoint(), \
  102. TRUE))
  103. #endif
  104. //
  105. // McDebugging Stuff
  106. //
  107. //
  108. // The following assertion macros ensure that the indicated structure
  109. // is valid
  110. //
  111. // ASSERT_STRUCT( IN PVOID Struct, IN CSHORT NodeType );
  112. // ASSERT_OPTIONAL_STRUCT( IN PVOID Struct OPTIONAL, IN CSHORT NodeType );
  113. //
  114. // ASSERT_VCB( IN PVCB Vcb );
  115. // ASSERT_OPTIONAL_VCB( IN PVCB Vcb OPTIONAL );
  116. //
  117. // ASSERT_FCB( IN PFCB Fcb );
  118. // ASSERT_OPTIONAL_FCB( IN PFCB Fcb OPTIONAL );
  119. //
  120. // ASSERT_LCB( IN PLCB Lcb );
  121. // ASSERT_OPTIONAL_LCB( IN PLCB Lcb OPTIONAL );
  122. //
  123. // ASSERT_PCB( IN PFCB Pcb );
  124. // ASSERT_OPTIONAL_PCB( IN PPCB Pcb OPTIONAL );
  125. //
  126. // ASSERT_FCB_NONPAGED( IN PFCB_NONPAGED FcbNonpaged );
  127. // ASSERT_OPTIONAL_FCB( IN PFCB_NONPAGED FcbNonpaged OPTIONAL );
  128. //
  129. // ASSERT_CCB( IN PSCB Ccb );
  130. // ASSERT_OPTIONAL_CCB( IN PSCB Ccb OPTIONAL );
  131. //
  132. // ASSERT_IRP_CONTEXT( IN PIRP_CONTEXT IrpContext );
  133. // ASSERT_OPTIONAL_IRP_CONTEXT( IN PIRP_CONTEXT IrpContext OPTIONAL );
  134. //
  135. // ASSERT_IRP( IN PIRP Irp );
  136. // ASSERT_OPTIONAL_IRP( IN PIRP Irp OPTIONAL );
  137. //
  138. // ASSERT_FILE_OBJECT( IN PFILE_OBJECT FileObject );
  139. // ASSERT_OPTIONAL_FILE_OBJECT( IN PFILE_OBJECT FileObject OPTIONAL );
  140. //
  141. // The following macros are used to check the current thread owns
  142. // the indicated resource
  143. //
  144. // ASSERT_EXCLUSIVE_RESOURCE( IN PERESOURCE Resource );
  145. //
  146. // ASSERT_SHARED_RESOURCE( IN PERESOURCE Resource );
  147. //
  148. // ASSERT_RESOURCE_NOT_MINE( IN PERESOURCE Resource );
  149. //
  150. // The following macros are used to check whether the current thread
  151. // owns the resoures in the given structures.
  152. //
  153. // ASSERT_EXCLUSIVE_CDDATA
  154. //
  155. // ASSERT_EXCLUSIVE_VCB( IN PVCB Vcb );
  156. //
  157. // ASSERT_SHARED_VCB( IN PVCB Vcb );
  158. //
  159. // ASSERT_EXCLUSIVE_FCB( IN PFCB Fcb );
  160. //
  161. // ASSERT_SHARED_FCB( IN PFCB Fcb );
  162. //
  163. // ASSERT_EXCLUSIVE_FILE( IN PFCB Fcb );
  164. //
  165. // ASSERT_SHARED_FILE( IN PFCB Fcb );
  166. //
  167. // ASSERT_LOCKED_VCB( IN PVCB Vcb );
  168. //
  169. // ASSERT_NOT_LOCKED_VCB( IN PVCB Vcb );
  170. //
  171. // ASSERT_LOCKED_FCB( IN PFCB Fcb );
  172. //
  173. // ASSERT_NOT_LOCKED_FCB( IN PFCB Fcb );
  174. //
  175. //
  176. // Turn on the sanity checks if this is DBG or UDF_FREE_ASSERTS
  177. //
  178. #if DBG || UDF_FREE_ASSERTS
  179. #undef UDF_SANITY
  180. #define UDF_SANITY
  181. #endif
  182. #ifdef UDF_SANITY
  183. extern LONG UdfDebugTraceLevel;
  184. extern LONG UdfDebugTraceIndent;
  185. extern BOOLEAN UdfNoisyVerifyDescriptor;
  186. extern BOOLEAN UdfTestRaisedStatus;
  187. BOOLEAN
  188. UdfDebugTrace (
  189. LONG IndentIncrement,
  190. ULONG TraceMask,
  191. PCHAR Format,
  192. ...
  193. );
  194. #define DebugTrace(x) UdfDebugTrace x
  195. #define DebugUnwind(X) { \
  196. if (AbnormalTermination()) { \
  197. DebugTrace(( -1, UDFS_DEBUG_LEVEL_UNWIND, #X ", Abnormal termination.\n" )); \
  198. } \
  199. }
  200. #define DebugBreakOnStatus(S) { \
  201. if (UdfTestRaisedStatus) { \
  202. if ((S) == STATUS_DISK_CORRUPT_ERROR || \
  203. (S) == STATUS_FILE_CORRUPT_ERROR || \
  204. (S) == STATUS_CRC_ERROR) { \
  205. DbgPrint( "UDFS: Breaking on possible media corruption (S = %08x)\n", (S)); \
  206. DbgPrint( "UDFS: Contact UDFS.SYS component owner for triage.\n"); \
  207. DbgPrint( "UDFS: 'eb %p 0' to disable this alert\n",&UdfTestRaisedStatus ); \
  208. DbgBreakPoint(); \
  209. } \
  210. } \
  211. }
  212. #define ASSERT_STRUCT(S,T) ASSERT( SafeNodeType( S ) == (T) )
  213. #define ASSERT_OPTIONAL_STRUCT(S,T) ASSERT( ((S) == NULL) || (SafeNodeType( S ) == (T)) )
  214. #define ASSERT_VCB(V) ASSERT_STRUCT( (V), UDFS_NTC_VCB )
  215. #define ASSERT_OPTIONAL_VCB(V) ASSERT_OPTIONAL_STRUCT( (V), UDFS_NTC_VCB )
  216. #define ASSERT_FCB(F) \
  217. ASSERT( (SafeNodeType( F ) == UDFS_NTC_FCB_DATA ) || \
  218. (SafeNodeType( F ) == UDFS_NTC_FCB_INDEX ) )
  219. #define ASSERT_OPTIONAL_FCB(F) \
  220. ASSERT( ((F) == NULL) || \
  221. (SafeNodeType( F ) == UDFS_NTC_FCB_DATA ) || \
  222. (SafeNodeType( F ) == UDFS_NTC_FCB_INDEX ) )
  223. #define ASSERT_FCB_DATA(F) ASSERT( (SafeNodeType( F ) == UDFS_NTC_FCB_DATA ) )
  224. #define ASSERT_OPTIONAL_FCB_DATA(F) \
  225. ASSERT( ((F) == NULL) || \
  226. (SafeNodeType( F ) == UDFS_NTC_FCB_DATA ) )
  227. #define ASSERT_FCB_INDEX(F) ASSERT( (SafeNodeType( F ) == UDFS_NTC_FCB_INDEX ) )
  228. #define ASSERT_OPTIONAL_FCB_INDEX(F) \
  229. ASSERT( ((F) == NULL) || \
  230. (SafeNodeType( F ) == UDFS_NTC_FCB_INDEX ) )
  231. #define ASSERT_FCB_NONPAGED(FN) ASSERT_STRUCT( (FN), UDFS_NTC_FCB_NONPAGED )
  232. #define ASSERT_OPTIONAL_FCB_NONPAGED(FN) ASSERT_OPTIONAL_STRUCT( (FN), UDFS_NTC_FCB_NONPAGED )
  233. #define ASSERT_CCB(C) ASSERT_STRUCT( (C), UDFS_NTC_CCB )
  234. #define ASSERT_OPTIONAL_CCB(C) ASSERT_OPTIONAL_STRUCT( (C), UDFS_NTC_CCB )
  235. #define ASSERT_PCB(C) ASSERT_STRUCT( (C), UDFS_NTC_PCB )
  236. #define ASSERT_OPTIONAL_PCB(C) ASSERT_OPTIONAL_STRUCT( (C), UDFS_NTC_PCB )
  237. #define ASSERT_LCB(C) ASSERT_STRUCT( (C), UDFS_NTC_LCB )
  238. #define ASSERT_OPTIONAL_LCB(C) ASSERT_OPTIONAL_STRUCT( (C), UDFS_NTC_LCB )
  239. #define ASSERT_IRP_CONTEXT(IC) ASSERT_STRUCT( (IC), UDFS_NTC_IRP_CONTEXT )
  240. #define ASSERT_OPTIONAL_IRP_CONTEXT(IC) ASSERT_OPTIONAL_STRUCT( (IC), UDFS_NTC_IRP_CONTEXT )
  241. #define ASSERT_IRP_CONTEXT_LITE(IC) ASSERT_STRUCT( (IC), UDFS_NTC_IRP_CONTEXT_LITE )
  242. #define ASSERT_OPTIONAL_IRP_CONTEXT_LITE(IC) ASSERT_OPTIONAL_STRUCT( (IC), UDFS_NTC_IRP_CONTEXT_LITE )
  243. #define ASSERT_IRP(I) ASSERT_STRUCT( (I), IO_TYPE_IRP )
  244. #define ASSERT_OPTIONAL_IRP(I) ASSERT_OPTIONAL_STRUCT( (I), IO_TYPE_IRP )
  245. #define ASSERT_FILE_OBJECT(FO) ASSERT_STRUCT( (FO), IO_TYPE_FILE )
  246. #define ASSERT_OPTIONAL_FILE_OBJECT(FO) ASSERT_OPTIONAL_STRUCT( (FO), IO_TYPE_FILE )
  247. #define ASSERT_EXCLUSIVE_RESOURCE(R) ASSERT( ExIsResourceAcquiredExclusiveLite( R ))
  248. #define ASSERT_SHARED_RESOURCE(R) ASSERT( ExIsResourceAcquiredSharedLite( R ))
  249. #define ASSERT_RESOURCE_NOT_MINE(R) ASSERT( !ExIsResourceAcquiredSharedLite( R ))
  250. #define ASSERT_EXCLUSIVE_UDFDATA ASSERT( ExIsResourceAcquiredExclusiveLite( &UdfData.DataResource ))
  251. #define ASSERT_EXCLUSIVE_VCB(V) ASSERT( ExIsResourceAcquiredExclusiveLite( &(V)->VcbResource ))
  252. #define ASSERT_SHARED_VCB(V) ASSERT( ExIsResourceAcquiredSharedLite( &(V)->VcbResource ))
  253. #define ASSERT_EXCLUSIVE_FCB_OR_VCB(F) ASSERT( ExIsResourceAcquiredExclusiveLite( &(F)->FcbNonpaged->FcbResource ) || \
  254. ExIsResourceAcquiredExclusiveLite( &(F)->Vcb->VcbResource ))
  255. #define ASSERT_EXCLUSIVE_FCB(F) ASSERT( ExIsResourceAcquiredExclusiveLite( &(F)->FcbNonpaged->FcbResource ))
  256. #define ASSERT_SHARED_FCB(F) ASSERT( ExIsResourceAcquiredSharedLite( &(F)->FcbNonpaged->FcbResource ))
  257. #define ASSERT_EXCLUSIVE_FILE(F) ASSERT( ExIsResourceAcquiredExclusiveLite( (F)->Resource ))
  258. #define ASSERT_SHARED_FILE(F) ASSERT( ExIsResourceAcquiredSharedLite( (F)->Resource ))
  259. #define ASSERT_LOCKED_VCB(V) ASSERT( (V)->VcbLockThread == PsGetCurrentThread() )
  260. #define ASSERT_NOT_LOCKED_VCB(V) ASSERT( (V)->VcbLockThread != PsGetCurrentThread() )
  261. #define ASSERT_LOCKED_FCB(F) ASSERT( (F)->FcbLockThread == PsGetCurrentThread() )
  262. #define ASSERT_NOT_LOCKED_FCB(F) ASSERT( (F)->FcbLockThread != PsGetCurrentThread() )
  263. #define ASSERT_NOT_HELD_VMCB(V) ASSERT( !ExIsResourceAcquiredSharedLite(&(V)->VmcbMappingResource) && \
  264. !ExIsResourceAcquiredExclusiveLite(&(V)->VmcbMappingResource) )
  265. #else
  266. #define DebugTrace(X) TRUE
  267. #define DebugUnwind(X) { NOTHING; }
  268. #define DebugBreakOnStatus(S) { NOTHING; }
  269. #define ASSERT_NOT_HELD_VMCB(V) { NOTHING; }
  270. #define ASSERT_STRUCT(S,T) { NOTHING; }
  271. #define ASSERT_OPTIONAL_STRUCT(S,T) { NOTHING; }
  272. #define ASSERT_VCB(V) { NOTHING; }
  273. #define ASSERT_OPTIONAL_VCB(V) { NOTHING; }
  274. #define ASSERT_FCB(F) { NOTHING; }
  275. #define ASSERT_OPTIONAL_FCB(F) { NOTHING; }
  276. #define ASSERT_FCB_DATA { NOTHING; }
  277. #define ASSERT_OPTIONAL_FCB_DATA(F) { NOTHING; }
  278. #define ASSERT_FCB_INDEX(F) { NOTHING; }
  279. #define ASSERT_OPTIONAL_FCB_INDEX(F) { NOTHING; }
  280. #define ASSERT_FCB_NONPAGED(FN) { NOTHING; }
  281. #define ASSERT_OPTIONAL_FCB_NONPAGED(FN) { NOTHING; }
  282. #define ASSERT_CCB(C) { NOTHING; }
  283. #define ASSERT_OPTIONAL_CCB(C) { NOTHING; }
  284. #define ASSERT_PCB(C) { NOTHING; }
  285. #define ASSERT_OPTIONAL_PCB(C) { NOTHING; }
  286. #define ASSERT_LCB(C) { NOTHING; }
  287. #define ASSERT_OPTIONAL_LCB(C) { NOTHING; }
  288. #define ASSERT_IRP_CONTEXT(IC) { NOTHING; }
  289. #define ASSERT_OPTIONAL_IRP_CONTEXT(IC) { NOTHING; }
  290. #define ASSERT_IRP_CONTEXT_LITE(IC) { NOTHING; }
  291. #define ASSERT_OPTIONAL_IRP_CONTEXT_LITE(IC) { NOTHING; }
  292. #define ASSERT_IRP(I) { NOTHING; }
  293. #define ASSERT_OPTIONAL_IRP(I) { NOTHING; }
  294. #define ASSERT_FILE_OBJECT(FO) { NOTHING; }
  295. #define ASSERT_OPTIONAL_FILE_OBJECT(FO) { NOTHING; }
  296. #define ASSERT_EXCLUSIVE_RESOURCE(R) { NOTHING; }
  297. #define ASSERT_SHARED_RESOURCE(R) { NOTHING; }
  298. #define ASSERT_RESOURCE_NOT_MINE(R) { NOTHING; }
  299. #define ASSERT_EXCLUSIVE_UDFDATA { NOTHING; }
  300. #define ASSERT_EXCLUSIVE_VCB(V) { NOTHING; }
  301. #define ASSERT_SHARED_VCB(V) { NOTHING; }
  302. #define ASSERT_EXCLUSIVE_FCB_OR_VCB(F) { NOTHING; }
  303. #define ASSERT_EXCLUSIVE_FCB(F) { NOTHING; }
  304. #define ASSERT_SHARED_FCB(F) { NOTHING; }
  305. #define ASSERT_EXCLUSIVE_FILE(F) { NOTHING; }
  306. #define ASSERT_SHARED_FILE(F) { NOTHING; }
  307. #define ASSERT_LOCKED_VCB(V) { NOTHING; }
  308. #define ASSERT_NOT_LOCKED_VCB(V) { NOTHING; }
  309. #define ASSERT_LOCKED_FCB(F) { NOTHING; }
  310. #define ASSERT_NOT_LOCKED_FCB(F) { NOTHING; }
  311. #endif
  312. #endif // _UDFDATA_