3 Copyright (c) 1989-2000 Microsoft Corporation
11 This module implements a collection of data structure dump routines
12 for debugging the Fat file system
21 VOID
FatDump(IN PVOID Ptr
);
23 VOID
FatDumpDataHeader();
24 VOID
FatDumpVcb(IN PVCB Ptr
);
25 VOID
FatDumpFcb(IN PFCB Ptr
);
26 VOID
FatDumpCcb(IN PCCB Ptr
);
28 ULONG FatDumpCurrentColumn
;
30 #define DumpNewLine() { \
32 FatDumpCurrentColumn = 1; \
35 #define DumpLabel(Label,Width) { \
36 size_t i, LastPeriod=0; \
38 for(i=0;i<2;i++) { _Str[i] = UCHAR_SP;} \
39 for(i=0;i<strlen(#Label);i++) {if (#Label[i] == '.') LastPeriod = i;} \
40 strncpy(&_Str[2],&#Label[LastPeriod],Width); \
41 for(i=strlen(_Str);i<Width;i++) {_Str[i] = UCHAR_SP;} \
43 DbgPrint("%s", _Str); \
46 #define DumpField(Field) { \
47 if ((FatDumpCurrentColumn + 18 + 9 + 9) > 80) {DumpNewLine();} \
48 FatDumpCurrentColumn += 18 + 9 + 9; \
49 DumpLabel(Field,18); \
50 DbgPrint(":%p", Ptr->Field); \
54 #define DumpListEntry(Links) { \
55 if ((FatDumpCurrentColumn + 18 + 9 + 9) > 80) {DumpNewLine();} \
56 FatDumpCurrentColumn += 18 + 9 + 9; \
57 DumpLabel(Links,18); \
58 DbgPrint(":%p", Ptr->Links.Flink); \
59 DbgPrint(":%p", Ptr->Links.Blink); \
62 #define DumpName(Field,Width) { \
65 if ((FatDumpCurrentColumn + 18 + Width) > 80) {DumpNewLine();} \
66 FatDumpCurrentColumn += 18 + Width; \
67 DumpLabel(Field,18); \
68 for(i=0;i<Width;i++) {_String[i] = (CHAR)Ptr->Field[i];} \
69 _String[Width] = '\0'; \
70 DbgPrint("%s", _String); \
73 #define TestForNull(Name) { \
75 DbgPrint("%s - Cannot dump a NULL pointer\n", Name); \
90 This routine determines the type of internal record reference by ptr and
91 calls the appropriate dump routine.
95 Ptr - Supplies the pointer to the record to be dumped
104 TestForNull("FatDump");
106 switch (NodeType(Ptr
)) {
108 case FAT_NTC_DATA_HEADER
:
120 case FAT_NTC_ROOT_DCB
:
132 DbgPrint("FatDump - Unknown Node type code %p\n", *((PNODE_TYPE_CODE
)(Ptr
)));
148 Dump the top data structures and all Device structures
166 TestForNull("FatDumpDataHeader");
169 DbgPrint("FatData@ %lx", (Ptr
));
172 DumpField (NodeTypeCode
);
173 DumpField (NodeByteSize
);
174 DumpListEntry (VcbQueue
);
175 DumpField (DriverObject
);
176 DumpField (OurProcess
);
179 for (Links
= Ptr
->VcbQueue
.Flink
;
180 Links
!= &Ptr
->VcbQueue
;
181 Links
= Links
->Flink
) {
183 FatDumpVcb(CONTAINING_RECORD(Links
, VCB
, VcbLinks
));
199 Dump an Device structure, its Fcb queue amd direct access queue.
203 Ptr - Supplies the Device record to be dumped
212 TestForNull("FatDumpVcb");
215 DbgPrint("Vcb@ %lx", (Ptr
));
218 DumpField (VolumeFileHeader
.NodeTypeCode
);
219 DumpField (VolumeFileHeader
.NodeByteSize
);
220 DumpListEntry (VcbLinks
);
221 DumpField (TargetDeviceObject
);
223 DumpField (VcbState
);
224 DumpField (VcbCondition
);
226 DumpField (DirectAccessOpenCount
);
227 DumpField (OpenFileCount
);
228 DumpField (ReadOnlyCount
);
229 DumpField (AllocationSupport
);
230 DumpField (AllocationSupport
.RootDirectoryLbo
);
231 DumpField (AllocationSupport
.RootDirectorySize
);
232 DumpField (AllocationSupport
.FileAreaLbo
);
233 DumpField (AllocationSupport
.NumberOfClusters
);
234 DumpField (AllocationSupport
.NumberOfFreeClusters
);
235 DumpField (AllocationSupport
.FatIndexBitSize
);
236 DumpField (AllocationSupport
.LogOfBytesPerSector
);
237 DumpField (AllocationSupport
.LogOfBytesPerCluster
);
238 DumpField (DirtyFatMcb
);
239 DumpField (FreeClusterBitMap
);
240 DumpField (VirtualVolumeFile
);
241 DumpField (SectionObjectPointers
.DataSectionObject
);
242 DumpField (SectionObjectPointers
.SharedCacheMap
);
243 DumpField (SectionObjectPointers
.ImageSectionObject
);
244 DumpField (ClusterHint
);
247 FatDumpFcb(Ptr
->RootDcb
);
262 Dump an Fcb structure, its various queues
266 Ptr - Supplies the Fcb record to be dumped
277 TestForNull("FatDumpFcb");
280 if (NodeType(&Ptr
->Header
) == FAT_NTC_FCB
) {DbgPrint("Fcb@ %lx", (Ptr
));}
281 else if (NodeType(&Ptr
->Header
) == FAT_NTC_DCB
) {DbgPrint("Dcb@ %lx", (Ptr
));}
282 else if (NodeType(&Ptr
->Header
) == FAT_NTC_ROOT_DCB
) {DbgPrint("RootDcb@ %lx", (Ptr
));}
283 else {DbgPrint("NonFcb NodeType @ %lx", (Ptr
));}
286 DumpField (Header
.NodeTypeCode
);
287 DumpField (Header
.NodeByteSize
);
288 DumpListEntry (ParentDcbLinks
);
289 DumpField (ParentDcb
);
291 DumpField (FcbState
);
292 DumpField (FcbCondition
);
293 DumpField (UncleanCount
);
294 DumpField (OpenCount
);
295 DumpField (DirentOffsetWithinDirectory
);
296 DumpField (DirentFatFlags
);
297 DumpField (FullFileName
.Length
);
298 DumpField (FullFileName
.Buffer
);
299 DumpName (FullFileName
.Buffer
, 32);
300 DumpField (ShortName
.Name
.Oem
.Length
);
301 DumpField (ShortName
.Name
.Oem
.Buffer
);
302 DumpField (NonPaged
);
303 DumpField (Header
.AllocationSize
.LowPart
);
304 DumpField (NonPaged
->SectionObjectPointers
.DataSectionObject
);
305 DumpField (NonPaged
->SectionObjectPointers
.SharedCacheMap
);
306 DumpField (NonPaged
->SectionObjectPointers
.ImageSectionObject
);
308 if ((Ptr
->Header
.NodeTypeCode
== FAT_NTC_DCB
) ||
309 (Ptr
->Header
.NodeTypeCode
== FAT_NTC_ROOT_DCB
)) {
311 DumpListEntry (Specific
.Dcb
.ParentDcbQueue
);
312 DumpField (Specific
.Dcb
.DirectoryFileOpenCount
);
313 DumpField (Specific
.Dcb
.DirectoryFile
);
315 } else if (Ptr
->Header
.NodeTypeCode
== FAT_NTC_FCB
) {
317 DumpField (Header
.FileSize
.LowPart
);
322 DbgPrint("Illegal Node type code");
327 if ((Ptr
->Header
.NodeTypeCode
== FAT_NTC_DCB
) ||
328 (Ptr
->Header
.NodeTypeCode
== FAT_NTC_ROOT_DCB
)) {
330 for (Links
= Ptr
->Specific
.Dcb
.ParentDcbQueue
.Flink
;
331 Links
!= &Ptr
->Specific
.Dcb
.ParentDcbQueue
;
332 Links
= Links
->Flink
) {
334 FatDumpFcb(CONTAINING_RECORD(Links
, FCB
, ParentDcbLinks
));
355 Ptr - Supplies the Ccb record to be dumped
364 TestForNull("FatDumpCcb");
367 DbgPrint("Ccb@ %lx", (Ptr
));
370 DumpField (NodeTypeCode
);
371 DumpField (NodeByteSize
);
372 DumpField (UnicodeQueryTemplate
.Length
);
373 DumpName (UnicodeQueryTemplate
.Buffer
, 32);
374 DumpField (OffsetToStartSearchFrom
);