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.

309 lines
8.7 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1998
  5. //
  6. // File: CISTORE.HXX
  7. //
  8. // Contents: Physical storage + transactions
  9. //
  10. // Classes: CiStorage
  11. //
  12. // History: 05-Mar-92 KyleP Created
  13. // 16-Jul-92 BartoszM Separated
  14. // 07-Feb-93 SrikantS Added Support for Recoverable Storage
  15. // Objects.
  16. //
  17. //----------------------------------------------------------------------------
  18. #pragma once
  19. #include <pstore.hxx>
  20. #include <ciintf.h>
  21. #include <rptcrpt.hxx>
  22. #include <thash.hxx>
  23. #include <twidhash.hxx>
  24. #include <fsciexps.hxx>
  25. #include <driveinf.hxx>
  26. class CEnumString;
  27. class CiStorageObject: public PStorageObject
  28. {
  29. public:
  30. CiStorageObject(WORKID objectId);
  31. ~CiStorageObject();
  32. WORKID ObjectId() { return _objectId; }
  33. void Close() {}
  34. private:
  35. WORKID _objectId;
  36. };
  37. class PMmStream;
  38. class PDirectory;
  39. class CPersStream;
  40. class CFreshTableIter;
  41. class CPersFresh;
  42. class CFresh;
  43. class PRcovStorageObj;
  44. class CiStorage;
  45. class CPropStoreBackupStream;
  46. //+-------------------------------------------------------------------------
  47. //
  48. // Class: CiStorage
  49. //
  50. // Purpose: Encapsulates a 'physical storage', really just a path.
  51. //
  52. // Interface:
  53. //
  54. // History: 07-Mar-92 KyleP Created
  55. // 15-Nov-93 DwightKr Allowed access to _xPath
  56. // 20-Mar-94 SrikantS Robust Master Merge changes
  57. // 17-Feb-98 KitmanH Added _fIsReadOnly and method
  58. // IsReadOnly()
  59. // 17-Mar-98 KitmanH Added functions QueryStringHash(),
  60. // QueryFileIdMap() & QueryDeletionLog()
  61. // 27-Oct-98 KLam Constructor takes disk space to leave
  62. // 20-Nov-98 KLam Added CDriveInfo member
  63. //
  64. //--------------------------------------------------------------------------
  65. class CTransaction;
  66. class CiStorage : public PStorage
  67. {
  68. friend class CiDirectory;
  69. friend class CIndexTable;
  70. friend class CIndexTabIter;
  71. public:
  72. //
  73. // Version defaults to the general store's version. When used by FSCI,
  74. // it passes in FSCI_VERSION_STAMP to distinguish itself from other
  75. // users of CiStorage.
  76. //
  77. CiStorage( WCHAR const * szPath,
  78. ICiCAdviseStatus & adviseStatus,
  79. ULONG cMegToLeaveOnDisk,
  80. ULONG ulVer = CURRENT_VERSION_STAMP,
  81. BOOL fReadOnly = FALSE);
  82. ~CiStorage();
  83. PIndexTable* QueryIndexTable ( CTransaction& xact );
  84. PRcovStorageObj * QueryIdxTableObject();
  85. WORKID CreateObjectId ( INDEXID iid, PStorage::EDefaultStrmType eType )
  86. {
  87. Win4Assert ( sizeof(INDEXID) == sizeof(WORKID) );
  88. return WORKID(iid);
  89. }
  90. PStorageObject* QueryObject( WORKID objectId );
  91. void DeleteObject ( WORKID objectId );
  92. void EmptyIndexList ();
  93. PMmStream* QueryNewIndexStream ( PStorageObject& obj, BOOL isSparse = FALSE );
  94. PMmStream* QueryExistingIndexStream ( PStorageObject& obj,
  95. PStorage::EOpenMode mode );
  96. PMmStream* DupExistingIndexStream( PStorageObject& obj,
  97. PMmStream & mmStream,
  98. EOpenMode mode );
  99. PMmStream* QueryNewHashStream ( PStorageObject& obj );
  100. PMmStream* QueryExistingHashStream ( PStorageObject& obj,
  101. PStorage::EOpenMode mode );
  102. PDirectory* QueryNewDirectory ( PStorageObject& obj );
  103. PDirectory* QueryExistingDirectory ( PStorageObject& obj,
  104. PStorage::EOpenMode mode );
  105. PMmStream* QueryNewPropStream ( PStorageObject& obj,
  106. DWORD dwStoreLevel = PRIMARY_STORE);
  107. PMmStream* QueryExistingPropStream ( PStorageObject& obj,
  108. PStorage::EOpenMode mode,
  109. DWORD dwStoreLevel = PRIMARY_STORE );
  110. PMmStream* QueryStringHash();
  111. PMmStream* QueryFileIdMap();
  112. PMmStream* QueryDeletionLog();
  113. CPropStoreBackupStream* QueryNewPSBkpStream( PStorageObject& obj,
  114. ULONG ulMaxPages,
  115. DWORD dwStoreLevel = PRIMARY_STORE );
  116. CPropStoreBackupStream* OpenExistingPSBkpStreamForRecovery(PStorageObject& obj,
  117. DWORD dwStoreLevel = PRIMARY_STORE);
  118. BOOL RemoveObject( WORKID iid );
  119. BOOL RemoveMMLog( WORKID objectId );
  120. void CommitTransaction() {}
  121. void AbortTransaction() {}
  122. void CheckPoint() {};
  123. WCHAR * QueryCurrentPath() { return _xPath.GetPointer(); }
  124. PRcovStorageObj * QueryFreshLog ( WORKID wid );
  125. WORKID GetSpecialItObjectId( IndexType it ) const;
  126. void SetSpecialItObjectId( IndexType it, WORKID wid );
  127. WORKID GetNewObjectIdForFreshLog();
  128. BOOL RemoveFreshLog( WORKID widFreshLog );
  129. PRcovStorageObj * QueryChangeLog(WORKID, EChangeLogType);
  130. PRcovStorageObj * QueryRecoverableLog(WORKID wid);
  131. PRcovStorageObj * QueryMMergeLog(WORKID);
  132. PRcovStorageObj * QueryPidLookupTable(WORKID wid);
  133. PRcovStorageObj * QuerySdidLookupTable(WORKID wid);
  134. PRcovStorageObj * QueryPropStore(WORKID wid,
  135. DWORD dwStoreLevel = PRIMARY_STORE);
  136. PRcovStorageObj * QueryScopeList(WORKID);
  137. PRcovStorageObj * QueryVirtualScopeList(WORKID);
  138. PRcovStorageObj * QueryTestLog();
  139. void InitRcovObj( WORKID wid, BOOL fAtomStrmOnly = FALSE ) { }
  140. void GetDiskSpace( __int64 & diskTotal, __int64 & diskRemaining );
  141. const WCHAR * GetVolumeName() { return _xPath.GetPointer(); }
  142. USN GetNextUsn() { USN usn = 0; return usn; }
  143. BOOL IsVolumeClean() { return TRUE; }
  144. void ReportCorruptComponent( WCHAR const * pwszString );
  145. virtual void DeleteAllFiles();
  146. virtual void DeleteAllCiFiles();
  147. virtual void DeleteAllPersIndexes();
  148. virtual void DeleteUnUsedPersIndexes( CIndexIdList const & iidsInUse );
  149. virtual void DeleteAllFsCiFiles();
  150. virtual void CopyGivenFile( WCHAR const * pwszFilePath, BOOL fMoveOk );
  151. virtual BOOL SupportsShrinkFromFront() const
  152. { return _fSupportsShrinkFromFront; }
  153. void RemovePropStore( WORKID wid,
  154. DWORD dwStoreLevel = PRIMARY_STORE );
  155. void RemoveSecStore( WORKID wid );
  156. static void EnumerateFilesInDir( WCHAR const * pwszDirectory,
  157. CEnumString & strEnum );
  158. static BOOL CheckHasIndexTable( WCHAR const * pwszDir );
  159. static BOOL IsValidFile( WCHAR const * pwszPath );
  160. static UINT DetermineDriveType( WCHAR const * pwszPath );
  161. //
  162. // Lists the filenames of property store related files
  163. //
  164. void ListPropStoreFileNames( CEnumString & enumStr, WORKID wid,
  165. DWORD dwStoreLevel = PRIMARY_STORE);
  166. void ListSecStoreFileNames( CEnumString & enumStr, WORKID wid );
  167. // get the storage version
  168. ULONG GetStorageVersion() const { return _ulVer; }
  169. BOOL IsReadOnly() const { return _fIsReadOnly; }
  170. void SetReadOnly() { _fIsReadOnly = TRUE; }
  171. BOOL FavorReadAhead() const { return _fFavorReadAhead; }
  172. void SetFavorReadAhead( BOOL f ) { _fFavorReadAhead = f; }
  173. private:
  174. PMmStream* QueryNewDirStream ( WORKID iid );
  175. PMmStream* QueryExistingDirStream ( WORKID iid, BOOL fWrite = FALSE );
  176. PMmStream* QueryStream ( WCHAR const * wcsFileName );
  177. enum EPathType
  178. {
  179. eIndexPath,
  180. eHashPath,
  181. ePrimaryPropPath,
  182. eSecondaryPropPath,
  183. eDirPath
  184. };
  185. void MakePath( EPathType type, WORKID iid, WCHAR * wcsIndex );
  186. void MakeLogPath( WCHAR *, WCHAR * );
  187. void FormRcovObjNames( WORKID wid, WCHAR * wcsPrefix,
  188. WCHAR * wcsHdr, WCHAR * wcsCopy1,
  189. WCHAR * wcsCopy2 );
  190. void DeleteFilesInCiDir( WCHAR const * pwszPattern );
  191. void DeleteUnUsedPersIndexes( BOOL fIsCi,
  192. CIndexIdList const & iidsInUse );
  193. BOOL IsInUse( WCHAR const * pwszFile, CIndexIdList const & iidsInUse ) const;
  194. static const WCHAR _aHexDigit[17];
  195. XPtrST<WCHAR> _xPath;
  196. WORKID _widFreshLog;
  197. ICiCAdviseStatus & _adviseStatus;
  198. BOOL _fCorruptionReported;
  199. BOOL _fSupportsShrinkFromFront;
  200. ULONG _ulVer; // Store version
  201. BOOL _fIsReadOnly;
  202. BOOL _fFavorReadAhead;
  203. ULONG _cMegToLeaveOnDisk;
  204. CDriveInfo _driveInfo;
  205. };