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.

389 lines
9.7 KiB

  1. /*++
  2. Copyright (c) 1989-2000 Microsoft Corporation
  3. Module Name:
  4. DumpSup.c
  5. Abstract:
  6. This module implements a collection of data structure dump routines
  7. for debugging the Fat file system
  8. // @@BEGIN_DDKSPLIT
  9. Author:
  10. Gary Kimura [GaryKi] 18-Jan-1990
  11. Revision History:
  12. // @@END_DDKSPLIT
  13. --*/
  14. #include "FatProcs.h"
  15. #ifdef FASTFATDBG
  16. VOID FatDump(IN PVOID Ptr);
  17. VOID FatDumpDataHeader();
  18. VOID FatDumpVcb(IN PVCB Ptr);
  19. VOID FatDumpFcb(IN PFCB Ptr);
  20. VOID FatDumpCcb(IN PCCB Ptr);
  21. ULONG FatDumpCurrentColumn;
  22. #define DumpNewLine() { \
  23. DbgPrint("\n"); \
  24. FatDumpCurrentColumn = 1; \
  25. }
  26. #define DumpLabel(Label,Width) { \
  27. ULONG i, LastPeriod=0; \
  28. CHAR _Str[20]; \
  29. for(i=0;i<2;i++) { _Str[i] = UCHAR_SP;} \
  30. for(i=0;i<strlen(#Label);i++) {if (#Label[i] == '.') LastPeriod = i;} \
  31. strncpy(&_Str[2],&#Label[LastPeriod],Width); \
  32. for(i=strlen(_Str);i<Width;i++) {_Str[i] = UCHAR_SP;} \
  33. _Str[Width] = '\0'; \
  34. DbgPrint("%s", _Str); \
  35. }
  36. #define DumpField(Field) { \
  37. if ((FatDumpCurrentColumn + 18 + 9 + 9) > 80) {DumpNewLine();} \
  38. FatDumpCurrentColumn += 18 + 9 + 9; \
  39. DumpLabel(Field,18); \
  40. DbgPrint(":%8lx", Ptr->Field); \
  41. DbgPrint(" "); \
  42. }
  43. #define DumpListEntry(Links) { \
  44. if ((FatDumpCurrentColumn + 18 + 9 + 9) > 80) {DumpNewLine();} \
  45. FatDumpCurrentColumn += 18 + 9 + 9; \
  46. DumpLabel(Links,18); \
  47. DbgPrint(":%8lx", Ptr->Links.Flink); \
  48. DbgPrint(":%8lx", Ptr->Links.Blink); \
  49. }
  50. #define DumpName(Field,Width) { \
  51. ULONG i; \
  52. CHAR _String[256]; \
  53. if ((FatDumpCurrentColumn + 18 + Width) > 80) {DumpNewLine();} \
  54. FatDumpCurrentColumn += 18 + Width; \
  55. DumpLabel(Field,18); \
  56. for(i=0;i<Width;i++) {_String[i] = Ptr->Field[i];} \
  57. _String[Width] = '\0'; \
  58. DbgPrint("%s", _String); \
  59. }
  60. #define TestForNull(Name) { \
  61. if (Ptr == NULL) { \
  62. DbgPrint("%s - Cannot dump a NULL pointer\n", Name); \
  63. return; \
  64. } \
  65. }
  66. VOID
  67. FatDump (
  68. IN PVOID Ptr
  69. )
  70. /*++
  71. Routine Description:
  72. This routine determines the type of internal record reference by ptr and
  73. calls the appropriate dump routine.
  74. Arguments:
  75. Ptr - Supplies the pointer to the record to be dumped
  76. Return Value:
  77. None
  78. --*/
  79. {
  80. TestForNull("FatDump");
  81. switch (NodeType(Ptr)) {
  82. case FAT_NTC_DATA_HEADER:
  83. FatDumpDataHeader();
  84. break;
  85. case FAT_NTC_VCB:
  86. FatDumpVcb(Ptr);
  87. break;
  88. case FAT_NTC_FCB:
  89. case FAT_NTC_DCB:
  90. case FAT_NTC_ROOT_DCB:
  91. FatDumpFcb(Ptr);
  92. break;
  93. case FAT_NTC_CCB:
  94. FatDumpCcb(Ptr);
  95. break;
  96. default :
  97. DbgPrint("FatDump - Unknown Node type code %8lx\n", *((PNODE_TYPE_CODE)(Ptr)));
  98. break;
  99. }
  100. return;
  101. }
  102. VOID
  103. FatDumpDataHeader (
  104. )
  105. /*++
  106. Routine Description:
  107. Dump the top data structures and all Device structures
  108. Arguments:
  109. None
  110. Return Value:
  111. None
  112. --*/
  113. {
  114. PFAT_DATA Ptr;
  115. PLIST_ENTRY Links;
  116. Ptr = &FatData;
  117. TestForNull("FatDumpDataHeader");
  118. DumpNewLine();
  119. DbgPrint("FatData@ %lx", (Ptr));
  120. DumpNewLine();
  121. DumpField (NodeTypeCode);
  122. DumpField (NodeByteSize);
  123. DumpListEntry (VcbQueue);
  124. DumpField (DriverObject);
  125. DumpField (OurProcess);
  126. DumpNewLine();
  127. for (Links = Ptr->VcbQueue.Flink;
  128. Links != &Ptr->VcbQueue;
  129. Links = Links->Flink) {
  130. FatDumpVcb(CONTAINING_RECORD(Links, VCB, VcbLinks));
  131. }
  132. return;
  133. }
  134. VOID
  135. FatDumpVcb (
  136. IN PVCB Ptr
  137. )
  138. /*++
  139. Routine Description:
  140. Dump an Device structure, its Fcb queue amd direct access queue.
  141. Arguments:
  142. Ptr - Supplies the Device record to be dumped
  143. Return Value:
  144. None
  145. --*/
  146. {
  147. TestForNull("FatDumpVcb");
  148. DumpNewLine();
  149. DbgPrint("Vcb@ %lx", (Ptr));
  150. DumpNewLine();
  151. DumpField (VolumeFileHeader.NodeTypeCode);
  152. DumpField (VolumeFileHeader.NodeByteSize);
  153. DumpListEntry (VcbLinks);
  154. DumpField (TargetDeviceObject);
  155. DumpField (Vpb);
  156. DumpField (VcbState);
  157. DumpField (VcbCondition);
  158. DumpField (RootDcb);
  159. DumpField (DirectAccessOpenCount);
  160. DumpField (OpenFileCount);
  161. DumpField (ReadOnlyCount);
  162. DumpField (AllocationSupport);
  163. DumpField (AllocationSupport.RootDirectoryLbo);
  164. DumpField (AllocationSupport.RootDirectorySize);
  165. DumpField (AllocationSupport.FileAreaLbo);
  166. DumpField (AllocationSupport.NumberOfClusters);
  167. DumpField (AllocationSupport.NumberOfFreeClusters);
  168. DumpField (AllocationSupport.FatIndexBitSize);
  169. DumpField (AllocationSupport.LogOfBytesPerSector);
  170. DumpField (AllocationSupport.LogOfBytesPerCluster);
  171. DumpField (DirtyFatMcb);
  172. DumpField (FreeClusterBitMap);
  173. DumpField (VirtualVolumeFile);
  174. DumpField (SectionObjectPointers.DataSectionObject);
  175. DumpField (SectionObjectPointers.SharedCacheMap);
  176. DumpField (SectionObjectPointers.ImageSectionObject);
  177. DumpField (ClusterHint);
  178. DumpNewLine();
  179. FatDumpFcb(Ptr->RootDcb);
  180. return;
  181. }
  182. VOID
  183. FatDumpFcb (
  184. IN PFCB Ptr
  185. )
  186. /*++
  187. Routine Description:
  188. Dump an Fcb structure, its various queues
  189. Arguments:
  190. Ptr - Supplies the Fcb record to be dumped
  191. Return Value:
  192. None
  193. --*/
  194. {
  195. PLIST_ENTRY Links;
  196. TestForNull("FatDumpFcb");
  197. DumpNewLine();
  198. if (NodeType(&Ptr->Header) == FAT_NTC_FCB) {DbgPrint("Fcb@ %lx", (Ptr));}
  199. else if (NodeType(&Ptr->Header) == FAT_NTC_DCB) {DbgPrint("Dcb@ %lx", (Ptr));}
  200. else if (NodeType(&Ptr->Header) == FAT_NTC_ROOT_DCB) {DbgPrint("RootDcb@ %lx", (Ptr));}
  201. else {DbgPrint("NonFcb NodeType @ %lx", (Ptr));}
  202. DumpNewLine();
  203. DumpField (Header.NodeTypeCode);
  204. DumpField (Header.NodeByteSize);
  205. DumpListEntry (ParentDcbLinks);
  206. DumpField (ParentDcb);
  207. DumpField (Vcb);
  208. DumpField (FcbState);
  209. DumpField (FcbCondition);
  210. DumpField (UncleanCount);
  211. DumpField (OpenCount);
  212. DumpField (DirentOffsetWithinDirectory);
  213. DumpField (DirentFatFlags);
  214. DumpField (FullFileName.Length);
  215. DumpField (FullFileName.Buffer);
  216. DumpName (FullFileName.Buffer, 32);
  217. DumpField (ShortName.Name.Oem.Length);
  218. DumpField (ShortName.Name.Oem.Buffer);
  219. DumpField (NonPaged);
  220. DumpField (Header.AllocationSize.LowPart);
  221. DumpField (NonPaged->SectionObjectPointers.DataSectionObject);
  222. DumpField (NonPaged->SectionObjectPointers.SharedCacheMap);
  223. DumpField (NonPaged->SectionObjectPointers.ImageSectionObject);
  224. if ((Ptr->Header.NodeTypeCode == FAT_NTC_DCB) ||
  225. (Ptr->Header.NodeTypeCode == FAT_NTC_ROOT_DCB)) {
  226. DumpListEntry (Specific.Dcb.ParentDcbQueue);
  227. DumpField (Specific.Dcb.DirectoryFileOpenCount);
  228. DumpField (Specific.Dcb.DirectoryFile);
  229. } else if (Ptr->Header.NodeTypeCode == FAT_NTC_FCB) {
  230. DumpField (Header.FileSize.LowPart);
  231. } else {
  232. DumpNewLine();
  233. DbgPrint("Illegal Node type code");
  234. }
  235. DumpNewLine();
  236. if ((Ptr->Header.NodeTypeCode == FAT_NTC_DCB) ||
  237. (Ptr->Header.NodeTypeCode == FAT_NTC_ROOT_DCB)) {
  238. for (Links = Ptr->Specific.Dcb.ParentDcbQueue.Flink;
  239. Links != &Ptr->Specific.Dcb.ParentDcbQueue;
  240. Links = Links->Flink) {
  241. FatDumpFcb(CONTAINING_RECORD(Links, FCB, ParentDcbLinks));
  242. }
  243. }
  244. return;
  245. }
  246. VOID
  247. FatDumpCcb (
  248. IN PCCB Ptr
  249. )
  250. /*++
  251. Routine Description:
  252. Dump a Ccb structure
  253. Arguments:
  254. Ptr - Supplies the Ccb record to be dumped
  255. Return Value:
  256. None
  257. --*/
  258. {
  259. TestForNull("FatDumpCcb");
  260. DumpNewLine();
  261. DbgPrint("Ccb@ %lx", (Ptr));
  262. DumpNewLine();
  263. DumpField (NodeTypeCode);
  264. DumpField (NodeByteSize);
  265. DumpField (UnicodeQueryTemplate.Length);
  266. DumpName (UnicodeQueryTemplate.Buffer, 32);
  267. DumpField (OffsetToStartSearchFrom);
  268. DumpNewLine();
  269. return;
  270. }
  271. #endif // FASTFATDBG