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.

367 lines
7.8 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. extents.hxx
  5. Abstract:
  6. This module contains the declarations for NTFS_EXTENT_LIST, which
  7. models a set of NTFS extents.
  8. An extent is a contiguous run of clusters; a non-resident
  9. attribute's value is made up of a list of extents. The
  10. NTFS_EXTENT_LIST object can be used to describe the disk space
  11. allocated to a non-resident attribute.
  12. This class also encapsulates the knowledge of mapping pairs
  13. and their compression, i.e. of the representation of extent
  14. lists in attribute records.
  15. Author:
  16. Bill McJohn (billmc) 17-June-91
  17. Matthew Bradburn (mattbr) 19-August-95
  18. Changed to use NTFS MCB package.
  19. Environment:
  20. ULIB, User Mode
  21. --*/
  22. #if !defined( _NTFS_EXTENT_LIST_DEFN_ )
  23. #define _NTFS_EXTENT_LIST_DEFN_
  24. DECLARE_CLASS( NTFS_BITMAP );
  25. DECLARE_CLASS( NTFS_EXTENT_LIST );
  26. DECLARE_CLASS( NTFS_EXTENT );
  27. typedef struct _MAPPING_PAIR {
  28. VCN NextVcn;
  29. LCN CurrentLcn;
  30. };
  31. DEFINE_TYPE( _MAPPING_PAIR, MAPPING_PAIR );
  32. class NTFS_EXTENT : public OBJECT {
  33. public:
  34. DECLARE_CONSTRUCTOR( NTFS_EXTENT );
  35. VCN Vcn;
  36. LCN Lcn;
  37. BIG_INT RunLength;
  38. };
  39. class NTFS_EXTENT_LIST : public OBJECT {
  40. public:
  41. UNTFS_EXPORT
  42. DECLARE_CONSTRUCTOR( NTFS_EXTENT_LIST );
  43. VIRTUAL
  44. UNTFS_EXPORT
  45. ~NTFS_EXTENT_LIST(
  46. );
  47. NONVIRTUAL
  48. UNTFS_EXPORT
  49. BOOLEAN
  50. Initialize(
  51. IN VCN LowestVcn,
  52. IN VCN NextVcn
  53. );
  54. NONVIRTUAL
  55. BOOLEAN
  56. Initialize(
  57. IN VCN StartingVcn,
  58. IN PCVOID CompressedMappingPairs,
  59. IN ULONG MappingPairsMaximumLength,
  60. OUT PBOOLEAN BadMappingPairs DEFAULT NULL
  61. );
  62. NONVIRTUAL
  63. BOOLEAN
  64. Initialize(
  65. IN PCNTFS_EXTENT_LIST ExtentsToCopy
  66. );
  67. FRIEND
  68. BOOLEAN
  69. Initialize(
  70. IN PCNTFS_EXTENT_LIST ExtentsToCopy
  71. );
  72. NONVIRTUAL
  73. BOOLEAN
  74. IsEmpty(
  75. ) CONST;
  76. NONVIRTUAL
  77. BOOLEAN
  78. IsSparse(
  79. ) CONST;
  80. NONVIRTUAL
  81. UNTFS_EXPORT
  82. ULONG
  83. QueryNumberOfExtents(
  84. ) CONST;
  85. NONVIRTUAL
  86. UNTFS_EXPORT
  87. BOOLEAN
  88. AddExtent(
  89. IN VCN Vcn,
  90. IN LCN Lcn,
  91. IN BIG_INT RunLength
  92. );
  93. NONVIRTUAL
  94. BOOLEAN
  95. AddExtents(
  96. IN VCN StartingVcn,
  97. IN PCVOID CompressedMappingPairs,
  98. IN ULONG MappingPairsMaximumLength,
  99. OUT PBOOLEAN BadMappingPairs DEFAULT NULL
  100. );
  101. NONVIRTUAL
  102. VOID
  103. DeleteExtent(
  104. IN ULONG ExtentNumber
  105. );
  106. NONVIRTUAL
  107. BOOLEAN
  108. Resize(
  109. IN BIG_INT NewSize,
  110. IN OUT PNTFS_BITMAP Bitmap
  111. );
  112. NONVIRTUAL
  113. BOOLEAN
  114. SetSparse(
  115. IN BIG_INT NewSize
  116. );
  117. NONVIRTUAL
  118. UNTFS_EXPORT
  119. BOOLEAN
  120. QueryExtent(
  121. IN ULONG ExtentNumber,
  122. OUT PVCN Vcn,
  123. OUT PLCN Lcn,
  124. OUT PBIG_INT RunLength
  125. ) CONST;
  126. NONVIRTUAL
  127. UNTFS_EXPORT
  128. BOOLEAN
  129. QueryLcnFromVcn(
  130. IN VCN Vcn,
  131. OUT PLCN Lcn,
  132. OUT PBIG_INT RunLength DEFAULT NULL
  133. ) CONST;
  134. NONVIRTUAL
  135. BOOLEAN
  136. QueryCompressedMappingPairs(
  137. OUT PVCN LowestVcn,
  138. OUT PVCN NextVcn,
  139. OUT PULONG MappingPairsLength,
  140. IN ULONG BufferSize,
  141. IN OUT PVOID Buffer,
  142. OUT PBOOLEAN HasHoleInFront DEFAULT NULL
  143. ) CONST;
  144. NONVIRTUAL
  145. VCN
  146. QueryLowestVcn(
  147. ) CONST;
  148. NONVIRTUAL
  149. VCN
  150. QueryNextVcn(
  151. ) CONST;
  152. NONVIRTUAL
  153. VOID
  154. SetLowestVcn(
  155. IN BIG_INT LowestVcn
  156. );
  157. NONVIRTUAL
  158. VOID
  159. SetNextVcn(
  160. IN BIG_INT NextVcn
  161. );
  162. NONVIRTUAL
  163. BIG_INT
  164. QueryClustersAllocated(
  165. ) CONST;
  166. NONVIRTUAL
  167. BOOLEAN
  168. DeleteRange(
  169. IN VCN Vcn,
  170. IN BIG_INT RunLength
  171. );
  172. private:
  173. NONVIRTUAL
  174. VOID
  175. Construct (
  176. );
  177. NONVIRTUAL
  178. VOID
  179. Destroy(
  180. );
  181. NONVIRTUAL
  182. LCN
  183. QueryLastLcn(
  184. ) CONST;
  185. NONVIRTUAL
  186. VOID
  187. Truncate(
  188. IN BIG_INT NewNumberOfClusters,
  189. IN OUT PNTFS_BITMAP Bitmap
  190. );
  191. NONVIRTUAL
  192. VOID
  193. Coalesce(
  194. );
  195. STATIC
  196. BOOLEAN
  197. QueryMappingPairsLength(
  198. IN PCVOID CompressedPairs,
  199. IN ULONG MaximumLength,
  200. OUT PULONG Length,
  201. OUT PULONG NumberOfPairs
  202. );
  203. STATIC
  204. BOOLEAN
  205. ExpandMappingPairs(
  206. IN PCVOID CompressedPairs,
  207. IN VCN StartingVcn,
  208. IN ULONG MaximumCompressedLength,
  209. IN ULONG MaximumNumberOfPairs,
  210. IN OUT PMAPPING_PAIR MappingPairs,
  211. OUT PULONG NumberOfPairs
  212. );
  213. STATIC
  214. BOOLEAN
  215. CompressMappingPairs(
  216. IN PCMAPPING_PAIR MappingPairs,
  217. IN ULONG NumberOfPairs,
  218. IN VCN StartingVcn,
  219. IN OUT PVOID CompressedPairs,
  220. IN ULONG MaximumCompressedLength,
  221. OUT PULONG CompressedLength
  222. );
  223. struct _LARGE_MCB* _Mcb;
  224. BOOLEAN _McbInitialized;
  225. VCN _LowestVcn;
  226. VCN _NextVcn;
  227. };
  228. INLINE
  229. BOOLEAN
  230. NTFS_EXTENT_LIST::IsEmpty(
  231. ) CONST
  232. /*++
  233. Routine Description:
  234. This method determines whether the extent list is empty.
  235. Arguments:
  236. None.
  237. Return Value:
  238. TRUE if there are no extents in the list.
  239. --*/
  240. {
  241. return ( _LowestVcn == _NextVcn );
  242. }
  243. INLINE
  244. VCN
  245. NTFS_EXTENT_LIST::QueryLowestVcn(
  246. ) CONST
  247. /*++
  248. Routine Description:
  249. This method returns the lowest VCN covered by this extent
  250. list. Note that for a sparse file, this is not necessarily
  251. the same as the VCN of the first extent in the list.
  252. Arguments:
  253. None.
  254. Return Value:
  255. The lowest VCN mapped by this extent list.
  256. --*/
  257. {
  258. return _LowestVcn;
  259. }
  260. INLINE
  261. LCN
  262. NTFS_EXTENT_LIST::QueryNextVcn(
  263. ) CONST
  264. /*++
  265. Routine Description:
  266. This method returns the highest VCN covered by this extent
  267. list. Note that for a sparse file, this is not necessarily
  268. the same as the last VCN of the last extent in the list.
  269. Arguments:
  270. None.
  271. Return Value:
  272. The highest VCN mapped by this extent list.
  273. --*/
  274. {
  275. return _NextVcn;
  276. }
  277. #endif // _NTFS_EXTENT_LIST_DEFN_