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.

179 lines
5.2 KiB

  1. /*++
  2. Copyright (c) 2000-2001 Microsoft Corporation
  3. Module Name:
  4. engine.h
  5. Abstract:
  6. Header file for the file system dump utility engine
  7. Author:
  8. Stefan R. Steiner [ssteiner] 02-18-2000
  9. Revision History:
  10. --*/
  11. #ifndef __H_ENGINE_
  12. #define __H_ENGINE_
  13. class CFsdVolumeStateManager;
  14. class CFsdVolumeState;
  15. class CDumpEngine
  16. {
  17. public:
  18. CDumpEngine(
  19. IN CBsString cwsDirFileSpec,
  20. IN CDumpParameters &cDumpParameters
  21. ) : m_pcParams( &cDumpParameters ),
  22. m_ullNumDirs( 0 ),
  23. m_ullNumMountpoints( 0 ),
  24. m_ullNumBytesChecksummed( 0 ),
  25. m_ullNumBytesTotalUnnamedStream( 0 ),
  26. m_ullNumBytesTotalNamedDataStream( 0 ),
  27. m_ullNumReparsePoints( 0 ),
  28. m_ullNumFiles( 0 ),
  29. m_bShareName( FALSE ),
  30. m_ullNumFilesExcluded( 0 ),
  31. m_ullNumHardLinks( 0 ),
  32. m_ullNumDiscreteDACEs( 0 ),
  33. m_ullNumDiscreteSACEs( 0 ),
  34. m_ullNumEncryptedFiles( 0 ),
  35. m_ullNumFilesWithObjectIds( 0 )
  36. {
  37. assert( cwsDirFileSpec.GetLength() >= 1 );
  38. //
  39. // Let's do a bunch of stuff to normalize the given directory path. Windows doesn't
  40. // make this easy....
  41. //
  42. BOOL bPathIsInLongPathForm = FALSE;
  43. if ( cwsDirFileSpec.Left( 4 ) == L"\\\\?\\" || cwsDirFileSpec.Left( 4 ) == L"\\\\.\\" )
  44. {
  45. //
  46. // Switch . with ? if it is there
  47. //
  48. cwsDirFileSpec.SetAt( 2, L'?' );
  49. bPathIsInLongPathForm = TRUE;
  50. }
  51. else if ( cwsDirFileSpec.Left( 2 ) == L"\\\\" )
  52. {
  53. //
  54. // Remote path
  55. //
  56. m_bShareName = TRUE;
  57. }
  58. else if ( cwsDirFileSpec.GetLength() == 2 && cwsDirFileSpec[1] == L':' )
  59. {
  60. //
  61. // Just the drive letter and :. GetFullPathNameW thinks that means
  62. // the current directory on the drive whereas I mean for it to be the
  63. // entire volume, i.e. L:\
  64. //
  65. cwsDirFileSpec += L'\\';
  66. }
  67. //
  68. // Let's get the full path
  69. //
  70. LPWSTR pwszFileName;
  71. if ( ::GetFullPathNameW(
  72. cwsDirFileSpec,
  73. FSD_MAX_PATH,
  74. m_cwsDirFileSpec.GetBufferSetLength( FSD_MAX_PATH ),
  75. &pwszFileName ) == 0 )
  76. {
  77. m_pcParams->ErrPrint( L"ERROR - Unable to get full path name of '%s', dwRet: %d, trying with relative pathname",
  78. cwsDirFileSpec.c_str(), ::GetLastError() );
  79. m_cwsDirFileSpec.ReleaseBuffer() ;
  80. m_cwsDirFileSpec = cwsDirFileSpec;
  81. }
  82. else
  83. {
  84. m_cwsDirFileSpec.ReleaseBuffer();
  85. }
  86. //
  87. // Must prepare the path to support > MAX_PATH file path by
  88. // tacking on \\?\ on the front of the path. Shares have
  89. // a slightly different format.
  90. //
  91. if ( !( m_pcParams->m_bDisableLongPaths || bPathIsInLongPathForm ) )
  92. {
  93. if ( m_bShareName )
  94. {
  95. // BUGBUG: When the bug in GetVolumePathNameW() is fixed, uncomment the
  96. // following:
  97. // m_cwsDirFileSpec = L"\\\\?\\UNC";
  98. // m_cwsDirFileSpec += cwsDirFileSpec.c_str() + 1; // Have to chop off one '\'
  99. }
  100. else
  101. {
  102. m_cwsDirFileSpec = L"\\\\?\\" + m_cwsDirFileSpec;
  103. }
  104. }
  105. //
  106. // Add a trailing '\' if necessary
  107. //
  108. if ( m_pcParams->m_eFsDumpType != eFsDumpFile
  109. && m_cwsDirFileSpec.Right( 1 ) != L"\\" )
  110. m_cwsDirFileSpec += L'\\';
  111. //
  112. // Finally done mucking with paths...
  113. //
  114. }
  115. virtual ~CDumpEngine()
  116. {
  117. }
  118. DWORD PerformDump();
  119. static LPCSTR GetHeaderInformation();
  120. private:
  121. DWORD ProcessDir(
  122. IN CFsdVolumeStateManager *pcFsdVolStateManager,
  123. IN CFsdVolumeState *pcFsdVolState,
  124. IN const CBsString& cwsDirPath,
  125. IN INT cDirFileSpecLength,
  126. IN INT cVolMountPointOffset
  127. );
  128. VOID PrintEntry(
  129. IN CFsdVolumeState *pcFsdVolState,
  130. IN const CBsString& cwsDirPath,
  131. IN INT cDirFileSpecLength,
  132. IN SDirectoryEntry *psDirEntry,
  133. IN BOOL bSingleEntryOutput = FALSE
  134. );
  135. CBsString m_cwsDirFileSpec;
  136. CDumpParameters *m_pcParams;
  137. ULONGLONG m_ullNumDirs;
  138. ULONGLONG m_ullNumFiles;
  139. ULONGLONG m_ullNumMountpoints;
  140. ULONGLONG m_ullNumReparsePoints;
  141. ULONGLONG m_ullNumBytesChecksummed;
  142. ULONGLONG m_ullNumBytesTotalUnnamedStream;
  143. ULONGLONG m_ullNumBytesTotalNamedDataStream;
  144. ULONGLONG m_ullNumFilesExcluded;
  145. ULONGLONG m_ullNumHardLinks;
  146. ULONGLONG m_ullNumDiscreteDACEs;
  147. ULONGLONG m_ullNumDiscreteSACEs;
  148. ULONGLONG m_ullNumEncryptedFiles;
  149. ULONGLONG m_ullNumFilesWithObjectIds;
  150. BOOL m_bShareName;
  151. };
  152. #endif // __H_ENGINE_