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.

383 lines
6.7 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. indxbuff.hxx
  5. Abstract:
  6. this module contains the declarations for the NTFS_INDEX_BUFFER
  7. class, which models index buffers in NTFS index trees.
  8. Author:
  9. Bill McJohn (billmc) 02-Sept-1991
  10. Environment:
  11. ULIB, User Mode
  12. --*/
  13. #if !defined( _NTFS_INDEX_BUFFER_DEFN_ )
  14. #define _NTFS_INDEX_BUFFER_DEFN_
  15. #include "hmem.hxx"
  16. #include "indxtree.hxx"
  17. DECLARE_CLASS( LOG_IO_DP_DRIVE );
  18. DECLARE_CLASS( NTFS_ATTRIBUTE );
  19. DECLARE_CLASS( NTFS_INDEX_TREE );
  20. DECLARE_CLASS( NTFS_UPCASE_TABLE );
  21. class NTFS_INDEX_BUFFER : public OBJECT {
  22. FRIEND
  23. BOOLEAN
  24. NTFS_INDEX_TREE::InsertIntoBuffer(
  25. PNTFS_INDEX_BUFFER TargetBuffer,
  26. PINTSTACK ParentTrail,
  27. PCINDEX_ENTRY NewEntry,
  28. PINDEX_ENTRY InsertionPoint
  29. );
  30. FRIEND
  31. BOOLEAN
  32. NTFS_INDEX_TREE::InsertIntoRoot(
  33. PCINDEX_ENTRY NewEntry,
  34. PINDEX_ENTRY InsertionPoint
  35. );
  36. FRIEND
  37. BOOLEAN
  38. NTFS_INDEX_TREE::GetNextParent(
  39. );
  40. public:
  41. DECLARE_CONSTRUCTOR( NTFS_INDEX_BUFFER );
  42. VIRTUAL
  43. ~NTFS_INDEX_BUFFER(
  44. );
  45. NONVIRTUAL
  46. BOOLEAN
  47. Initialize(
  48. IN PCLOG_IO_DP_DRIVE Drive,
  49. IN VCN ThisBufferVcn,
  50. IN ULONG ClusterSize,
  51. IN ULONG ClustersPerBuffer,
  52. IN ULONG BufferSize,
  53. IN ULONG CollationRule,
  54. IN PNTFS_UPCASE_TABLE UpcaseTable
  55. );
  56. NONVIRTUAL
  57. VOID
  58. Create(
  59. IN BOOLEAN IsLeaf,
  60. IN VCN EndEntryDownpointer
  61. );
  62. NONVIRTUAL
  63. BOOLEAN
  64. Read(
  65. IN OUT PNTFS_ATTRIBUTE AllocationAttribute
  66. );
  67. NONVIRTUAL
  68. BOOLEAN
  69. Write(
  70. IN OUT PNTFS_ATTRIBUTE AllocationAttribute
  71. );
  72. NONVIRTUAL
  73. BOOLEAN
  74. FindEntry(
  75. IN PCINDEX_ENTRY SearchEntry,
  76. IN OUT PULONG Ordinal,
  77. OUT PINDEX_ENTRY* EntryFound
  78. );
  79. NONVIRTUAL
  80. BOOLEAN
  81. InsertEntry(
  82. IN PCINDEX_ENTRY NewEntry,
  83. IN PINDEX_ENTRY InsertPoint DEFAULT NULL
  84. );
  85. NONVIRTUAL
  86. VOID
  87. RemoveEntry(
  88. IN PINDEX_ENTRY EntryToRemove
  89. );
  90. NONVIRTUAL
  91. PINDEX_ENTRY
  92. GetFirstEntry(
  93. );
  94. NONVIRTUAL
  95. BOOLEAN
  96. IsLeaf(
  97. ) CONST;
  98. NONVIRTUAL
  99. VCN
  100. QueryVcn(
  101. ) CONST;
  102. NONVIRTUAL
  103. ULONG
  104. QuerySize(
  105. ) CONST;
  106. NONVIRTUAL
  107. PINDEX_ALLOCATION_BUFFER
  108. GetData(
  109. );
  110. NONVIRTUAL
  111. PINDEX_ENTRY
  112. FindSplitPoint(
  113. );
  114. NONVIRTUAL
  115. BOOLEAN
  116. IsEmpty(
  117. );
  118. NONVIRTUAL
  119. BOOLEAN
  120. SetLsn(
  121. IN BIG_INT NewLsn
  122. );
  123. NONVIRTUAL
  124. LSN
  125. QueryLsn(
  126. ) CONST;
  127. BOOLEAN
  128. Copy(
  129. IN PNTFS_INDEX_BUFFER p,
  130. IN PCLOG_IO_DP_DRIVE Drive
  131. );
  132. private:
  133. NONVIRTUAL
  134. VOID
  135. Construct(
  136. );
  137. NONVIRTUAL
  138. VOID
  139. Destroy(
  140. );
  141. NONVIRTUAL
  142. VOID
  143. InsertClump(
  144. IN ULONG LengthOfClump,
  145. IN PCVOID Clump
  146. );
  147. NONVIRTUAL
  148. VOID
  149. RemoveClump(
  150. IN ULONG LengthOfClump
  151. );
  152. VCN _ThisBufferVcn;
  153. ULONG _ClusterSize;
  154. ULONG _ClustersPerBuffer;
  155. ULONG _BufferSize;
  156. COLLATION_RULE _CollationRule;
  157. PNTFS_UPCASE_TABLE _UpcaseTable;
  158. HMEM _Mem;
  159. PINDEX_ALLOCATION_BUFFER _Data;
  160. };
  161. INLINE
  162. PINDEX_ENTRY
  163. NTFS_INDEX_BUFFER::GetFirstEntry(
  164. )
  165. /*++
  166. Routine Description:
  167. This method returns a pointer to the first entry in the index buffer.
  168. Arguments:
  169. None.
  170. Return Value:
  171. A pointer to the first index entry in the buffer.
  172. --*/
  173. {
  174. return( (PINDEX_ENTRY)( (PBYTE)&(_Data->IndexHeader) +
  175. _Data->IndexHeader.FirstIndexEntry ) );
  176. }
  177. INLINE
  178. BOOLEAN
  179. NTFS_INDEX_BUFFER::IsLeaf(
  180. ) CONST
  181. /*++
  182. Routine Description:
  183. This method determines whether this index buffer is a leaf.
  184. Arguments:
  185. None.
  186. Return Value:
  187. TRUE if this buffer is a leaf; FALSE otherwise.
  188. --*/
  189. {
  190. return( !(_Data->IndexHeader.Flags & INDEX_NODE) );
  191. }
  192. INLINE
  193. VCN
  194. NTFS_INDEX_BUFFER::QueryVcn(
  195. ) CONST
  196. /*++
  197. Routine Description:
  198. This method returns the VCN within the index allocation attribute
  199. of this index buffer.
  200. Arguments:
  201. None.
  202. Return Value:
  203. The VCN within the index allocation attribute of this index buffer.
  204. --*/
  205. {
  206. return _ThisBufferVcn;
  207. }
  208. INLINE
  209. ULONG
  210. NTFS_INDEX_BUFFER::QuerySize(
  211. ) CONST
  212. /*++
  213. Routine Description:
  214. This method returns the size of this buffer. Note that it includes
  215. any free space in the buffer, and that all buffers in a given tree
  216. will have the same size.
  217. Arguments:
  218. None.
  219. Return Value:
  220. The size of the buffer.
  221. --*/
  222. {
  223. return _BufferSize;
  224. }
  225. INLINE
  226. PINDEX_ALLOCATION_BUFFER
  227. NTFS_INDEX_BUFFER::GetData(
  228. )
  229. /*++
  230. Routine Description:
  231. This method returns the index buffer's data buffer. It's a back
  232. door that allows the index tree to read and write the index buffer.
  233. Arguments:
  234. None.
  235. Return Value:
  236. The index buffer's data buffer.
  237. --*/
  238. {
  239. return _Data;
  240. }
  241. INLINE
  242. BOOLEAN
  243. NTFS_INDEX_BUFFER::SetLsn(
  244. IN BIG_INT NewLsn
  245. )
  246. /*++
  247. Routine Description:
  248. This method sets the Log Sequence Number in the index buffer.
  249. Arguments:
  250. NewLsn -- Supplies the new LSN
  251. Return Value:
  252. Always returns TRUE.
  253. --*/
  254. {
  255. _Data->Lsn = NewLsn.GetLargeInteger();
  256. return TRUE;
  257. }
  258. INLINE
  259. LSN
  260. NTFS_INDEX_BUFFER::QueryLsn(
  261. ) CONST
  262. /*++
  263. Routine Description:
  264. This method sets the Log Sequence Number in the index buffer.
  265. Arguments:
  266. NewLsn -- Supplies the new LSN
  267. Return Value:
  268. Always returns TRUE.
  269. --*/
  270. {
  271. return _Data->Lsn;
  272. }
  273. #endif