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.

307 lines
8.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 2002.
  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 BOOL SupportsShrinkFromFront() const
  151. { return _fSupportsShrinkFromFront; }
  152. void RemovePropStore( WORKID wid,
  153. DWORD dwStoreLevel = PRIMARY_STORE );
  154. void RemoveSecStore( WORKID wid );
  155. static void EnumerateFilesInDir( WCHAR const * pwszDirectory,
  156. CEnumString & strEnum );
  157. static BOOL CheckHasIndexTable( WCHAR const * pwszDir );
  158. static BOOL IsValidFile( WCHAR const * pwszPath );
  159. static UINT DetermineDriveType( WCHAR const * pwszPath );
  160. //
  161. // Lists the filenames of property store related files
  162. //
  163. void ListPropStoreFileNames( CEnumString & enumStr, WORKID wid,
  164. DWORD dwStoreLevel = PRIMARY_STORE);
  165. void ListSecStoreFileNames( CEnumString & enumStr, WORKID wid );
  166. // get the storage version
  167. ULONG GetStorageVersion() const { return _ulVer; }
  168. BOOL IsReadOnly() const { return _fIsReadOnly; }
  169. void SetReadOnly() { _fIsReadOnly = TRUE; }
  170. BOOL FavorReadAhead() const { return _fFavorReadAhead; }
  171. void SetFavorReadAhead( BOOL f ) { _fFavorReadAhead = f; }
  172. private:
  173. PMmStream* QueryNewDirStream ( WORKID iid );
  174. PMmStream* QueryExistingDirStream ( WORKID iid, BOOL fWrite = FALSE );
  175. PMmStream* QueryStream ( WCHAR const * wcsFileName );
  176. enum EPathType
  177. {
  178. eIndexPath,
  179. eHashPath,
  180. ePrimaryPropPath,
  181. eSecondaryPropPath,
  182. eDirPath
  183. };
  184. void MakePath( EPathType type, WORKID iid, WCHAR * wcsIndex );
  185. void MakeLogPath( WCHAR *, WCHAR * );
  186. void FormRcovObjNames( WORKID wid, WCHAR * wcsPrefix,
  187. WCHAR * wcsHdr, WCHAR * wcsCopy1,
  188. WCHAR * wcsCopy2 );
  189. void DeleteFilesInCiDir( WCHAR const * pwszPattern );
  190. void DeleteUnUsedPersIndexes( BOOL fIsCi,
  191. CIndexIdList const & iidsInUse );
  192. BOOL IsInUse( WCHAR const * pwszFile, CIndexIdList const & iidsInUse ) const;
  193. static const WCHAR _aHexDigit[17];
  194. XPtrST<WCHAR> _xPath;
  195. WORKID _widFreshLog;
  196. ICiCAdviseStatus & _adviseStatus;
  197. BOOL _fCorruptionReported;
  198. BOOL _fSupportsShrinkFromFront;
  199. ULONG _ulVer; // Store version
  200. BOOL _fIsReadOnly;
  201. BOOL _fFavorReadAhead;
  202. ULONG _cMegToLeaveOnDisk;
  203. CDriveInfo _driveInfo;
  204. };