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.

441 lines
9.0 KiB

  1. /*++
  2. Copyright (c) 1990-2001 Microsoft Corporation
  3. Module Name:
  4. volume.hxx
  5. Abstract:
  6. Provides volume methods.
  7. Author:
  8. Mark Shavlik (marks) 13-Feb-90
  9. Norbert P. Kusters (norbertk) 22-Feb-91
  10. --*/
  11. #if !defined (VOL_LOG_IO_DP_DRIVE_DEFN)
  12. #define VOL_LOG_IO_DP_DRIVE_DEFN
  13. #if !defined( _SETUP_LOADER_ )
  14. #include "drive.hxx"
  15. #include "numset.hxx"
  16. #if defined ( _AUTOCHECK_ )
  17. #define IFSUTIL_EXPORT
  18. #elif defined ( _IFSUTIL_MEMBER_ )
  19. #define IFSUTIL_EXPORT __declspec(dllexport)
  20. #else
  21. #define IFSUTIL_EXPORT __declspec(dllimport)
  22. #endif
  23. //
  24. // Forward references
  25. //
  26. DECLARE_CLASS( HMEM );
  27. DECLARE_CLASS( MESSAGE );
  28. DECLARE_CLASS( SUPERAREA );
  29. DECLARE_CLASS( VOL_LIODPDRV );
  30. DECLARE_CLASS( WSTRING );
  31. DECLARE_CLASS( WSTRING );
  32. // This number describes the minimum number of bytes in a boot sector.
  33. #define BYTES_PER_BOOT_SECTOR 512
  34. typedef ULONG VOLID;
  35. #define MAXVOLNAME 11
  36. #define AUTOCHK_TIMEOUT 10 // 10 seconds before initiating autochk
  37. #define MAX_AUTOCHK_TIMEOUT_VALUE (3*24*3600) // 3 days maximum
  38. enum FIX_LEVEL {
  39. CheckOnly,
  40. TotalFix,
  41. SetupSpecial
  42. };
  43. enum FORMAT_ERROR_CODE {
  44. GeneralError,
  45. NoError,
  46. LockError
  47. };
  48. #if !defined(RUN_ON_NT4)
  49. IFSUTIL_EXPORT
  50. VOID
  51. RestoreThreadExecutionState(
  52. IN NTSTATUS PrevStatus,
  53. IN EXECUTION_STATE PrevState
  54. );
  55. #endif
  56. class VOL_LIODPDRV : public LOG_IO_DP_DRIVE {
  57. public:
  58. VIRTUAL
  59. IFSUTIL_EXPORT
  60. ~VOL_LIODPDRV(
  61. );
  62. NONVIRTUAL
  63. IFSUTIL_EXPORT
  64. FORMAT_ERROR_CODE
  65. Format(
  66. IN PCWSTRING Label DEFAULT NULL,
  67. IN OUT PMESSAGE Message DEFAULT NULL,
  68. IN ULONG flags DEFAULT 0,
  69. IN ULONG ClusterSize DEFAULT 0,
  70. IN ULONG VirtualSectors DEFAULT 0
  71. );
  72. NONVIRTUAL
  73. IFSUTIL_EXPORT
  74. BOOLEAN
  75. SetVolumeLabelAndPrintFormatReport(
  76. IN PCWSTRING Label DEFAULT NULL,
  77. IN OUT PMESSAGE Message DEFAULT NULL
  78. );
  79. NONVIRTUAL
  80. IFSUTIL_EXPORT
  81. BOOLEAN
  82. ChkDsk(
  83. IN FIX_LEVEL FixLevel,
  84. IN OUT PMESSAGE Message DEFAULT NULL,
  85. IN ULONG Flags DEFAULT 0,
  86. IN ULONG DesiredLogfileSize DEFAULT 0,
  87. IN USHORT Algorithm DEFAULT 0,
  88. OUT PULONG ExitStatus DEFAULT NULL,
  89. IN PCWSTRING DriveLetter DEFAULT NULL
  90. );
  91. NONVIRTUAL
  92. IFSUTIL_EXPORT
  93. BOOLEAN
  94. Recover(
  95. IN PCWSTRING FileName,
  96. IN OUT PMESSAGE Message DEFAULT NULL
  97. );
  98. NONVIRTUAL
  99. PSUPERAREA
  100. GetSa(
  101. );
  102. VIRTUAL
  103. PVOL_LIODPDRV
  104. QueryDupVolume(
  105. IN PCWSTRING NtDriveName,
  106. IN OUT PMESSAGE Message DEFAULT NULL,
  107. IN BOOLEAN ExclusiveWrite DEFAULT FALSE,
  108. IN BOOLEAN FormatMedia DEFAULT FALSE,
  109. IN MEDIA_TYPE MediaType DEFAULT Unknown
  110. ) CONST PURE;
  111. NONVIRTUAL
  112. IFSUTIL_EXPORT
  113. BOOLEAN
  114. ForceAutochk(
  115. IN BOOLEAN Fix,
  116. IN ULONG Options,
  117. IN ULONG DesiredLogfileSize,
  118. IN USHORT Algorithm,
  119. IN PCWSTRING Name
  120. );
  121. STATIC
  122. IFSUTIL_EXPORT
  123. BOOLEAN
  124. QueryAutochkTimeOut(
  125. OUT PULONG TimeOut
  126. );
  127. STATIC
  128. IFSUTIL_EXPORT
  129. BOOLEAN
  130. SetAutochkTimeOut(
  131. IN ULONG TimeOut
  132. );
  133. protected:
  134. IFSUTIL_EXPORT
  135. DECLARE_CONSTRUCTOR( VOL_LIODPDRV );
  136. NONVIRTUAL
  137. IFSUTIL_EXPORT
  138. FORMAT_ERROR_CODE
  139. Initialize(
  140. IN PCWSTRING NtDriveName,
  141. IN PSUPERAREA SuperArea,
  142. IN OUT PMESSAGE Message DEFAULT NULL,
  143. IN BOOLEAN ExclusiveWrite DEFAULT FALSE,
  144. IN BOOLEAN FormatMedia DEFAULT FALSE,
  145. IN MEDIA_TYPE MediaType DEFAULT Unknown,
  146. IN USHORT FormatType DEFAULT DP_DRIVE::NONE,
  147. IN BOOLEAN ForceDismount DEFAULT FALSE
  148. );
  149. NONVIRTUAL
  150. IFSUTIL_EXPORT
  151. BOOLEAN
  152. Initialize(
  153. IN PCWSTRING NtDriveName,
  154. IN PCWSTRING HostFileName,
  155. IN PSUPERAREA SuperArea,
  156. IN OUT PMESSAGE Message DEFAULT NULL,
  157. IN BOOLEAN ExclusiveWrite DEFAULT FALSE
  158. );
  159. private:
  160. NONVIRTUAL
  161. VOID
  162. Construct (
  163. );
  164. NONVIRTUAL
  165. VOID
  166. Destroy(
  167. );
  168. NONVIRTUAL
  169. SECTORCOUNT
  170. ReadABunch(
  171. IN OUT PHMEM HeapMem,
  172. IN LBN StartLbn,
  173. IN SECTORCOUNT NumSectors,
  174. IN OUT PMESSAGE Message DEFAULT NULL,
  175. IN PCWSTRING SrcDosDriveName DEFAULT NULL
  176. );
  177. NONVIRTUAL
  178. FORMAT_ERROR_CODE
  179. FormatSonyG2MS(
  180. IN OUT PMESSAGE Message,
  181. IN BIG_INT Sectors
  182. );
  183. PSUPERAREA _sa;
  184. NUMBER_SET _bad_sectors;
  185. };
  186. INLINE
  187. PSUPERAREA
  188. VOL_LIODPDRV::GetSa(
  189. )
  190. /*++
  191. Routine Description:
  192. This routine returns a pointer to the current super area.
  193. Arguments:
  194. None.
  195. Return Value:
  196. A pointer to the current super area.
  197. --*/
  198. {
  199. return _sa;
  200. }
  201. #else // _SETUP_LOADER_ is defined
  202. #include "drive.hxx"
  203. #include "intstack.hxx"
  204. //
  205. // Forward references
  206. //
  207. DECLARE_CLASS( HMEM );
  208. DECLARE_CLASS( MESSAGE );
  209. DECLARE_CLASS( SUPERAREA );
  210. DECLARE_CLASS( VOL_LIODPDRV );
  211. DECLARE_CLASS( WSTRING );
  212. DECLARE_CLASS( WSTRING );
  213. typedef ULONG VOLID;
  214. #define MAXVOLNAME 11
  215. enum FIX_LEVEL {
  216. CheckOnly,
  217. TotalFix
  218. };
  219. // This number describes the minimum number of bytes in a boot sector.
  220. #define BYTES_PER_BOOT_SECTOR 512
  221. class VOL_LIODPDRV : public LOG_IO_DP_DRIVE {
  222. public:
  223. VIRTUAL
  224. ~VOL_LIODPDRV(
  225. );
  226. NONVIRTUAL
  227. BOOLEAN
  228. ChkDsk(
  229. IN FIX_LEVEL FixLevel,
  230. IN OUT PMESSAGE Message DEFAULT NULL,
  231. IN BOOLEAN Verbose DEFAULT FALSE,
  232. IN BOOLEAN OnlyIfDirty DEFAULT FALSE
  233. );
  234. NONVIRTUAL
  235. PSUPERAREA
  236. GetSa(
  237. );
  238. VIRTUAL
  239. BOOLEAN
  240. IsHpfs(
  241. );
  242. VIRTUAL
  243. BOOLEAN
  244. IsNtfs(
  245. );
  246. VIRTUAL
  247. ARC_STATUS
  248. MarkDirty(
  249. ) PURE;
  250. VIRTUAL
  251. ARC_STATUS
  252. Flush(
  253. IN BOOLEAN JustHandle
  254. ) PURE;
  255. protected:
  256. DECLARE_CONSTRUCTOR( VOL_LIODPDRV );
  257. NONVIRTUAL
  258. BOOLEAN
  259. Initialize(
  260. IN ULONG DeviceId,
  261. IN OUT PSUPERAREA SuperArea
  262. );
  263. private:
  264. NONVIRTUAL
  265. VOID
  266. Construct (
  267. );
  268. NONVIRTUAL
  269. VOID
  270. Destroy(
  271. );
  272. NONVIRTUAL
  273. SECTORCOUNT
  274. ReadABunch(
  275. IN OUT PHMEM HeapMem,
  276. IN LBN StartLbn,
  277. IN SECTORCOUNT NumSectors,
  278. IN OUT PMESSAGE Message DEFAULT NULL,
  279. IN PCWSTRING SrcDosDriveName DEFAULT NULL
  280. );
  281. PSUPERAREA _sa;
  282. INTSTACK _bad_sectors;
  283. };
  284. INLINE
  285. PSUPERAREA
  286. VOL_LIODPDRV::GetSa(
  287. )
  288. /*++
  289. Routine Description:
  290. This routine returns a pointer to the current super area.
  291. Arguments:
  292. None.
  293. Return Value:
  294. A pointer to the current super area.
  295. --*/
  296. {
  297. return _sa;
  298. }
  299. INLINE
  300. BOOLEAN
  301. VOL_LIODPDRV::IsHpfs(
  302. )
  303. /*++
  304. Routine Description:
  305. This method determines whether the volume is HPFS.
  306. Arguments:
  307. None.
  308. Return Value:
  309. TRUE if this volume is an HPFS volume.
  310. --*/
  311. {
  312. return FALSE;
  313. }
  314. INLINE
  315. BOOLEAN
  316. VOL_LIODPDRV::IsNtfs(
  317. )
  318. /*++
  319. Routine Description:
  320. This method determines whether the volume is NTFS.
  321. Arguments:
  322. None.
  323. Return Value:
  324. TRUE if this volume is an NTFS volume.
  325. --*/
  326. {
  327. return FALSE;
  328. }
  329. #endif
  330. #endif