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.

897 lines
29 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 2000.
  5. //
  6. // File: CICAT.HXX
  7. //
  8. // Contents: File catalog
  9. //
  10. // History: 09-Mar-92 BartoszM Created
  11. // 15-Mar-93 BartoszM Converted to memory mapped streams
  12. //
  13. //----------------------------------------------------------------------------
  14. #pragma once
  15. #include <dynstrm.hxx>
  16. #include <catalog.hxx>
  17. #include <spropmap.hxx>
  18. #include <secstore.hxx>
  19. #include <doclist.hxx>
  20. #include <imprsnat.hxx>
  21. #include <ciintf.h>
  22. #include <workman.hxx>
  23. #include <cistore.hxx>
  24. #include <pidtable.hxx>
  25. #include <prpstmgr.hxx>
  26. #include <ntopen.hxx>
  27. #include <notifary.hxx>
  28. #include "statmon.hxx"
  29. #include "chash.hxx"
  30. #include "notifmgr.hxx"
  31. #include "scopetbl.hxx"
  32. #include "scanmgr.hxx"
  33. #include "scpfixup.hxx"
  34. #include "signore.hxx"
  35. #include "usnlist.hxx"
  36. #include "usnmgr.hxx"
  37. #include "filidmap.hxx"
  38. #include "volinfo.hxx"
  39. class CClientDocStore;
  40. class CCompositePropRecord;
  41. class CPrimaryPropRecord;
  42. class CDynLoadNetApi32;
  43. #include "strings.hxx"
  44. WCHAR const CAT_DIR[] = L"\\catalog.wci";
  45. WCHAR const SETUP_DIR_PREFIX[] = L"\\$WIN_NT$.~";
  46. //
  47. // The path given for the catalog should leave room for \Catalog.Wci\8.3
  48. // Leave room for 2 8.3 names with a backslash.
  49. //
  50. const MAX_CAT_PATH = MAX_PATH - 13*2;
  51. void UpdateDuringRecovery( WORKID wid, BOOL fDelete, void const *pUserData );
  52. //+---------------------------------------------------------------------------
  53. //
  54. // Class: CScopeEntry
  55. //
  56. // Purpose: Maintains a scope entry to rescan
  57. //
  58. // History: 4/3/98 mohamedn created
  59. //----------------------------------------------------------------------------
  60. class CScopeEntry
  61. {
  62. public:
  63. CScopeEntry(WCHAR const * pwszScope);
  64. BOOL SetToParentDirectory(void);
  65. BOOL ContainsSpecialChar(void) { return _fContainsSpecialChar; }
  66. WCHAR const * Get(void) { return _xwcsPath.Get(); }
  67. private:
  68. WCHAR * GetSpecialCharLocation(void);
  69. BOOL IsSpecialChar(WCHAR c);
  70. BOOL IsRoot(void);
  71. BOOL _fContainsSpecialChar;
  72. XGrowable<WCHAR> _xwcsPath;
  73. unsigned _cclen;
  74. };
  75. //+---------------------------------------------------------------------------
  76. //
  77. // Class: CiCat
  78. //
  79. // Purpose: Catalog for downlevel media used by content index
  80. //
  81. // History: 10-Mar-92 BartoszM Created
  82. // 17-Feb-98 KitmanH Added public function
  83. // IsReadOnly()
  84. //----------------------------------------------------------------------------
  85. class CiCat: public PCatalog
  86. {
  87. friend class CUpdate;
  88. friend class CRegistryScopesCallBackAdd;
  89. friend class CRegistryScopesCallBackFixups;
  90. friend class CRegistryScopesCallBackRemoveAlias;
  91. friend class CUserPropCallback;
  92. friend class CClientDocStore;
  93. friend class CGibCallBack;
  94. public:
  95. CiCat ( CClientDocStore & docStore,
  96. CWorkManager & workMan,
  97. const WCHAR* wcsCatPath,
  98. BOOL &fVersionChange,
  99. BOOL fOpenForReadOnly,
  100. CDrvNotifArray & DrvNotifArray,
  101. const WCHAR * pwcName,
  102. BOOL fLeaveCorruptCatalog );
  103. ~CiCat ();
  104. const WCHAR * GetName() { return _xName.Get(); }
  105. const WCHAR * GetCatalogName() { return _xName.Get(); }
  106. const WCHAR * GetScopesKey() { return _xScopesKey.Get(); }
  107. PROPID PropertyToPropId ( CFullPropSpec const & ps, BOOL fCreate = FALSE );
  108. unsigned WorkIdToPath ( WORKID wid, CFunnyPath & funnyPath );
  109. unsigned WorkIdToAccuratePath ( WORKID wid, CLowerFunnyPath & funnyPath );
  110. BOOL PropertyRecordToFileId( CCompositePropRecord & PropRec,
  111. FILEID & fileId,
  112. VOLUMEID & volumeId );
  113. WORKID PathToWorkId ( const CLowerFunnyPath & lcaseFunnyPath,
  114. BOOL fCreate,
  115. BOOL & fNew,
  116. FILETIME * pftLastSeen,
  117. ESeenArrayType eType,
  118. FILEID fileId,
  119. WORKID widParent = widInvalid,
  120. BOOL fGuaranteedNew = FALSE );
  121. WORKID PathToWorkId( const CLowerFunnyPath & lcaseFunnyPath,
  122. const BOOL fCreate )
  123. {
  124. BOOL fNew;
  125. return PathToWorkId( lcaseFunnyPath, fCreate, fNew, 0, eScansArray, fileIdInvalid );
  126. }
  127. WORKID PathToWorkId ( const CLowerFunnyPath & lcaseFunnyPath,
  128. ESeenArrayType eType,
  129. FILEID fileId = fileIdInvalid )
  130. {
  131. BOOL fNew;
  132. return PathToWorkId( lcaseFunnyPath, TRUE, fNew, 0, eType, fileId );
  133. }
  134. void RenameFile( const CLowerFunnyPath & lcaseFunnyOldName,
  135. const CLowerFunnyPath & lcaseFunnyNewName,
  136. ULONG ulFileAttrib,
  137. VOLUMEID volumeId,
  138. FILEID fileId,
  139. WORKID widParent = widInvalid );
  140. void WriteFileAttributes( WORKID wid, ULONG ulFileAttrib )
  141. {
  142. PROPVARIANT propVar;
  143. propVar.vt = VT_UI4;
  144. propVar.ulVal = ulFileAttrib;
  145. _propstoremgr.WriteProperty( wid,
  146. pidAttrib,
  147. *(CStorageVariant const *)(ULONG_PTR)&propVar );
  148. }
  149. PStorage& GetStorage ();
  150. void FlushPropertyStore()
  151. {
  152. if ( _propstoremgr.IsBackedUpMode() )
  153. _propstoremgr.Flush();
  154. }
  155. void Update( const CLowerFunnyPath & lowerFunnyPath,
  156. BOOL fDeleted,
  157. FILETIME const & ftLastSeen,
  158. ULONG ulFileAttrib );
  159. void Update( const CLowerFunnyPath & lowerFunnyPath,
  160. FILEID fileId,
  161. WORKID widParent,
  162. USN usn,
  163. CUsnVolume *pUsnVolume,
  164. BOOL fDeleted,
  165. CReleasableLock * pLock = 0 );
  166. void LokMarkForDeletion( FILEID fileId,
  167. WORKID wid );
  168. void AddDocuments( CDocList const & docList );
  169. void ReScanPath( WCHAR const * wcsPath, BOOL fDelayed );
  170. BOOL EnumerateProperty( CFullPropSpec & ps, unsigned & cbInCache,
  171. ULONG & type, DWORD & dwStoreLevel,
  172. BOOL & fIsModifiable, unsigned & iBmk );
  173. void ClearNonStoragePropertiesForWid( WORKID wid );
  174. //
  175. // Cache metadata changes
  176. //
  177. ULONG_PTR BeginCacheTransaction();
  178. void SetupCache( CFullPropSpec const & ps,
  179. ULONG vt,
  180. ULONG cbMaxLen,
  181. ULONG_PTR ulToken,
  182. BOOL fCanBeModified,
  183. DWORD dwStoreLevel );
  184. void EndCacheTransaction( ULONG_PTR ulToken, BOOL fCommit );
  185. BOOL IsPropertyCached( CFullPropSpec const & ps )
  186. {
  187. Win4Assert( !"Not Yet Implemented" );
  188. return FALSE;
  189. }
  190. BOOL StoreValue( WORKID wid,
  191. CFullPropSpec const & ps,
  192. CStorageVariant const & var );
  193. BOOL FetchValue( WORKID wid,
  194. PROPID pid,
  195. PROPVARIANT * pbData,
  196. unsigned * pcb );
  197. BOOL FetchValue( CCompositePropRecord & Rec,
  198. PROPID pid,
  199. PROPVARIANT * pbData,
  200. BYTE * pbExtra,
  201. unsigned * pcb );
  202. BOOL FetchValue( WORKID wid,
  203. CFullPropSpec const & ps,
  204. PROPVARIANT & var );
  205. BOOL FetchValue( CCompositePropRecord * pRec,
  206. PROPID pid,
  207. PROPVARIANT * pbData,
  208. unsigned * pcb );
  209. BOOL FetchValue( CCompositePropRecord * pRec,
  210. PROPID pid,
  211. PROPVARIANT & var );
  212. CCompositePropRecord * OpenValueRecord( WORKID wid, BYTE * pb );
  213. void CloseValueRecord( CCompositePropRecord * pRec );
  214. BOOL StoreSecurity( WORKID wid,
  215. PSECURITY_DESCRIPTOR pSD,
  216. ULONG cbSD );
  217. SDID FetchSDID( CCompositePropRecord * pRec,
  218. WORKID wid );
  219. void MarkUnReachable( WORKID wid ); // virtual
  220. BOOL AccessCheck( SDID sdid,
  221. HANDLE hToken,
  222. ACCESS_MASK am,
  223. BOOL & fGranted );
  224. void Delete( WORKID wid, USN usn ) {}
  225. void UpdateDocuments ( WCHAR const* rootPath=0, ULONG flag=UPD_FULL );
  226. void CatalogState( ULONG & cDocuments, ULONG & cPendingScans, ULONG & fState );
  227. void AddScopeToCI( WCHAR const * rootPath, BOOL fFromVirtual = FALSE )
  228. {
  229. ScanOrAddScope( rootPath, TRUE, UPD_FULL, FALSE, TRUE, fFromVirtual );
  230. }
  231. DWORD ReScanCIScope( WCHAR const * rootPath, BOOL fFull );
  232. void ScanOrAddScope( WCHAR const * rootPath,
  233. BOOL fAdd,
  234. ULONG flag,
  235. BOOL fDoDeletions,
  236. BOOL fScanIfNotNew,
  237. BOOL fCreateShadow = FALSE );
  238. void RemoveScopeFromCI( WCHAR const * rootPath, BOOL fForceRemovalScan );
  239. void RemovePathsFromCiCat( WCHAR const * rootPath, ESeenArrayType eType );
  240. BOOL IsScopeInCI( WCHAR const * wcsScope );
  241. BOOL AddVirtualScope( WCHAR const * vroot,
  242. WCHAR const * root,
  243. BOOL fAutomatic,
  244. CiVRootTypeEnum eType,
  245. BOOL fIsVRoot,
  246. BOOL fIsIndexed );
  247. BOOL RemoveVirtualScope( WCHAR const * vroot,
  248. BOOL fOnlyIfAutomatic,
  249. CiVRootTypeEnum eType,
  250. BOOL fIsVRoot,
  251. BOOL fForceVPathFixing = FALSE );
  252. unsigned WorkIdToVirtualPath( WORKID wid,
  253. unsigned cSkip,
  254. XGrowable<WCHAR> & xBuf );
  255. unsigned WorkIdToVirtualPath( CCompositePropRecord & propRec,
  256. unsigned cSkip,
  257. XGrowable<WCHAR> & xBuf );
  258. BOOL VirtualToPhysicalRoot( WCHAR const * pwcVPath,
  259. unsigned ccVPath,
  260. XGrowable<WCHAR> & xwcsVRoot,
  261. unsigned & ccVRoot,
  262. CLowerFunnyPath & lcaseFunnyPRoot,
  263. unsigned & ccPRoot,
  264. unsigned & iBmk );
  265. inline BOOL VirtualToAllPhysicalRoots( WCHAR const * pwcVPath,
  266. unsigned ccVPath,
  267. XGrowable<WCHAR> & xwcsVRoot,
  268. unsigned & ccVRoot,
  269. CLowerFunnyPath & lcaseFunnyPRoot,
  270. unsigned & ccPRoot,
  271. ULONG & ulType,
  272. unsigned & iBmk );
  273. ULONG EnumerateVRoot( XGrowable<WCHAR> & xwcVRoot,
  274. unsigned & ccVRoot,
  275. CLowerFunnyPath & lcaseFunnyPRoot,
  276. unsigned & ccPRoot,
  277. unsigned & iBmk );
  278. virtual SCODE CreateContentIndex();
  279. virtual void EmptyContentIndex();
  280. virtual void ShutdownPhase1();
  281. virtual void ShutdownPhase2();
  282. NTSTATUS ForceMerge( PARTITIONID partID );
  283. NTSTATUS AbortMerge( PARTITIONID partID );
  284. void DumpWorkId( WORKID wid, ULONG iid, BYTE * pb, ULONG cb );
  285. void StartUpdate ( FILETIME* time,
  286. WCHAR const * pwcsScope,
  287. BOOL fDoDeletions,
  288. ESeenArrayType eType );
  289. void Touch ( WORKID wid, ESeenArrayType eType );
  290. void EndUpdate ( BOOL doDeletions, ESeenArrayType eType );
  291. WCHAR * GetDriveName();
  292. CRWStore * ComputeRelevantWords(ULONG cRows,ULONG cRW,
  293. WORKID *pwid,PARTITIONID partid);
  294. CRWStore * RetrieveRelevantWords(BOOL fAcquire,PARTITIONID partid);
  295. void SetPartition( PARTITIONID PartId ) { _PartId = PartId; }
  296. PARTITIONID GetPartition() const { return _PartId; }
  297. void PidMapToPidRemap( const CPidMapper & pidMap,
  298. CPidRemapper & pidRemap );
  299. SCODE CiState( CI_STATE & state );
  300. void DoUpdate( WCHAR const* rootPath,
  301. ULONG flag,
  302. BOOL fDoDeletions,
  303. BOOL & fAbort,
  304. BOOL fProcessRoot );
  305. void DoUpdate( CScanInfoList & scopes, CCiScanMgr & scanMgr, BOOL & fAbort );
  306. void ProcessScansComplete( BOOL fForce, BOOL & fShortWait );
  307. void IncrementUpdateCount( ULONG nUpdates )
  308. {
  309. _notify.IncrementUpdateCount( nUpdates );
  310. }
  311. BOOL IsEligibleForFiltering( WCHAR const* wcsDirPath );
  312. BOOL IsEligibleForFiltering( const CLowcaseBuf & LcaseDirPath );
  313. BOOL IsEligibleForFiltering( const CLowerFunnyPath & lowerFunnyPath );
  314. void SynchWithIIS( BOOL fRescanTC = TRUE, BOOL fSleep = TRUE );
  315. void SynchWithRegistryScopes( BOOL fRescanTC = TRUE );
  316. void SetupScopeFixups();
  317. void SynchShares();
  318. void DoRecovery();
  319. void SetRecoveryCompleted();
  320. BOOL IsRecoveryCompleted() { return _fRecoveryCompleted; }
  321. void SignalPhase2Completion() { _evtPh2Init.Set(); };
  322. void StartScansAndNotifies();
  323. void HandleError( NTSTATUS status ); // virtual
  324. BOOL IsDirectory( const CLowerFunnyPath * pOldFunnyPath, const CLowerFunnyPath * pNewFunnyPath );
  325. static BOOL IsUNCName( WCHAR const * pwszPath );
  326. BOOL IsReadOnly() { return _fIsReadOnly; }
  327. void SetEvtInitialized() { _evtInitialized.Set(); }
  328. void SetEvtPh2Init() { _evtPh2Init.Set(); }
  329. // Disk full processing
  330. void NoLokProcessDiskFull();
  331. void NoLokClearDiskFull();
  332. BOOL IsLowOnDisk() const { return _statusMonitor.IsLowOnDisk(); }
  333. BOOL IsCorrupt( ) const
  334. {
  335. return _statusMonitor.IsCorrupt();
  336. }
  337. // Scan support
  338. void MarkFullScanNeeded();
  339. void MarkIncrScanNeeded();
  340. // Changes Flush Support
  341. void ProcessChangesFlush( FILETIME const & ftFlushed,
  342. ULONG cEntries,
  343. USN_FLUSH_INFO const * const * ppUsnEntries );
  344. void ScheduleSerializeChanges();
  345. void SerializeChangesInfo();
  346. static BOOL IsDiskLowError( DWORD status );
  347. static void FillMaxTime( FILETIME & ft );
  348. static BOOL IsMaxTime( const FILETIME & ft );
  349. //
  350. // Support for CiFramework.
  351. //
  352. void StartupCiFrameWork( ICiManager * pCiManager );
  353. unsigned FixupPath( WCHAR const * pwcOriginal,
  354. WCHAR * pwcResult,
  355. unsigned cwcResult,
  356. unsigned cSkip )
  357. {
  358. return _scopeFixup.Fixup( pwcOriginal, pwcResult, cwcResult, cSkip );
  359. }
  360. void InverseFixupPath( CLowerFunnyPath & lcaseFunnyPath )
  361. {
  362. _scopeFixup.InverseFixup( lcaseFunnyPath );
  363. }
  364. CCiScopeTable * GetScopeTable() { return & _scopeTable; }
  365. CScopeFixup * GetScopeFixup()
  366. {
  367. return &_scopeFixup;
  368. }
  369. CImpersonationTokenCache * GetImpersonationTokenCache()
  370. { return & _impersonationTokenCache; }
  371. void RefreshRegistryParams();
  372. WCHAR const * GetCatDir() const { return _wcsCatDir; }
  373. CWorkManager & GetWorkMan() { return _workMan; }
  374. void MakeBackupOfPropStore( WCHAR const * pwszDir,
  375. IProgressNotify * pIProgressNotify,
  376. BOOL & fAbort,
  377. ICiEnumWorkids * pIWorkIds );
  378. BOOL ProcessFile( const CLowerFunnyPath & lcaseFunnyPath,
  379. FILEID fileId,
  380. VOLUMEID volumeId,
  381. WORKID widParent,
  382. DWORD dwFileAttributes,
  383. WORKID & wid );
  384. WORKID FileIdToWorkId( FILEID fileId, VOLUMEID volumeId )
  385. {
  386. CLock lock( _mutex );
  387. return _fileIdMap.LokFind( fileId, volumeId );
  388. }
  389. void FileIdToPath( FILEID fileId,
  390. CUsnVolume *pUsnVolume,
  391. CLowerFunnyPath & lcaseFunnyPath,
  392. BOOL & fPathInScope );
  393. unsigned FileIdToPath( FILEID & fileId,
  394. VOLUMEID volumeId,
  395. CLowerFunnyPath & funnyPath );
  396. void UsnRecordToPathUsingParentId( USN_RECORD *pUsnRec,
  397. CUsnVolume *pUsnVolume,
  398. CLowerFunnyPath & lowerFunnyPath,
  399. BOOL &fPathInScope,
  400. WORKID & widParent,
  401. BOOL fParentMayNotBeIndexed );
  402. BOOL VolumeSupportsUsns( WCHAR wcVolume );
  403. BOOL IsOnUsnVolume( WCHAR const *pwszPath );
  404. VOLUMEID MapPathToVolumeId( const WCHAR *pwszPath );
  405. ULONGLONG const & GetJournalId( const WCHAR *pwszPath );
  406. ULONGLONG const & GetVolumeCreationTime( const WCHAR *pwszPath );
  407. ULONG GetVolumeSerialNumber( const WCHAR *pwszPath );
  408. void InitUsnTreeScan( WCHAR const *pwszPath );
  409. void SetUsnTreeScanComplete( WCHAR const *pwszPath,
  410. USN usnMax );
  411. void SetTreeScanComplete( WCHAR const *pwszPath );
  412. #if CIDBG==1
  413. void CheckUsnTreeScan( WCHAR const *pwszPath );
  414. #endif
  415. ICiManager *CiManager()
  416. {
  417. Win4Assert( _xCiManager.GetPointer() );
  418. return _xCiManager.GetPointer();
  419. }
  420. BOOL HasChanged( WORKID wid, FILETIME const & ft );
  421. CCiRegParams * GetRegParams() { return & _regParams; }
  422. PROPID StandardPropertyToPropId ( CFullPropSpec const & ps )
  423. {
  424. return _propMapper.StandardPropertyToPropId( ps );
  425. }
  426. unsigned ReserveUpdate( WORKID wid ) { Win4Assert( FALSE ); return 0; }
  427. void Update( unsigned iHint, WORKID wid, PARTITIONID partid, USN usn, ULONG flags )
  428. { Win4Assert( FALSE ); }
  429. void FlushScanStatus() {}
  430. BOOL IsNullCatalog() { return FALSE; }
  431. CMutexSem & GetMutex() { return _mutex; }
  432. private:
  433. friend void UpdateDuringRecovery( WORKID wid, BOOL fDelete, void const *pUserData );
  434. BOOL _IsEligibleForFiltering( const WCHAR * pwcsPath, unsigned ccPath );
  435. void ScanThisScope(WCHAR const * pwszPath);
  436. void RemoveThisScope(WCHAR const * pwszPath, BOOL fForceRemovalScan );
  437. void OnIgnoredScopeDelete(WCHAR const * pwcRoot, unsigned & iBmk, CRegAccess & regScopes);
  438. void OnIndexedScopeDelete(WCHAR const * pwcRoot, unsigned & iBmk, CRegAccess & regScopes);
  439. BOOL RemoveMatchingScopeTableEntries( WCHAR const * pwszRegXScope );
  440. void ScanScopeTableEntry (WCHAR const * pwszScopeToRescan);
  441. SCODE Update( WORKID wid, PARTITIONID partid, VOLUMEID volumeId, USN usn, ULONG flags );
  442. void SignalDaemonRescanTC() { _evtRescanTC->Set(); }
  443. void EvtLogIISAdminNotAvailable();
  444. void SetName( const WCHAR *pwc )
  445. {
  446. _xName.Init( wcslen( pwc ) + 1 );
  447. RtlCopyMemory( _xName.Get(), pwc, _xName.SizeOf() );
  448. }
  449. void EnableUpdateNotifies();
  450. CPidLookupTable & GetPidLookupTable() { return _PidTable; }
  451. void LokWriteFileUsnInfo( WORKID wid,
  452. FILEID fileId,
  453. BOOL fWriteToPropStore,
  454. VOLUMEID volumeId,
  455. WORKID widParent,
  456. DWORD dwFileAttributes );
  457. void PersistMaxUSNs( void );
  458. void RenameFileInternal( const CLowerFunnyPath & lcaseFunnyOldName,
  459. const CLowerFunnyPath & lcaseFunnyNewName,
  460. ULONG ulFileAttrib,
  461. VOLUMEID volumeId,
  462. FILEID fileId,
  463. WORKID widParent);
  464. WORKID PathToWorkIdInternal
  465. ( const CLowerFunnyPath & lcaseFunnyPath,
  466. BOOL fCreate,
  467. BOOL & fNew,
  468. FILETIME * pftLastSeen,
  469. ESeenArrayType eType,
  470. FILEID fileId,
  471. WORKID widParent,
  472. BOOL fGuaranteedNew);
  473. #if CIDBG==1
  474. void DebugPrintWidInfo( WORKID wid );
  475. #endif
  476. BOOL IsInit() { return eStarting != _state; }
  477. BOOL LokExists();
  478. void LokCreate();
  479. void LokInit();
  480. void InitOrCreate();
  481. void InitIf( BOOL fLeaveCorruptCatalog = FALSE );
  482. void CreateIf();
  483. void AbortWorkItems();
  484. void LogCiFailure( NTSTATUS status );
  485. BOOL IsIgnoreNotification( WORKID wid,
  486. const CFunnyPath & funnyPath,
  487. ULONG ulFileAttrib );
  488. void AddShadowScopes();
  489. BOOL IsStarting() const { return (eStarting == _state || eQueryOnly == _state); }
  490. BOOL IsStarted() const { return (eStarted == _state || eQueryOnly == _state); }
  491. BOOL IsShuttingDown() const { return (eShutdownPhase1 == _state); }
  492. BOOL IsShutdown() const { return (eShutdown == _state); }
  493. BOOL IsCiDataCorrupt() const
  494. {
  495. return _scopeTable.IsCiDataCorrupt();
  496. }
  497. void ClearCiDataCorrupt()
  498. {
  499. _scopeTable.ClearCiDataCorrupt();
  500. }
  501. BOOL IsFsCiDataCorrupt() const
  502. {
  503. return _scopeTable.IsFsCiDataCorrupt();
  504. }
  505. void LogEvent( CCiStatusMonitor::EMessageType eType,
  506. DWORD status = STATUS_SUCCESS,
  507. ULONG val = 0 )
  508. {
  509. _statusMonitor.LogEvent( eType, status, val );
  510. }
  511. //
  512. // Helper routines for properties
  513. //
  514. void RecoverUserProperties( ULONG_PTR ulToken, DWORD dwStoreLevel );
  515. void DeleteUserProperty( CFullPropSpec const & fps );
  516. FILEID PathToFileId( const CFunnyPath & pwcPath );
  517. WORKID LokLookupWid( const CLowerFunnyPath & lcaseFunnyPath, FILEID & fileId );
  518. void AddShares( CDynLoadNetApi32 & dlNetApi32 );
  519. void RefreshIfShadowAlias( WCHAR const * pwcsScope,
  520. WCHAR const * pwcsAlias,
  521. HKEY hkey );
  522. void AddShadowAlias( WCHAR const * pwcsScope,
  523. WCHAR const * pwcsAlias,
  524. unsigned iSlot,
  525. HKEY hkey );
  526. void DeleteIfShadowAlias( WCHAR const * pwcsScope, WCHAR const * pwcsAlias );
  527. enum EState
  528. {
  529. eStarting,
  530. eQueryOnly,
  531. eStarted,
  532. eShutdownPhase1,
  533. eShutdown
  534. };
  535. ULONG _ulSignature; // Signature of start of privates
  536. CCiRegParams _regParams;
  537. CStandardPropMapper _propMapper;
  538. CScopeMatch _CatDir; // skip indexing catalog directory
  539. BOOL _fIsReadOnly; // TRUE if catalog is read-only
  540. BOOL _fDiskPerfEnabled; // TRUE if DiskPerf.sys is loaded
  541. CiStorage* _pStorage; // Allocates storage
  542. EState _state;
  543. CImpersonationTokenCache _impersonationTokenCache;
  544. CScopeFixup _scopeFixup; // path fixup for remote clients
  545. CScopesIgnored _scopesIgnored; // paths that shouldn't be filtered
  546. CClientDocStore & _docStore; // Document store interface
  547. XGrowable<WCHAR> _xwcsDriveName; // Large buffer for UNC drive
  548. WCHAR _wcsCatDir[MAX_PATH]; // path to catalog directory
  549. CCiStatusMonitor _statusMonitor; // CI Status monitoring
  550. BOOL _fInitialized; // Set to true when fully initilaized.
  551. // Optimization - test before doing a wait.
  552. CEventSem _evtInitialized; // Event set when initialization is
  553. // completed.
  554. CEventSem _evtPh2Init; // Phase2 initialization
  555. CPropStoreManager _propstoremgr; // Property values cached through this.
  556. CStrings _strings; // pointers to strings and hash table
  557. CFileIdMap _fileIdMap; // File id to wid map
  558. CPidLookupTable _PidTable; // PROPID mapping table
  559. CSdidLookupTable _SecStore; // SDID mapping table
  560. CMutexSem _mutex;
  561. CMutexSem _mtxAdmin; // Lock for admin operations.
  562. PARTITIONID _PartId; // partitions are not supported
  563. CWorkManager & _workMan; // Asynchronous work item manager
  564. CMutexSem _mtxIISSynch; // IIS Synch protection
  565. long _cIISSynchThreads;
  566. CCiScanMgr _scanMgr; // Scanning thread manager
  567. CUsnMgr _usnMgr; // Usn thread manager
  568. CCiNotifyMgr _notify; // Change notifications.
  569. CCiScopeTable _scopeTable; // Table of all scopes in CI
  570. BOOL _fRecovering; // TRUE if in midst of dirty shutdown recovery
  571. BOOL _fRecoveryCompleted; // TRUE AFTER recovery has successfully completed
  572. BOOL _fAutoAlias; // TRUE if all net shares should be added as fixups
  573. BOOL _fIndexW3Roots; // TRUE if should grovel W3 roots
  574. BOOL _fIndexNNTPRoots; // TRUE if should grovel NNTP roots
  575. BOOL _fIndexIMAPRoots; // TRUE if should grovel IMAP roots
  576. ULONG _W3SvcInstance; // instance # of w3svc
  577. ULONG _NNTPSvcInstance; // instance # of nntpsvc
  578. ULONG _IMAPSvcInstance; // instance # of imapsvc
  579. BOOL _fIsIISAdminAlive; // TRUE if the iisadmin svc is up
  580. FILETIME _ftLastCLFlush; // Last ChangeLog Flush time
  581. CUsnFlushInfoList _usnFlushInfoList; // List of usn info
  582. CVolumeInfo _aUsnVolumes[ RTL_MAX_DRIVE_LETTERS ]; // Info about each usn volume
  583. unsigned _cUsnVolumes;
  584. CDrvNotifArray & _DrvNotifArray;
  585. //
  586. // CI Framework support.
  587. //
  588. XInterface<ICiManager> _xCiManager; // ContentIndex manager
  589. XInterface<ICiCAdviseStatus> _xAdviseStatus;
  590. XPtr<CEventSem> _evtRescanTC; // Rescan token cache
  591. XArray<WCHAR> _xName; // friendly name of catalog
  592. XArray<WCHAR> _xScopesKey; // handy registry key
  593. };
  594. inline BOOL CiCat::IsDiskLowError( DWORD status )
  595. {
  596. return STATUS_DISK_FULL == status ||
  597. ERROR_DISK_FULL == status ||
  598. HRESULT_FROM_WIN32(ERROR_DISK_FULL) == status ||
  599. FILTER_S_DISK_FULL == status ||
  600. CI_E_CONFIG_DISK_FULL == status;
  601. }
  602. inline void CiCat::FillMaxTime( FILETIME & ft )
  603. {
  604. ft.dwLowDateTime = 0xFFFFFFFF;
  605. ft.dwHighDateTime = 0xFFFFFFFF;
  606. }
  607. inline BOOL CiCat::IsMaxTime( const FILETIME & ft )
  608. {
  609. return 0xFFFFFFFF == ft.dwLowDateTime &&
  610. 0xFFFFFFFF == ft.dwHighDateTime;
  611. }
  612. inline BOOL CiCat::VirtualToAllPhysicalRoots( WCHAR const * pwcVPath,
  613. unsigned ccVPath,
  614. XGrowable<WCHAR> & xwcsVRoot,
  615. unsigned & ccVRoot,
  616. CLowerFunnyPath & lcaseFunnyPRoot,
  617. unsigned & ccPRoot,
  618. ULONG & ulType,
  619. unsigned & iBmk )
  620. {
  621. return _strings.VirtualToAllPhysicalRoots( pwcVPath,
  622. ccVPath,
  623. xwcsVRoot,
  624. ccVRoot,
  625. lcaseFunnyPRoot,
  626. ccPRoot,
  627. ulType,
  628. iBmk );
  629. }
  630. //+---------------------------------------------------------------------------
  631. //
  632. // Class: CReferenceCount
  633. //
  634. // Purpose: Counts references
  635. //
  636. // History: 23-Sep-97 dlee Created
  637. //
  638. //----------------------------------------------------------------------------
  639. class CReferenceCount
  640. {
  641. public:
  642. CReferenceCount( long & lCount, BOOL fInc = TRUE ) :
  643. _lCount( lCount ), _fInc( fInc )
  644. {
  645. if ( fInc )
  646. InterlockedIncrement( &_lCount );
  647. }
  648. long Increment()
  649. {
  650. Win4Assert( !_fInc );
  651. _fInc = TRUE;
  652. return InterlockedIncrement( &_lCount );
  653. }
  654. long Decrement()
  655. {
  656. Win4Assert( _fInc );
  657. _fInc = FALSE;
  658. return InterlockedDecrement( &_lCount );
  659. }
  660. ~CReferenceCount()
  661. {
  662. if ( _fInc )
  663. InterlockedDecrement( &_lCount );
  664. }
  665. private:
  666. long & _lCount;
  667. BOOL _fInc;
  668. };