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.

340 lines
4.6 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. clusrun.hxx
  5. Abstract:
  6. This class models a run of clusters on an NTFS volume. Its
  7. principle purpose is to mediate between the cluster-oriented
  8. NTFS volume and the sector-oriented drive object.
  9. Author:
  10. Bill McJohn (billmc) 17-June-91
  11. Environment:
  12. ULIB, User Mode
  13. --*/
  14. #if !defined( NTFS_CLUSTER_RUN_DEFN )
  15. #define NTFS_CLUSTER_RUN_DEFN
  16. #include "secrun.hxx"
  17. class NTFS_CLUSTER_RUN : public SECRUN {
  18. public:
  19. UNTFS_EXPORT
  20. DECLARE_CONSTRUCTOR( NTFS_CLUSTER_RUN );
  21. UNTFS_EXPORT
  22. VIRTUAL
  23. ~NTFS_CLUSTER_RUN(
  24. );
  25. UNTFS_EXPORT
  26. NONVIRTUAL
  27. BOOLEAN
  28. Initialize(
  29. IN PMEM Mem,
  30. IN PLOG_IO_DP_DRIVE Drive,
  31. IN LCN Lcn,
  32. IN ULONG ClusterFactor,
  33. IN ULONG NumberOfClusters
  34. );
  35. UNTFS_EXPORT
  36. NONVIRTUAL
  37. VOID
  38. Relocate(
  39. IN LCN NewLcn
  40. );
  41. NONVIRTUAL
  42. LCN
  43. QueryStartLcn(
  44. ) CONST;
  45. NONVIRTUAL
  46. ULONG
  47. QueryClusterFactor(
  48. ) CONST;
  49. NONVIRTUAL
  50. PLOG_IO_DP_DRIVE
  51. GetDrive(
  52. );
  53. NONVIRTUAL
  54. VOID
  55. MarkModified(
  56. );
  57. NONVIRTUAL
  58. BOOLEAN
  59. IsModified(
  60. ) CONST;
  61. VIRTUAL
  62. BOOLEAN
  63. Write(
  64. );
  65. VIRTUAL
  66. BOOLEAN
  67. Write(
  68. IN BOOLEAN OnlyIfModified
  69. );
  70. protected:
  71. NONVIRTUAL
  72. USHORT
  73. QueryClusterSize(
  74. ) CONST;
  75. private:
  76. NONVIRTUAL
  77. VOID
  78. Construct (
  79. );
  80. NONVIRTUAL
  81. VOID
  82. Destroy (
  83. );
  84. LCN _StartLcn;
  85. ULONG _ClusterFactor;
  86. PLOG_IO_DP_DRIVE _Drive;
  87. BOOLEAN _IsModified;
  88. };
  89. INLINE
  90. LCN
  91. NTFS_CLUSTER_RUN::QueryStartLcn (
  92. ) CONST
  93. /*++
  94. Routine Description:
  95. This method gives the client the first LCN of the cluster run.
  96. Arguments:
  97. StartLcn -- receives the first LCN of the cluster run.
  98. Return Value:
  99. None.
  100. --*/
  101. {
  102. return _StartLcn;
  103. }
  104. INLINE
  105. ULONG
  106. NTFS_CLUSTER_RUN::QueryClusterFactor(
  107. ) CONST
  108. /*++
  109. Routine Description:
  110. This method returns the number of sectors per cluster in
  111. this cluster run.
  112. Arguments:
  113. None.
  114. Return Value:
  115. The cluster run's cluster factor.
  116. ++*/
  117. {
  118. return _ClusterFactor;
  119. }
  120. INLINE
  121. PLOG_IO_DP_DRIVE
  122. NTFS_CLUSTER_RUN::GetDrive(
  123. )
  124. /*++
  125. Routine Description:
  126. This method returns the drive on which the Cluster Run resides.
  127. This functionality enables clients of Cluster Run to initialize
  128. other Cluster Runs on the same drive.
  129. Arguments:
  130. None.
  131. Return Value:
  132. The drive on which the Cluster Run resides.
  133. --*/
  134. {
  135. return _Drive;
  136. }
  137. INLINE
  138. VOID
  139. NTFS_CLUSTER_RUN::MarkModified(
  140. )
  141. /*++
  142. Routine Description:
  143. Mark the Cluster Run as modified.
  144. Arguments:
  145. None.
  146. Return Value:
  147. None.
  148. --*/
  149. {
  150. _IsModified = TRUE;
  151. }
  152. INLINE
  153. BOOLEAN
  154. NTFS_CLUSTER_RUN::IsModified(
  155. ) CONST
  156. /*++
  157. Routine Description:
  158. Query whether the Cluster Run has been marked as modified.
  159. Arguments:
  160. None.
  161. Return Value:
  162. TRUE if the Cluster Run has been marked as modified.
  163. --*/
  164. {
  165. return( _IsModified );
  166. }
  167. INLINE
  168. BOOLEAN
  169. NTFS_CLUSTER_RUN::Write(
  170. )
  171. /*++
  172. Routine Description:
  173. This method writes the Cluster Run.
  174. Arguments:
  175. None.
  176. Return Value:
  177. TRUE upon successful completion.
  178. Notes:
  179. This method is provided to keep the Write method on SECRUN visible.
  180. --*/
  181. {
  182. return SECRUN::Write();
  183. }
  184. INLINE
  185. BOOLEAN
  186. NTFS_CLUSTER_RUN::Write(
  187. IN BOOLEAN OnlyIfModified
  188. )
  189. /*++
  190. Routine Description:
  191. This method writes the Cluster Run; it also allows the client
  192. to specify that it should only be written if it has been modified.
  193. Arguments:
  194. OnlyIfModified -- supplies a flag indicating whether the write
  195. is conditional; if this is TRUE, then the
  196. Cluster Run is written only if it has been
  197. marked as modified.
  198. Return Value:
  199. TRUE upon successful completion.
  200. Notes:
  201. The Cluster Run does not mark itself dirty; if clients want
  202. to take advantage of the ability to write only if modified,
  203. they have to be sure to call MarkModified appropriately.
  204. --*/
  205. {
  206. _IsModified = (BOOLEAN)
  207. !((OnlyIfModified && !_IsModified) || SECRUN::Write());
  208. return !_IsModified;
  209. }
  210. INLINE
  211. USHORT
  212. NTFS_CLUSTER_RUN::QueryClusterSize(
  213. ) CONST
  214. /*++
  215. Routine Description:
  216. This method returns the number of bytes per cluster.
  217. Arguments:
  218. None.
  219. Return Value:
  220. Number of bytes per cluster (zero indicates error).
  221. --*/
  222. {
  223. DebugPtrAssert( _Drive );
  224. return( (USHORT)_ClusterFactor * (USHORT)_Drive->QuerySectorSize() );
  225. }
  226. #endif