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.

382 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. #ifdef UDF_SANITY
  176. extern LONG UdfDebugTraceLevel;
  177. extern LONG UdfDebugTraceIndent;
  178. extern BOOLEAN UdfNoisyVerifyDescriptor;
  179. extern BOOLEAN UdfTestRaisedStatus;
  180. BOOLEAN
  181. UdfDebugTrace (
  182. LONG IndentIncrement,
  183. ULONG TraceMask,
  184. PCHAR Format,
  185. ...
  186. );
  187. #define DebugTrace(x) UdfDebugTrace x
  188. #define DebugUnwind(X) { \
  189. if (AbnormalTermination()) { \
  190. DebugTrace(( -1, UDFS_DEBUG_LEVEL_UNWIND, #X ", Abnormal termination.\n" )); \
  191. } \
  192. }
  193. #define DebugBreakOnStatus(S) { \
  194. if (UdfTestRaisedStatus) { \
  195. if ((S) == STATUS_DISK_CORRUPT_ERROR || \
  196. (S) == STATUS_FILE_CORRUPT_ERROR || \
  197. (S) == STATUS_CRC_ERROR) { \
  198. DbgPrint( "UDFS: Breaking on possible media corruption (S = %08x)\n", (S)); \
  199. DbgPrint( "UDFS: Contact UDFS.SYS component owner for triage.\n"); \
  200. DbgPrint( "UDFS: 'eb %p 0' to disable this alert\n",&UdfTestRaisedStatus ); \
  201. DbgBreakPoint(); \
  202. } \
  203. } \
  204. }
  205. #define ASSERT_STRUCT(S,T) ASSERT( SafeNodeType( S ) == (T) )
  206. #define ASSERT_OPTIONAL_STRUCT(S,T) ASSERT( ((S) == NULL) || (SafeNodeType( S ) == (T)) )
  207. #define ASSERT_VCB(V) ASSERT_STRUCT( (V), UDFS_NTC_VCB )
  208. #define ASSERT_OPTIONAL_VCB(V) ASSERT_OPTIONAL_STRUCT( (V), UDFS_NTC_VCB )
  209. #define ASSERT_FCB(F) \
  210. ASSERT( (SafeNodeType( F ) == UDFS_NTC_FCB_DATA ) || \
  211. (SafeNodeType( F ) == UDFS_NTC_FCB_INDEX ) )
  212. #define ASSERT_OPTIONAL_FCB(F) \
  213. ASSERT( ((F) == NULL) || \
  214. (SafeNodeType( F ) == UDFS_NTC_FCB_DATA ) || \
  215. (SafeNodeType( F ) == UDFS_NTC_FCB_INDEX ) )
  216. #define ASSERT_FCB_DATA(F) ASSERT( (SafeNodeType( F ) == UDFS_NTC_FCB_DATA ) )
  217. #define ASSERT_OPTIONAL_FCB_DATA(F) \
  218. ASSERT( ((F) == NULL) || \
  219. (SafeNodeType( F ) == UDFS_NTC_FCB_DATA ) )
  220. #define ASSERT_FCB_INDEX(F) ASSERT( (SafeNodeType( F ) == UDFS_NTC_FCB_INDEX ) )
  221. #define ASSERT_OPTIONAL_FCB_INDEX(F) \
  222. ASSERT( ((F) == NULL) || \
  223. (SafeNodeType( F ) == UDFS_NTC_FCB_INDEX ) )
  224. #define ASSERT_FCB_NONPAGED(FN) ASSERT_STRUCT( (FN), UDFS_NTC_FCB_NONPAGED )
  225. #define ASSERT_OPTIONAL_FCB_NONPAGED(FN) ASSERT_OPTIONAL_STRUCT( (FN), UDFS_NTC_FCB_NONPAGED )
  226. #define ASSERT_CCB(C) ASSERT_STRUCT( (C), UDFS_NTC_CCB )
  227. #define ASSERT_OPTIONAL_CCB(C) ASSERT_OPTIONAL_STRUCT( (C), UDFS_NTC_CCB )
  228. #define ASSERT_PCB(C) ASSERT_STRUCT( (C), UDFS_NTC_PCB )
  229. #define ASSERT_OPTIONAL_PCB(C) ASSERT_OPTIONAL_STRUCT( (C), UDFS_NTC_PCB )
  230. #define ASSERT_LCB(C) ASSERT_STRUCT( (C), UDFS_NTC_LCB )
  231. #define ASSERT_OPTIONAL_LCB(C) ASSERT_OPTIONAL_STRUCT( (C), UDFS_NTC_LCB )
  232. #define ASSERT_IRP_CONTEXT(IC) ASSERT_STRUCT( (IC), UDFS_NTC_IRP_CONTEXT )
  233. #define ASSERT_OPTIONAL_IRP_CONTEXT(IC) ASSERT_OPTIONAL_STRUCT( (IC), UDFS_NTC_IRP_CONTEXT )
  234. #define ASSERT_IRP_CONTEXT_LITE(IC) ASSERT_STRUCT( (IC), UDFS_NTC_IRP_CONTEXT_LITE )
  235. #define ASSERT_OPTIONAL_IRP_CONTEXT_LITE(IC) ASSERT_OPTIONAL_STRUCT( (IC), UDFS_NTC_IRP_CONTEXT_LITE )
  236. #define ASSERT_IRP(I) ASSERT_STRUCT( (I), IO_TYPE_IRP )
  237. #define ASSERT_OPTIONAL_IRP(I) ASSERT_OPTIONAL_STRUCT( (I), IO_TYPE_IRP )
  238. #define ASSERT_FILE_OBJECT(FO) ASSERT_STRUCT( (FO), IO_TYPE_FILE )
  239. #define ASSERT_OPTIONAL_FILE_OBJECT(FO) ASSERT_OPTIONAL_STRUCT( (FO), IO_TYPE_FILE )
  240. #define ASSERT_EXCLUSIVE_RESOURCE(R) ASSERT( ExIsResourceAcquiredExclusiveLite( R ))
  241. #define ASSERT_SHARED_RESOURCE(R) ASSERT( ExIsResourceAcquiredSharedLite( R ))
  242. #define ASSERT_RESOURCE_NOT_MINE(R) ASSERT( !ExIsResourceAcquiredSharedLite( R ))
  243. #define ASSERT_EXCLUSIVE_UDFDATA ASSERT( ExIsResourceAcquiredExclusiveLite( &UdfData.DataResource ))
  244. #define ASSERT_EXCLUSIVE_VCB(V) ASSERT( ExIsResourceAcquiredExclusiveLite( &(V)->VcbResource ))
  245. #define ASSERT_SHARED_VCB(V) ASSERT( ExIsResourceAcquiredSharedLite( &(V)->VcbResource ))
  246. #define ASSERT_EXCLUSIVE_FCB_OR_VCB(F) ASSERT( ExIsResourceAcquiredExclusiveLite( &(F)->FcbNonpaged->FcbResource ) || \
  247. ExIsResourceAcquiredExclusiveLite( &(F)->Vcb->VcbResource ))
  248. #define ASSERT_EXCLUSIVE_FCB(F) ASSERT( ExIsResourceAcquiredExclusiveLite( &(F)->FcbNonpaged->FcbResource ))
  249. #define ASSERT_SHARED_FCB(F) ASSERT( ExIsResourceAcquiredSharedLite( &(F)->FcbNonpaged->FcbResource ))
  250. #define ASSERT_EXCLUSIVE_FILE(F) ASSERT( ExIsResourceAcquiredExclusiveLite( (F)->Resource ))
  251. #define ASSERT_SHARED_FILE(F) ASSERT( ExIsResourceAcquiredSharedLite( (F)->Resource ))
  252. #define ASSERT_LOCKED_VCB(V) ASSERT( (V)->VcbLockThread == PsGetCurrentThread() )
  253. #define ASSERT_NOT_LOCKED_VCB(V) ASSERT( (V)->VcbLockThread != PsGetCurrentThread() )
  254. #define ASSERT_LOCKED_FCB(F) ASSERT( (F)->FcbLockThread == PsGetCurrentThread() )
  255. #define ASSERT_NOT_LOCKED_FCB(F) ASSERT( (F)->FcbLockThread != PsGetCurrentThread() )
  256. #define ASSERT_NOT_HELD_VMCB(V) ASSERT( !ExIsResourceAcquiredSharedLite(&(V)->VmcbMappingResource) && \
  257. !ExIsResourceAcquiredExclusiveLite(&(V)->VmcbMappingResource) )
  258. #else
  259. #define DebugTrace(X) TRUE
  260. #define DebugUnwind(X) { NOTHING; }
  261. #define DebugBreakOnStatus(S) { NOTHING; }
  262. #define ASSERT_NOT_HELD_VMCB(V) { NOTHING; }
  263. #define ASSERT_STRUCT(S,T) { NOTHING; }
  264. #define ASSERT_OPTIONAL_STRUCT(S,T) { NOTHING; }
  265. #define ASSERT_VCB(V) { NOTHING; }
  266. #define ASSERT_OPTIONAL_VCB(V) { NOTHING; }
  267. #define ASSERT_FCB(F) { NOTHING; }
  268. #define ASSERT_OPTIONAL_FCB(F) { NOTHING; }
  269. #define ASSERT_FCB_DATA { NOTHING; }
  270. #define ASSERT_OPTIONAL_FCB_DATA(F) { NOTHING; }
  271. #define ASSERT_FCB_INDEX(F) { NOTHING; }
  272. #define ASSERT_OPTIONAL_FCB_INDEX(F) { NOTHING; }
  273. #define ASSERT_FCB_NONPAGED(FN) { NOTHING; }
  274. #define ASSERT_OPTIONAL_FCB_NONPAGED(FN) { NOTHING; }
  275. #define ASSERT_CCB(C) { NOTHING; }
  276. #define ASSERT_OPTIONAL_CCB(C) { NOTHING; }
  277. #define ASSERT_PCB(C) { NOTHING; }
  278. #define ASSERT_OPTIONAL_PCB(C) { NOTHING; }
  279. #define ASSERT_LCB(C) { NOTHING; }
  280. #define ASSERT_OPTIONAL_LCB(C) { NOTHING; }
  281. #define ASSERT_IRP_CONTEXT(IC) { NOTHING; }
  282. #define ASSERT_OPTIONAL_IRP_CONTEXT(IC) { NOTHING; }
  283. #define ASSERT_IRP_CONTEXT_LITE(IC) { NOTHING; }
  284. #define ASSERT_OPTIONAL_IRP_CONTEXT_LITE(IC) { NOTHING; }
  285. #define ASSERT_IRP(I) { NOTHING; }
  286. #define ASSERT_OPTIONAL_IRP(I) { NOTHING; }
  287. #define ASSERT_FILE_OBJECT(FO) { NOTHING; }
  288. #define ASSERT_OPTIONAL_FILE_OBJECT(FO) { NOTHING; }
  289. #define ASSERT_EXCLUSIVE_RESOURCE(R) { NOTHING; }
  290. #define ASSERT_SHARED_RESOURCE(R) { NOTHING; }
  291. #define ASSERT_RESOURCE_NOT_MINE(R) { NOTHING; }
  292. #define ASSERT_EXCLUSIVE_UDFDATA { NOTHING; }
  293. #define ASSERT_EXCLUSIVE_VCB(V) { NOTHING; }
  294. #define ASSERT_SHARED_VCB(V) { NOTHING; }
  295. #define ASSERT_EXCLUSIVE_FCB_OR_VCB(F) { NOTHING; }
  296. #define ASSERT_EXCLUSIVE_FCB(F) { NOTHING; }
  297. #define ASSERT_SHARED_FCB(F) { NOTHING; }
  298. #define ASSERT_EXCLUSIVE_FILE(F) { NOTHING; }
  299. #define ASSERT_SHARED_FILE(F) { NOTHING; }
  300. #define ASSERT_LOCKED_VCB(V) { NOTHING; }
  301. #define ASSERT_NOT_LOCKED_VCB(V) { NOTHING; }
  302. #define ASSERT_LOCKED_FCB(F) { NOTHING; }
  303. #define ASSERT_NOT_LOCKED_FCB(F) { NOTHING; }
  304. #endif
  305. #endif // _UDFDATA_