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.

487 lines
7.6 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. mft.hxx
  5. Abstract:
  6. This module contains the declarations for the NTFS_MASTER_FILE_TABLE
  7. class. The MFT is the root of the file system
  8. Author:
  9. Bill McJohn (billmc) 13-June-91
  10. Environment:
  11. ULIB, User Mode
  12. --*/
  13. #if !defined( _NTFS_MASTER_FILE_TABLE_DEFN_ )
  14. #define _NTFS_MASTER_FILE_TABLE_DEFN_
  15. #include "ntfsbit.hxx"
  16. DECLARE_CLASS( NTFS_ATTRIBUTE );
  17. DECLARE_CLASS( NTFS_UPCASE_TABLE );
  18. class NTFS_MASTER_FILE_TABLE : public OBJECT {
  19. public:
  20. DECLARE_CONSTRUCTOR( NTFS_MASTER_FILE_TABLE );
  21. VIRTUAL
  22. ~NTFS_MASTER_FILE_TABLE(
  23. );
  24. NONVIRTUAL
  25. BOOLEAN
  26. Initialize(
  27. IN OUT PNTFS_ATTRIBUTE DataAttribute,
  28. IN OUT PNTFS_BITMAP MftBitmap,
  29. IN OUT PNTFS_BITMAP VolumeBitmap OPTIONAL,
  30. IN PNTFS_UPCASE_TABLE UpcaseTable OPTIONAL,
  31. IN ULONG ClusterFactor,
  32. IN ULONG FrsSize,
  33. IN ULONG SectorSize,
  34. IN BIG_INT VolumeSectors,
  35. IN BOOLEAN ReadOnly DEFAULT FALSE
  36. );
  37. NONVIRTUAL
  38. UNTFS_EXPORT
  39. BOOLEAN
  40. AllocateFileRecordSegment(
  41. OUT PVCN FileNumber,
  42. IN BOOLEAN IsMft
  43. );
  44. NONVIRTUAL
  45. BOOLEAN
  46. FreeFileRecordSegment(
  47. IN VCN SegmentToFree
  48. );
  49. NONVIRTUAL
  50. UNTFS_EXPORT
  51. BOOLEAN
  52. Extend(
  53. IN ULONG NumberOfSegmentsToAdd
  54. );
  55. NONVIRTUAL
  56. PNTFS_ATTRIBUTE
  57. GetDataAttribute(
  58. );
  59. NONVIRTUAL
  60. PNTFS_BITMAP
  61. GetMftBitmap(
  62. );
  63. NONVIRTUAL
  64. PNTFS_BITMAP
  65. GetVolumeBitmap(
  66. );
  67. NONVIRTUAL
  68. VOID
  69. EnableMethods(
  70. );
  71. NONVIRTUAL
  72. VOID
  73. DisableMethods(
  74. );
  75. NONVIRTUAL
  76. BOOLEAN
  77. AreMethodsEnabled(
  78. ) CONST;
  79. NONVIRTUAL
  80. ULONG
  81. QueryClusterFactor(
  82. ) CONST;
  83. NONVIRTUAL
  84. ULONG
  85. QueryFrsSize(
  86. ) CONST;
  87. NONVIRTUAL
  88. BIG_INT
  89. QueryVolumeSectors(
  90. ) CONST;
  91. NONVIRTUAL
  92. ULONG
  93. QuerySectorSize(
  94. ) CONST;
  95. NONVIRTUAL
  96. PNTFS_UPCASE_TABLE
  97. GetUpcaseTable(
  98. );
  99. NONVIRTUAL
  100. VOID
  101. SetUpcaseTable(
  102. IN PNTFS_UPCASE_TABLE UpcaseTable
  103. );
  104. NONVIRTUAL
  105. BIG_INT
  106. QueryFrsCount(
  107. );
  108. private:
  109. NONVIRTUAL
  110. VOID
  111. Construct(
  112. );
  113. NONVIRTUAL
  114. VOID
  115. Destroy(
  116. );
  117. PNTFS_ATTRIBUTE _DataAttribute;
  118. PNTFS_BITMAP _MftBitmap;
  119. PNTFS_BITMAP _VolumeBitmap;
  120. PNTFS_UPCASE_TABLE _UpcaseTable;
  121. ULONG _ClusterFactor;
  122. ULONG _BytesPerFrs;
  123. BOOLEAN _MethodsEnabled;
  124. BOOLEAN _ReadOnly;
  125. BIG_INT _VolumeSectors;
  126. ULONG _SectorSize;
  127. };
  128. INLINE
  129. BOOLEAN
  130. NTFS_MASTER_FILE_TABLE::FreeFileRecordSegment(
  131. IN VCN SegmentToFree
  132. )
  133. /*++
  134. Routine Description:
  135. Free a File Record Segment in the Master File Table.
  136. Arguments:
  137. SegmentToFree -- supplies the virtual cluster number withing
  138. the Master File Table of the segment to be
  139. freed.
  140. Return Value:
  141. TRUE upon successful completion.
  142. --*/
  143. {
  144. DebugAssert(_MftBitmap);
  145. return _MethodsEnabled ?
  146. (_MftBitmap->SetFree(SegmentToFree, 1), TRUE) : FALSE;
  147. }
  148. INLINE
  149. PNTFS_ATTRIBUTE
  150. NTFS_MASTER_FILE_TABLE::GetDataAttribute(
  151. )
  152. /*++
  153. Routine Description:
  154. This routine computes the MFT's $DATA attribute.
  155. Arguments:
  156. None.
  157. Return Value:
  158. The data attribute for this class.
  159. --*/
  160. {
  161. return _MethodsEnabled ? _DataAttribute : NULL;
  162. }
  163. INLINE
  164. PNTFS_BITMAP
  165. NTFS_MASTER_FILE_TABLE::GetMftBitmap(
  166. )
  167. /*++
  168. Routine Description:
  169. This routine computes the MFT's $BITMAP attribute.
  170. Arguments:
  171. None.
  172. Return Value:
  173. The mft bitmap.
  174. --*/
  175. {
  176. return _MethodsEnabled ? _MftBitmap : NULL;
  177. }
  178. INLINE
  179. PNTFS_BITMAP
  180. NTFS_MASTER_FILE_TABLE::GetVolumeBitmap(
  181. )
  182. /*++
  183. Routine Description:
  184. This routine return the volume bitmap
  185. Arguments:
  186. None.
  187. Return Value:
  188. The volume bitmap.
  189. --*/
  190. {
  191. return _MethodsEnabled ? _VolumeBitmap : NULL;
  192. }
  193. INLINE
  194. VOID
  195. NTFS_MASTER_FILE_TABLE::EnableMethods(
  196. )
  197. /*++
  198. Routine Description:
  199. This method enables the methods provided by this class.
  200. This method and its complement allow the user of this class to declare
  201. when the passed in data attribute and mft bitmap are good enough to
  202. use.
  203. After the class is initialized, all of the methods are enabled.
  204. Arguments:
  205. None.
  206. Return Value:
  207. None.
  208. --*/
  209. {
  210. _MethodsEnabled = TRUE;
  211. }
  212. INLINE
  213. VOID
  214. NTFS_MASTER_FILE_TABLE::DisableMethods(
  215. )
  216. /*++
  217. Routine Description:
  218. This method disables the methods provided by this class.
  219. This method and its complement allow the user of this class to declare
  220. when the passed in data attribute and mft bitmap are good enough to
  221. use.
  222. After the class is initialized, all of the methods are enabled.
  223. Arguments:
  224. None.
  225. Return Value:
  226. None.
  227. --*/
  228. {
  229. _MethodsEnabled = FALSE;
  230. }
  231. INLINE
  232. BOOLEAN
  233. NTFS_MASTER_FILE_TABLE::AreMethodsEnabled(
  234. ) CONST
  235. /*++
  236. Routine Description:
  237. This method computes whether or not the methods are enabled.
  238. Arguments:
  239. None.
  240. Return Value:
  241. FALSE - The methods are not enabled.
  242. TRUE - The methods are enabled.
  243. --*/
  244. {
  245. return _MethodsEnabled;
  246. }
  247. INLINE
  248. ULONG
  249. NTFS_MASTER_FILE_TABLE::QueryClusterFactor(
  250. ) CONST
  251. /*++
  252. Routine Description:
  253. This routine computes the number of sectors per cluster.
  254. Arguments:
  255. None.
  256. Return Value:
  257. The number of sectors per cluster.
  258. --*/
  259. {
  260. return _ClusterFactor;
  261. }
  262. INLINE
  263. BIG_INT
  264. NTFS_MASTER_FILE_TABLE::QueryVolumeSectors(
  265. ) CONST
  266. /*++
  267. Routine Description:
  268. This routine returns the number of sectors on the volume as recorded in
  269. the boot sector.
  270. Arguments:
  271. None.
  272. Return Value:
  273. The number of volume sectors.
  274. --*/
  275. {
  276. return _VolumeSectors;
  277. }
  278. INLINE
  279. ULONG
  280. NTFS_MASTER_FILE_TABLE::QueryFrsSize(
  281. ) CONST
  282. /*++
  283. Routine Description:
  284. This routine computes the number of clusters per FRS.
  285. Arguments:
  286. None.
  287. Return Value:
  288. The number of clusters per FRS.
  289. --*/
  290. {
  291. return _BytesPerFrs;
  292. }
  293. INLINE
  294. PNTFS_UPCASE_TABLE
  295. NTFS_MASTER_FILE_TABLE::GetUpcaseTable(
  296. )
  297. /*++
  298. Routine Description:
  299. This method fetches the upcase table for the volume.
  300. Arguments:
  301. None.
  302. Return Value:
  303. The volume upcase table.
  304. --*/
  305. {
  306. return _UpcaseTable;
  307. }
  308. INLINE
  309. VOID
  310. NTFS_MASTER_FILE_TABLE::SetUpcaseTable(
  311. IN PNTFS_UPCASE_TABLE UpcaseTable
  312. )
  313. /*++
  314. Routine Description:
  315. This method sets the upcase table for the volume.
  316. Arguments:
  317. UpcaseTable -- Supplies the volume upcase table.
  318. Return Value:
  319. None.
  320. --*/
  321. {
  322. _UpcaseTable = UpcaseTable;
  323. }
  324. INLINE
  325. ULONG
  326. NTFS_MASTER_FILE_TABLE::QuerySectorSize(
  327. ) CONST
  328. {
  329. return _SectorSize;
  330. }
  331. #endif