Source code of Windows XP (NT5)
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.

178 lines
5.1 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997-1999.
  5. //
  6. // File: usnmgr.hxx
  7. //
  8. // Contents: Usn manager
  9. //
  10. // History: 07-May-97 SitaramR Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #pragma once
  14. #include <waitmult.hxx>
  15. #include "usnvol.hxx"
  16. #include "scaninfo.hxx"
  17. class CiCat;
  18. class CScopeInfo;
  19. //+-------------------------------------------------------------------------
  20. //
  21. // Class: CUsnMgr
  22. //
  23. // Purpose: Usn manager
  24. //
  25. // History: 07-May-97 SitaramR Created
  26. //
  27. //--------------------------------------------------------------------------
  28. class CUsnMgr
  29. {
  30. public:
  31. CUsnMgr( CiCat & cicat );
  32. ~CUsnMgr();
  33. void Resume() { _thrUsn.Resume(); }
  34. void AddScope( WCHAR const *pwcsScope,
  35. VOLUMEID volumeId,
  36. BOOL fDoDeletions,
  37. USN const & usnStart = 0,
  38. BOOL fFullScan = FALSE,
  39. BOOL fUserInitiatedScan = FALSE,
  40. BOOL fNewScope = FALSE );
  41. void MonitorScope( WCHAR const *pwcsScope,
  42. VOLUMEID volumeId,
  43. USN usnStart );
  44. void RemoveScope( WCHAR const *pwcsScope,
  45. VOLUMEID volumeId );
  46. void EnableUpdates();
  47. void DisableUpdates();
  48. void InitiateShutdown();
  49. void WaitForShutdown();
  50. void Count( ULONG & ulInProgress, ULONG & ulPending )
  51. {
  52. CLock lock( _mutex );
  53. ulInProgress = _usnScansInProgress.Count();
  54. ulPending = _usnScansToDo.Count();
  55. }
  56. BOOL AnyInitialScans();
  57. void SetBatch();
  58. void ClearBatch();
  59. void ProcessUsnLog( BOOL & fAbort, VOLUMEID volScan, USN & usnScan );
  60. BOOL IsPathIndexed( CUsnVolume * pUsnVolume, CLowerFunnyPath & lcaseFunnyPath );
  61. void GetMaxUSNs( CUsnFlushInfoList & flushInfoList );
  62. BOOL IsWaitingForUpdates() const { return _fWaitingForUpdates; }
  63. private:
  64. static DWORD WINAPI UsnThread( void * self );
  65. void DoUsnProcessing();
  66. void ScanScope( XPtr<CCiScanInfo> & xScanInfo,
  67. BOOL fRefiled );
  68. BOOL LokIsScanScheduled( const XPtr<CCiScanInfo> & xScanInfo );
  69. static CCiScanInfo * QueryScanInfo( WCHAR const * pwcsScope,
  70. VOLUMEID volumeId,
  71. USN usnStart,
  72. BOOL fDoDeletions,
  73. BOOL fUserInitiated = FALSE,
  74. BOOL fNewScope = FALSE );
  75. void LokEmptyInProgressScans();
  76. void LokScheduleRemove( WCHAR const * pwcsScope,
  77. VOLUMEID volumeId );
  78. void DoUsnScans();
  79. void LokAddScopeForUsnMonitoring( XPtr<CCiScanInfo> & xScanInfo );
  80. void LokRemoveScopeFromUsnMonitoring( XPtr<CCiScanInfo> & xScanInfo );
  81. void ProcessUsnNotifications();
  82. void ProcessUsnLogRecords( CUsnVolume *pUsnVolume );
  83. NTSTATUS ProcessUsnNotificationsFromVolume( CUsnVolume *pUsnVolume,
  84. BOOL fImmediate = FALSE,
  85. BOOL fWait = TRUE );
  86. USN FindCurrentMaxUsn( WCHAR const * pwcsScope );
  87. void HandleError( WCHAR wcDrive, NTSTATUS Status );
  88. void HandleError( CUsnVolume * pUsnVolume, NTSTATUS Status );
  89. BOOL IsLowResource();
  90. void CheckTopLevelChange( CUsnVolume * pUsnVolume, ULONGLONG & FileReferenceNumber );
  91. CiCat & _cicat; // Catalog
  92. CMutexSem _mutex; // For mutual exclusion
  93. CEventSem _evtUsn; // Event semaphore
  94. BOOL _fAbort; // To abort processing
  95. BOOL _fUpdatesDisabled; // Are updates disabled ?
  96. BOOL _fBatch; // Are usn scans being batched ?
  97. BOOL _fDoingRenameTraverse; // Usn Tree Traversal due to rename?
  98. BOOL _fWaitingForUpdates; // TRUE if waiting on NTFS
  99. CWaitForMultipleObjects _waitForMultObj; // For waiting for usn notifications
  100. // from multiple volumes
  101. CScanInfoList _usnScansToDo; // Usn scopes that were added/removed
  102. CScanInfoList _usnScansInProgress; // Usn scopes being scanned by tree walk
  103. CUsnVolumeList _usnVolumesToMonitor; // Usn volumes being monitored by fsctls
  104. CThread _thrUsn; // Separate threads for usns
  105. };
  106. //+-------------------------------------------------------------------------
  107. //
  108. // Class: XBatchUsnProcessing
  109. //
  110. // Purpose: To batch processing of usn scans
  111. //
  112. // History: 27-Jun-97 SitaramR Created
  113. //
  114. //--------------------------------------------------------------------------
  115. class XBatchUsnProcessing
  116. {
  117. public:
  118. XBatchUsnProcessing( CUsnMgr & usnMgr )
  119. : _usnMgr(usnMgr)
  120. {
  121. _usnMgr.SetBatch();
  122. }
  123. ~XBatchUsnProcessing()
  124. {
  125. _usnMgr.ClearBatch();
  126. }
  127. private:
  128. CUsnMgr & _usnMgr;
  129. };