Source code of Windows XP (NT5)
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.

468 lines
8.8 KiB

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