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.

265 lines
4.8 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. mftfile.hxx
  5. Abstract:
  6. This module contains the declarations for the NTFS_MFT_FILE
  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_MFT_FILE_DEFN_ )
  14. #define _NTFS_MFT_FILE_DEFN_
  15. #include "hmem.hxx"
  16. #include "bitfrs.hxx"
  17. #include "clusrun.hxx"
  18. #include "frs.hxx"
  19. #include "attrib.hxx"
  20. #include "ntfsbit.hxx"
  21. #include "mft.hxx"
  22. #include "mftref.hxx"
  23. DECLARE_CLASS( NTFS_MFT_FILE );
  24. class NTFS_MFT_FILE : public NTFS_FILE_RECORD_SEGMENT {
  25. public:
  26. UNTFS_EXPORT
  27. DECLARE_CONSTRUCTOR( NTFS_MFT_FILE );
  28. VIRTUAL
  29. UNTFS_EXPORT
  30. ~NTFS_MFT_FILE(
  31. );
  32. NONVIRTUAL
  33. UNTFS_EXPORT
  34. BOOLEAN
  35. Initialize(
  36. IN OUT PLOG_IO_DP_DRIVE Drive,
  37. IN LCN Lcn,
  38. IN ULONG ClusterFactor,
  39. IN ULONG FrsSize,
  40. IN BIG_INT VolumeSectors,
  41. IN OUT PNTFS_BITMAP VolumeBitmap OPTIONAL,
  42. IN PNTFS_UPCASE_TABLE UpcaseTable OPTIONAL
  43. );
  44. NONVIRTUAL
  45. BOOLEAN
  46. Create(
  47. IN ULONG InitialSize,
  48. IN PCSTANDARD_INFORMATION StandardInformation,
  49. IN OUT PNTFS_BITMAP VolumeBitmap
  50. );
  51. NONVIRTUAL
  52. UNTFS_EXPORT
  53. BOOLEAN
  54. Read(
  55. );
  56. NONVIRTUAL
  57. BOOLEAN
  58. AllocateFileRecordSegment(
  59. OUT PVCN FileNumber,
  60. IN BOOLEAN IsMft
  61. );
  62. NONVIRTUAL
  63. BOOLEAN
  64. FreeFileRecordSegment(
  65. IN VCN SegmentToFree
  66. );
  67. NONVIRTUAL
  68. BOOLEAN
  69. Extend(
  70. IN ULONG NumberOfSegmentsToAdd
  71. );
  72. NONVIRTUAL
  73. UNTFS_EXPORT
  74. BOOLEAN
  75. Flush(
  76. );
  77. NONVIRTUAL
  78. PNTFS_MASTER_FILE_TABLE
  79. GetMasterFileTable(
  80. );
  81. private:
  82. NONVIRTUAL
  83. VOID
  84. Construct(
  85. );
  86. NONVIRTUAL
  87. VOID
  88. Destroy(
  89. );
  90. NONVIRTUAL
  91. BOOLEAN
  92. SetUpMft(
  93. );
  94. NONVIRTUAL
  95. BOOLEAN
  96. CheckMirrorSize(
  97. IN OUT PNTFS_ATTRIBUTE MirrorDataAttribute,
  98. IN BOOLEAN Fix,
  99. IN OUT PNTFS_BITMAP VolumeBitmap,
  100. OUT PLCN FirstLcn
  101. );
  102. NONVIRTUAL
  103. BOOLEAN
  104. WriteMirror(
  105. IN OUT PNTFS_ATTRIBUTE MirrorDataAttribute
  106. );
  107. LCN _FirstLcn;
  108. NTFS_ATTRIBUTE _DataAttribute;
  109. NTFS_BITMAP _MftBitmap;
  110. NTFS_MASTER_FILE_TABLE _Mft;
  111. PNTFS_BITMAP _VolumeBitmap;
  112. HMEM _MirrorMem;
  113. NTFS_CLUSTER_RUN _MirrorClusterRun;
  114. };
  115. INLINE
  116. BOOLEAN
  117. NTFS_MFT_FILE::AllocateFileRecordSegment(
  118. OUT PVCN FileNumber,
  119. IN BOOLEAN IsMft
  120. )
  121. /*++
  122. Routine Description:
  123. Allocate a File Record Segment from the Master File Table.
  124. Arguments:
  125. FileNumber -- receives the file number of the allocated segment.
  126. IsMft -- supplies a flag which indicates, if TRUE, that
  127. the allocation is being made on behalf of the
  128. MFT itself.
  129. Return Value:
  130. TRUE upon successful completion.
  131. --*/
  132. {
  133. return _Mft.AllocateFileRecordSegment(FileNumber, IsMft);
  134. }
  135. INLINE
  136. BOOLEAN
  137. NTFS_MFT_FILE::FreeFileRecordSegment(
  138. IN VCN SegmentToFree
  139. )
  140. /*++
  141. Routine Description:
  142. Free a File Record Segment in the Master File Table.
  143. Arguments:
  144. SegmentToFree -- supplies the virtual cluster number withing
  145. the Master File Table of the segment to be
  146. freed.
  147. Return Value:
  148. TRUE upon successful completion.
  149. --*/
  150. {
  151. return _Mft.FreeFileRecordSegment(SegmentToFree);
  152. }
  153. INLINE
  154. BOOLEAN
  155. NTFS_MFT_FILE::Extend(
  156. IN ULONG NumberOfSegmentsToAdd
  157. )
  158. /*++
  159. Routine Description:
  160. This method grows the Master File Table. It increases the
  161. size of the Data attribute (to hold more File Record Segments)
  162. and increases the size of the MFT Bitmap to match.
  163. Arguments:
  164. NumberOfSegmentsToAdd -- supplies the number of new File Record
  165. Segments to add to the Master File Table.
  166. Return Value:
  167. TRUE upon successful completion.
  168. --*/
  169. {
  170. return _Mft.Extend(NumberOfSegmentsToAdd);
  171. }
  172. INLINE
  173. PNTFS_MASTER_FILE_TABLE
  174. NTFS_MFT_FILE::GetMasterFileTable(
  175. )
  176. /*++
  177. Routine Description:
  178. This routine returns a pointer to master file table.
  179. Arguments:
  180. None.
  181. Return Value:
  182. A pointer to the master file table.
  183. --*/
  184. {
  185. return _Mft.AreMethodsEnabled() ? &_Mft : NULL;
  186. }
  187. #endif