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.

240 lines
6.8 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 2002.
  5. //
  6. // File: PSTORE.HXX
  7. //
  8. // Contents: Physical storage + transactions
  9. //
  10. // Classes: CiStorage
  11. //
  12. // History: 13-Jul-93 BartoszM Created
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. class PMmStream;
  17. class PDirectory;
  18. class PIndexTable;
  19. class CTransaction;
  20. class CStorageObject;
  21. class CStorageTransaction;
  22. class CFreshTableIter;
  23. class CPersFresh;
  24. class CFresh;
  25. class PRcovStorageObj;
  26. class PStorage;
  27. enum IndexType;
  28. typedef CDynArrayInPlace<INDEXID> CIndexIdList;
  29. //+---------------------------------------------------------------------------
  30. //
  31. // Class: PStorageObject
  32. //
  33. // Purpose: Encapsulate file control block
  34. //
  35. // History: 24-Aug-93 BartoszM Created
  36. //
  37. //----------------------------------------------------------------------------
  38. class PStorageObject
  39. {
  40. public:
  41. PStorageObject();
  42. virtual ~PStorageObject() {}
  43. virtual void Close() = 0;
  44. };
  45. //+---------------------------------------------------------------------------
  46. //
  47. // Class: SStorageObject
  48. //
  49. // Purpose: Smart pointer to storage object
  50. //
  51. // History: 24-Aug-93 BartoszM Created
  52. //
  53. //----------------------------------------------------------------------------
  54. class SStorageObject
  55. {
  56. public:
  57. SStorageObject ( PStorageObject* pObj );
  58. ~SStorageObject();
  59. PStorageObject& GetObj() { return *_pObj; }
  60. PStorageObject* operator->() { return _pObj; }
  61. PStorageObject * Acquire()
  62. { PStorageObject * temp = _pObj; _pObj = NULL; return temp; }
  63. private:
  64. PStorageObject* _pObj;
  65. };
  66. //+---------------------------------------------------------------------------
  67. //
  68. // Class: SStorage
  69. //
  70. // Purpose: Smart pointer to storage
  71. //
  72. // History: 29-Aug-94 DwightKr Created
  73. //
  74. //----------------------------------------------------------------------------
  75. class SStorage
  76. {
  77. public:
  78. SStorage ( PStorage* pObj );
  79. ~SStorage();
  80. PStorage & GetObj() { return *_pObj; }
  81. PStorage * operator->() { return _pObj; }
  82. PStorage * Acquire()
  83. { PStorage * temp = _pObj; _pObj = NULL; return temp; }
  84. private:
  85. PStorage * _pObj;
  86. };
  87. //+-------------------------------------------------------------------------
  88. //
  89. // Class: CiStorage
  90. //
  91. // Purpose: Encapsulates a physical storage
  92. //
  93. // Interface:
  94. //
  95. // History: 13-Jul-93 BartoszM Created
  96. // 21-Jan-94 SrikantS Added Mutex Sem
  97. // 19-Nov-93 DwightKr Added QueryFreshSnapStream() &
  98. // QueryFreshSnapLog() methods
  99. // 21-Jan-94 SrikantS Added Mutex Sem
  100. // 03-Mar-98 KitmanH Added IsReadOnly() pure virtual method
  101. // 17-Mar-98 KitmanH Added QueryStringHash(),
  102. // QueryFileIdMap() & QueryDeletionLog()
  103. // pure virtual methods
  104. //
  105. //--------------------------------------------------------------------------
  106. class PStorage
  107. {
  108. public:
  109. enum EOpenMode { eCreate, eOpenForWrite, eOpenForRead };
  110. enum EBitOperation{ eSetBits, eClearBits };
  111. enum EDefaultStrmType { eRcovHdr, eNonSparseIndex, eSparseIndex };
  112. enum EChangeLogType { ePrimChangeLog, eSecChangeLog };
  113. virtual ~PStorage() {}
  114. virtual PIndexTable* QueryIndexTable ( CTransaction& xact ) = 0;
  115. virtual PRcovStorageObj * QueryIdxTableObject() = 0;
  116. virtual WORKID CreateObjectId (INDEXID iid, EDefaultStrmType eType ) = 0;
  117. virtual PStorageObject* QueryObject( WORKID objectId ) = 0;
  118. virtual void DeleteObject ( WORKID objectId ) = 0;
  119. virtual void EmptyIndexList () = 0;
  120. virtual PMmStream* QueryNewIndexStream ( PStorageObject& obj, BOOL isSparse=FALSE )=0;
  121. virtual PMmStream* QueryExistingIndexStream ( PStorageObject& obj,
  122. EOpenMode mode ) = 0;
  123. virtual PMmStream* DupExistingIndexStream( PStorageObject& obj,
  124. PMmStream & mmStream,
  125. EOpenMode mode ) = 0;
  126. virtual PMmStream* QueryNewHashStream ( PStorageObject& obj )=0;
  127. virtual PMmStream* QueryExistingHashStream ( PStorageObject& obj,
  128. EOpenMode mode ) = 0;
  129. virtual PMmStream* QueryStringHash() = 0;
  130. virtual PMmStream* QueryFileIdMap() = 0;
  131. virtual PMmStream* QueryDeletionLog() = 0;
  132. virtual PDirectory* QueryNewDirectory ( PStorageObject& obj )=0;
  133. virtual PDirectory* QueryExistingDirectory ( PStorageObject& obj,
  134. EOpenMode mode ) = 0;
  135. virtual BOOL RemoveObject ( WORKID iid ) = 0;
  136. virtual BOOL RemoveMMLog( WORKID objectId ) = 0;
  137. virtual void CommitTransaction() = 0;
  138. virtual void AbortTransaction() = 0;
  139. virtual void CheckPoint() = 0;
  140. virtual WORKID GetSpecialItObjectId( IndexType it ) const = 0;
  141. virtual void SetSpecialItObjectId( IndexType it, WORKID wid ) = 0;
  142. virtual WORKID GetNewObjectIdForFreshLog() = 0;
  143. virtual BOOL RemoveFreshLog( WORKID objectId ) = 0;
  144. virtual void InitRcovObj( WORKID wid, BOOL fAtomStrmOnly = FALSE ) = 0;
  145. virtual PRcovStorageObj * QueryRecoverableLog(WORKID) = 0;
  146. virtual PRcovStorageObj * QueryChangeLog(WORKID, EChangeLogType) = 0;
  147. virtual PRcovStorageObj * QueryFreshLog( WORKID wid ) = 0;
  148. virtual PRcovStorageObj * QueryMMergeLog(WORKID) = 0;
  149. //
  150. // used for testing recoverable storage objects.
  151. //
  152. virtual PRcovStorageObj * QueryTestLog() = 0;
  153. //
  154. // Used for double buffering in OFS.
  155. //
  156. virtual void GetDiskSpace( __int64 & diskTotal, __int64 & diskRemaining ) = 0;
  157. virtual const WCHAR * GetVolumeName() = 0;
  158. virtual USN GetNextUsn() = 0;
  159. virtual BOOL IsVolumeClean() = 0;
  160. virtual void ReportCorruptComponent( WCHAR const * pwszString ) = 0;
  161. virtual void DeleteAllFiles() = 0;
  162. virtual void DeleteAllCiFiles() = 0;
  163. virtual void DeleteAllPersIndexes() = 0;
  164. virtual void DeleteUnUsedPersIndexes( CIndexIdList const & iidsInUse ) = 0;
  165. virtual void DeleteAllFsCiFiles() = 0;
  166. //
  167. // Get the storage's version stamp.
  168. //
  169. virtual ULONG GetStorageVersion() const = 0;
  170. virtual BOOL SupportsShrinkFromFront() const { return FALSE; }
  171. virtual BOOL IsReadOnly() const = 0;
  172. virtual BOOL FavorReadAhead() const = 0;
  173. virtual void SetFavorReadAhead( BOOL f ) = 0;
  174. };