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.

366 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. indxroot.hxx
  5. Abstract:
  6. this module contains the declarations for the NTFS_INDEX_ROOT
  7. class, which models the root of an NTFS index
  8. Author:
  9. Bill McJohn (billmc) 06-Sept-1991
  10. Environment:
  11. ULIB, User Mode
  12. --*/
  13. #if !defined( _NTFS_INDEX_ROOT_DEFN_ )
  14. #define _NTFS_INDEX_ROOT_DEFN_
  15. DECLARE_CLASS( NTFS_ATTRIBUTE );
  16. DECLARE_CLASS( NTFS_UPCASE_TABLE );
  17. // If the index buffer size is smaller than the cluster size, we'll
  18. // divide the index buffers into 512-byte blocks, and the ClustersPer-
  19. // IndexBuffer item will actually be blocks per index buffer.
  20. //
  21. const ULONG NTFS_INDEX_BLOCK_SIZE = 512;
  22. class NTFS_INDEX_ROOT : public OBJECT {
  23. public:
  24. DECLARE_CONSTRUCTOR( NTFS_INDEX_ROOT );
  25. VIRTUAL
  26. ~NTFS_INDEX_ROOT(
  27. );
  28. NONVIRTUAL
  29. BOOLEAN
  30. Initialize(
  31. IN PNTFS_ATTRIBUTE RootAttribute,
  32. IN PNTFS_UPCASE_TABLE UpcaseTable,
  33. IN ULONG MaximumSize
  34. );
  35. NONVIRTUAL
  36. BOOLEAN
  37. Initialize(
  38. IN ATTRIBUTE_TYPE_CODE IndexedAttributeType,
  39. IN COLLATION_RULE CollationRule,
  40. IN PNTFS_UPCASE_TABLE UpcaseTable,
  41. IN ULONG ClustersPerBuffer,
  42. IN ULONG BytesPerBuffer,
  43. IN ULONG MaximumRootSize
  44. );
  45. NONVIRTUAL
  46. BOOLEAN
  47. FindEntry(
  48. IN PCINDEX_ENTRY SearchEntry,
  49. IN OUT PULONG Ordinal,
  50. OUT PINDEX_ENTRY* EntryFound
  51. );
  52. NONVIRTUAL
  53. BOOLEAN
  54. InsertEntry(
  55. IN PCINDEX_ENTRY NewEntry,
  56. IN PINDEX_ENTRY InsertPoint DEFAULT NULL
  57. );
  58. NONVIRTUAL
  59. VOID
  60. RemoveEntry(
  61. PINDEX_ENTRY EntryToRemove
  62. );
  63. NONVIRTUAL
  64. PINDEX_ENTRY
  65. GetFirstEntry(
  66. );
  67. NONVIRTUAL
  68. VOID
  69. Recreate(
  70. IN BOOLEAN IsLeaf,
  71. IN VCN EndEntryDownpointer
  72. );
  73. NONVIRTUAL
  74. BOOLEAN
  75. Write(
  76. PNTFS_ATTRIBUTE RootAttribute
  77. );
  78. NONVIRTUAL
  79. ULONG
  80. QueryClustersPerBuffer(
  81. );
  82. NONVIRTUAL
  83. ULONG
  84. QueryBufferSize(
  85. );
  86. NONVIRTUAL
  87. ULONG
  88. QueryIndexedAttributeType(
  89. );
  90. NONVIRTUAL
  91. COLLATION_RULE
  92. QueryCollationRule(
  93. );
  94. NONVIRTUAL
  95. BOOLEAN
  96. IsLeaf(
  97. );
  98. NONVIRTUAL
  99. BOOLEAN
  100. IsModified(
  101. );
  102. private:
  103. NONVIRTUAL
  104. VOID
  105. Construct(
  106. );
  107. NONVIRTUAL
  108. VOID
  109. Destroy(
  110. );
  111. NONVIRTUAL
  112. VOID
  113. MarkModified(
  114. );
  115. ULONG _MaximumSize;
  116. ULONG _DataLength;
  117. PINDEX_ROOT _Data;
  118. PNTFS_UPCASE_TABLE _UpcaseTable;
  119. BOOLEAN _IsModified;
  120. };
  121. INLINE
  122. PINDEX_ENTRY
  123. NTFS_INDEX_ROOT::GetFirstEntry(
  124. )
  125. /*++
  126. Routine Description:
  127. This method returns a pointer to the first entry in the index root.
  128. Arguments:
  129. None.
  130. Return Value:
  131. A pointer to the first index entry in the root.
  132. --*/
  133. {
  134. return( (PINDEX_ENTRY)( (PBYTE)&(_Data->IndexHeader) +
  135. _Data->IndexHeader.FirstIndexEntry ) );
  136. }
  137. INLINE
  138. ULONG
  139. NTFS_INDEX_ROOT::QueryClustersPerBuffer(
  140. )
  141. /*++
  142. Routine Description:
  143. This method returns the number of clusters in each Index Allocation
  144. Buffer in this index.
  145. Arguments:
  146. None.
  147. Return Value:
  148. Clusters per Buffer.
  149. --*/
  150. {
  151. return _Data->ClustersPerIndexBuffer;
  152. }
  153. INLINE
  154. ULONG
  155. NTFS_INDEX_ROOT::QueryBufferSize(
  156. )
  157. /*++
  158. Routine Description:
  159. This method returns the number of bytes in each Index Allocation
  160. Buffer in this index.
  161. Arguments:
  162. None.
  163. Return Value:
  164. Bytes per Buffer.
  165. --*/
  166. {
  167. return _Data->BytesPerIndexBuffer;
  168. }
  169. INLINE
  170. ULONG
  171. NTFS_INDEX_ROOT::QueryIndexedAttributeType(
  172. )
  173. /*++
  174. Routine Description:
  175. This method returns the Attribute Type Code of the attribute
  176. which is indexed by this index.
  177. Arguments:
  178. None.
  179. Return Value:
  180. The attribute type code of the attributes in this index.
  181. --*/
  182. {
  183. return _Data->IndexedAttributeType;
  184. }
  185. INLINE
  186. COLLATION_RULE
  187. NTFS_INDEX_ROOT::QueryCollationRule(
  188. )
  189. /*++
  190. Routine Description:
  191. This method marks the index root as modified.
  192. Arguments:
  193. None.
  194. Return Value:
  195. None.
  196. --*/
  197. {
  198. return _Data->CollationRule;
  199. }
  200. INLINE
  201. BOOLEAN
  202. NTFS_INDEX_ROOT::IsLeaf(
  203. )
  204. /*++
  205. Routine Description:
  206. This method determines whether the Index Root is a leaf (ie. that
  207. the entries in the root do not have downpointers) or a node
  208. (ie. the entries have downpointers).
  209. Arguments:
  210. None.
  211. Return Value:
  212. TRUE if the root is a leaf; FALSE if it is a node.
  213. --*/
  214. {
  215. return( !(_Data->IndexHeader.Flags & INDEX_NODE) );
  216. }
  217. INLINE
  218. BOOLEAN
  219. NTFS_INDEX_ROOT::IsModified(
  220. )
  221. /*++
  222. Routine Description:
  223. This method indicates whether the index root has been modified
  224. since the last time it was read from or written to an $INDEX_ROOT
  225. attribute.
  226. Arguments:
  227. None.
  228. Return Value:
  229. TRUE if the index root has been modified; FALSE otherwise.
  230. --*/
  231. {
  232. return _IsModified;
  233. }
  234. INLINE
  235. VOID
  236. NTFS_INDEX_ROOT::MarkModified(
  237. )
  238. /*++
  239. Routine Description:
  240. This method marks the index root as modified.
  241. Arguments:
  242. None.
  243. Return Value:
  244. None.
  245. --*/
  246. {
  247. _IsModified = TRUE;
  248. }
  249. #endif