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.

236 lines
6.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1998.
  5. //
  6. // File: scopetbl.hxx
  7. //
  8. // Contents: Persistent scope table
  9. //
  10. // Classes: CCiScopeTable
  11. //
  12. // History: 14-Jul-97 SitaramR Created from dlnotify.hxx
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #include <refcount.hxx>
  17. #include <regevent.hxx>
  18. #include <fatnot.hxx>
  19. #include <rcstrmhd.hxx>
  20. #include <cimbmgr.hxx>
  21. #include "scaninfo.hxx"
  22. #include "acinotfy.hxx"
  23. #include "usnlist.hxx"
  24. #include "usnmgr.hxx"
  25. class CiCat;
  26. class CCiNotifyMgr;
  27. class CClientDocStore;
  28. extern WCHAR GetDriveLetterOfAnyScope( WCHAR const * pwcCatalog );
  29. //+---------------------------------------------------------------------------
  30. //
  31. // Class: CCiScopeUsrHdr
  32. //
  33. // Purpose: Format of the user header area in the scope table.
  34. //
  35. // History: 1-26-96 srikants Created
  36. // 3-06-98 kitmanh Added IsReadOnly method()
  37. //
  38. // Notes:
  39. //
  40. //----------------------------------------------------------------------------
  41. class CCiScopeUsrHdr
  42. {
  43. enum { CURRENT_VERSION = 1 };
  44. public:
  45. CCiScopeUsrHdr * GetPointer()
  46. {
  47. return this;
  48. }
  49. // ULONG GetVersion() const { return _nVersion; }
  50. // void SetVersion( ULONG nVersion ) { _nVersion = nVersion; }
  51. // BOOL IsCurrentVersion() const { return CURRENT_VERSION == _nVersion; }
  52. // void SetCurrentVersion() { _nVersion = CURRENT_VERSION; }
  53. BOOL IsInitialized() const { return 0 != _nVersion; }
  54. void Initialize()
  55. {
  56. RtlZeroMemory( this, sizeof(CCiScopeUsrHdr) );
  57. _nVersion = CURRENT_VERSION;
  58. }
  59. BOOL IsCiDataCorrupt() const { return _corruptInfo & eCiDataCorrupt; }
  60. BOOL IsFsCiDataCorrupt() const { return _corruptInfo & eFsCiDataCorrupt; }
  61. void SetCiDataCorrupt() { _corruptInfo |= eCiDataCorrupt; }
  62. void SetFsCiDataCorrupt() { _corruptInfo |= eFsCiDataCorrupt; }
  63. void ClearCiDataCorrupt() { _corruptInfo &= ~eCiDataCorrupt; }
  64. void ClearFsCiDataCorrupt() { _corruptInfo &= ~eFsCiDataCorrupt; }
  65. void SetFullScanNeeded() { _fFullScan = TRUE; }
  66. void ClearFullScanNeeded() { _fFullScan = FALSE; }
  67. BOOL IsFullScanNeeded() const { return _fFullScan; }
  68. private:
  69. enum ECorruptInfo
  70. {
  71. eNoCorruption = 0x0,
  72. eCiDataCorrupt = 0x1,
  73. eFsCiDataCorrupt = 0x2
  74. };
  75. ULONG _nVersion; // Version number - unused
  76. FILETIME _ftLastScan; // Time of the last successful scan
  77. ULONG _corruptInfo; // Set to TRUE if there is corruption
  78. BOOL _fFullScan; // Set to TRUE if full scan is needed
  79. };
  80. //+---------------------------------------------------------------------------
  81. //
  82. // Class: CCiScopeTable
  83. //
  84. // Purpose: Manages the persistent table of scopes that are of indexed
  85. // in a specific downlevel CI.
  86. //
  87. // History: 1-22-96 srikants Created
  88. // 2-20-98 kitmanh Move ClearCiDataCorrupt to scopetbl.cxx
  89. //
  90. // Notes:
  91. //
  92. //----------------------------------------------------------------------------
  93. const LONGLONG eSigCiScopeTable = 0x5158515851585158i64;
  94. const LONGLONG eFtCorrection = 2 * 60 * 1000 * 10000; // 2 minutes in 100
  95. // nanosecond intervals
  96. class CCiScopeTable
  97. {
  98. enum EContentScanState { eNoScan,
  99. eIncrScanNeeded,
  100. eFullScanNeeded,
  101. eDoingFullScan,
  102. eDoingIncrScan };
  103. public:
  104. CCiScopeTable( CiCat & cicat,
  105. CCiNotifyMgr & notifyMgr,
  106. CCiScanMgr & scanMgr,
  107. CUsnMgr & usnMgr )
  108. : _cicat(cicat),
  109. _notifyMgr(notifyMgr),
  110. _scanMgr(scanMgr),
  111. _usnMgr(usnMgr),
  112. _pTable(0),
  113. _state( eNoScan ),
  114. _fInitialized(FALSE)
  115. {
  116. }
  117. ~CCiScopeTable();
  118. void FastInit();
  119. void Empty();
  120. BOOL IsInit() const { return 0 != _pTable; }
  121. BOOL Enumerate( WCHAR *pwcScope, unsigned cwc, unsigned & iBmk );
  122. void AddScope( VOLUMEID volumeid,
  123. WCHAR const * pwcsScope,
  124. WCHAR const * pwcsCatScope = 0 );
  125. void StartUp( CClientDocStore & docStore, PARTITIONID partId );
  126. void ScanAllScopes( PARTITIONID partId );
  127. void RemoveSubScopes( WCHAR const * pwcsScope, WCHAR const * pwcsCatScope = 0 );
  128. void RemoveScope( WCHAR const * pwcsScope, WCHAR const * pwcsCatScope = 0 );
  129. static void RefreshShadow( WCHAR const * pwcsPScope, WCHAR const * pwcsCatScope );
  130. void ProcessChangesFlush();
  131. void UpdateScanTime( WCHAR const * pwcsScope, FILETIME const & ft );
  132. void MarkCiDataCorrupt();
  133. void ClearCiDataCorrupt();
  134. void MarkFsCiDataCorrupt()
  135. {
  136. _hdr.SetFsCiDataCorrupt();
  137. _UpdateHeader();
  138. }
  139. void ClearFsCiDataCorrupt()
  140. {
  141. _hdr.ClearFsCiDataCorrupt();
  142. _UpdateHeader();
  143. }
  144. BOOL IsCiDataCorrupt() const { return _hdr.IsCiDataCorrupt(); }
  145. BOOL IsFsCiDataCorrupt() const { return _hdr.IsFsCiDataCorrupt(); }
  146. BOOL IsDoingFullScan() const { return eDoingFullScan == _state; }
  147. BOOL IsFullScanNeeded() const { return eFullScanNeeded == _state; }
  148. BOOL IsIncrScanNeeded() const { return eIncrScanNeeded == _state; }
  149. void RecordFullScanNeeded();
  150. void RecordIncrScanNeeded( BOOL fStartup );
  151. void ScheduleScansIfNeeded(CClientDocStore & docStore);
  152. void RecordScansComplete();
  153. void ProcessDiskFull( CClientDocStore & docStore, PARTITIONID partId );
  154. void ClearDiskFull( CClientDocStore & docStore );
  155. #if CIDBG==1
  156. void Dump();
  157. #endif
  158. private:
  159. CiCat & _cicat;
  160. CCiNotifyMgr & _notifyMgr;
  161. CCiScanMgr & _scanMgr;
  162. CUsnMgr & _usnMgr;
  163. CMutexSem _mutex;
  164. PRcovStorageObj * _pTable;
  165. EContentScanState _state;
  166. BOOL _fInitialized;
  167. union
  168. {
  169. CRcovUserHdr _usrHdr;
  170. CCiScopeUsrHdr _hdr;
  171. };
  172. void _Serialize( CScopeInfoStack const & stk );
  173. void _Serialize();
  174. void _DeSerialize( CScopeInfoStack & stk );
  175. void _UpdateHeader();
  176. void _FatalCorruption();
  177. void _LokScheduleScans( PARTITIONID partId, BOOL &fSerializeNotifyList );
  178. };