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.

170 lines
4.4 KiB

  1. /*++
  2. Copyright (c) 2000-2001 Microsoft Corporation
  3. Module Name:
  4. volstate.h
  5. Abstract:
  6. Contains definition of the volume state class. This class
  7. maintains state about one volume.
  8. Author:
  9. Stefan R. Steiner [ssteiner] 03-14-2000
  10. Revision History:
  11. --*/
  12. #ifndef __H_VOLSTATE_
  13. #define __H_VOLSTATE_
  14. #include "exclproc.h"
  15. #include "vs_hash.h"
  16. #include "hardlink.h"
  17. //
  18. // Definition of the volume id
  19. //
  20. struct SFsdVolumeId
  21. {
  22. DWORD m_dwVolSerialNumber;
  23. inline BOOL IsEqual(
  24. IN SFsdVolumeId *psVolid
  25. )
  26. {
  27. return m_dwVolSerialNumber == psVolid->m_dwVolSerialNumber;
  28. }
  29. };
  30. //
  31. // Forward define
  32. //
  33. class CFsdVolumeState;
  34. //
  35. // Definition of the list of volume state objects with SFsdVolumeId key.
  36. //
  37. typedef TBsHashMap< SFsdVolumeId, CFsdVolumeState * > FSD_VOLUME_STATE_LIST;
  38. class CFsdVolumeStateManager
  39. {
  40. public:
  41. CFsdVolumeStateManager(
  42. IN CDumpParameters *pcDumpParameters
  43. );
  44. virtual ~CFsdVolumeStateManager();
  45. DWORD GetVolumeState(
  46. IN const CBsString& cwsVolumePath,
  47. OUT CFsdVolumeState **ppcVolState
  48. );
  49. VOID PrintExclusionInformation()
  50. {
  51. // Pass the buck...
  52. m_pcExclManager->PrintExclusionInformation();
  53. }
  54. VOID PrintHardLinkInfo();
  55. static DWORD CFsdVolumeStateManager::GetVolumeIdAndPath(
  56. IN CDumpParameters *pcDumpParameters,
  57. IN const CBsString& cwsPathOnVolume,
  58. OUT SFsdVolumeId *psVolId,
  59. OUT CBsString& cwsVolPath
  60. );
  61. private:
  62. CDumpParameters *m_pcParams;
  63. CFsdExclusionManager *m_pcExclManager;
  64. FSD_VOLUME_STATE_LIST m_cVolumeStateList;
  65. };
  66. class CFsdVolumeState
  67. {
  68. friend class CFsdVolumeStateManager;
  69. public:
  70. CFsdVolumeState(
  71. IN CDumpParameters *pcDumpParameters,
  72. IN const CBsString& cwsVolumePath
  73. ) : m_pcParams( pcDumpParameters ),
  74. m_cHardLinkManager( pcDumpParameters, cwsVolumePath.GetLength() ),
  75. m_cwsVolumePath( cwsVolumePath ),
  76. m_pcFSExclProcessor( NULL ),
  77. m_dwFileSystemFlags( 0 ),
  78. m_dwMaxComponentLength( 0 ),
  79. m_dwVolSerialNumber( 0 ) { }
  80. virtual ~CFsdVolumeState()
  81. {
  82. delete m_pcFSExclProcessor;
  83. }
  84. //
  85. // DirPath is relative to this volume
  86. //
  87. inline BOOL IsExcludedFile(
  88. IN const CBsString &cwsFullDirPath,
  89. IN DWORD dwEndOfVolMountPointOffset,
  90. IN const CBsString &cwsFileName
  91. )
  92. {
  93. if ( m_pcFSExclProcessor == NULL )
  94. return FALSE;
  95. return m_pcFSExclProcessor->IsExcludedFile( cwsFullDirPath, dwEndOfVolMountPointOffset, cwsFileName );
  96. }
  97. inline BOOL IsNtfs() { return ( m_dwFileSystemFlags & FS_PERSISTENT_ACLS ); }
  98. inline LPCWSTR GetFileSystemName() { return m_cwsFileSystemName.c_str(); }
  99. inline LPCWSTR GetVolumePath() { return m_cwsVolumePath.c_str(); }
  100. BOOL IsHardLinkInList(
  101. IN ULONGLONG ullFileIndex,
  102. IN const CBsString& cwsDirPath,
  103. IN const CBsString& cwsFileName,
  104. OUT WIN32_FILE_ATTRIBUTE_DATA *psFileAttributeData,
  105. OUT SFileExtendedInfo *psExtendedInfo
  106. )
  107. {
  108. return m_cHardLinkManager.IsHardLinkInList( ullFileIndex, cwsDirPath, cwsFileName, psFileAttributeData, psExtendedInfo );
  109. }
  110. VOID AddHardLinkToList(
  111. IN ULONGLONG ullFileIndex,
  112. IN const CBsString& cwsDirPath,
  113. IN const CBsString& cwsFileName,
  114. IN WIN32_FILE_ATTRIBUTE_DATA *psFileAttributeData,
  115. IN SFileExtendedInfo *psExtendedInfo
  116. )
  117. {
  118. m_cHardLinkManager.AddHardLinkToList( ullFileIndex, cwsDirPath, cwsFileName, psFileAttributeData, psExtendedInfo );
  119. }
  120. VOID PrintHardLinkInfo()
  121. {
  122. //
  123. // Pass it on...
  124. //
  125. m_cHardLinkManager.PrintHardLinkInfo();
  126. }
  127. private:
  128. CFsdVolumeState(); // No copying please
  129. CDumpParameters *m_pcParams;
  130. CBsString m_cwsVolumePath; // Path to the volume
  131. CBsString m_cwsFileSystemName;
  132. CFsdHardLinkManager m_cHardLinkManager;
  133. CFsdFileSystemExcludeProcessor *m_pcFSExclProcessor;
  134. DWORD m_dwFileSystemFlags; // GetVolumeInformation() fs flags
  135. DWORD m_dwMaxComponentLength;
  136. DWORD m_dwVolSerialNumber; // Should be volume GUID
  137. };
  138. #endif // __H_VOLSTATE_