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.

440 lines
8.5 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. );
  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. NONVIRTUAL
  177. FORMAT_ERROR_CODE
  178. FormatSonyG2MS(
  179. IN OUT PMESSAGE Message,
  180. IN BIG_INT Sectors
  181. );
  182. PSUPERAREA _sa;
  183. NUMBER_SET _bad_sectors;
  184. };
  185. INLINE
  186. PSUPERAREA
  187. VOL_LIODPDRV::GetSa(
  188. )
  189. /*++
  190. Routine Description:
  191. This routine returns a pointer to the current super area.
  192. Arguments:
  193. None.
  194. Return Value:
  195. A pointer to the current super area.
  196. --*/
  197. {
  198. return _sa;
  199. }
  200. #else // _SETUP_LOADER_ is defined
  201. #include "drive.hxx"
  202. #include "intstack.hxx"
  203. //
  204. // Forward references
  205. //
  206. DECLARE_CLASS( HMEM );
  207. DECLARE_CLASS( MESSAGE );
  208. DECLARE_CLASS( SUPERAREA );
  209. DECLARE_CLASS( VOL_LIODPDRV );
  210. DECLARE_CLASS( WSTRING );
  211. DECLARE_CLASS( WSTRING );
  212. typedef ULONG VOLID;
  213. #define MAXVOLNAME 11
  214. enum FIX_LEVEL {
  215. CheckOnly,
  216. TotalFix
  217. };
  218. // This number describes the minimum number of bytes in a boot sector.
  219. #define BYTES_PER_BOOT_SECTOR 512
  220. class VOL_LIODPDRV : public LOG_IO_DP_DRIVE {
  221. public:
  222. VIRTUAL
  223. ~VOL_LIODPDRV(
  224. );
  225. NONVIRTUAL
  226. BOOLEAN
  227. ChkDsk(
  228. IN FIX_LEVEL FixLevel,
  229. IN OUT PMESSAGE Message DEFAULT NULL,
  230. IN BOOLEAN Verbose DEFAULT FALSE,
  231. IN BOOLEAN OnlyIfDirty DEFAULT FALSE
  232. );
  233. NONVIRTUAL
  234. PSUPERAREA
  235. GetSa(
  236. );
  237. VIRTUAL
  238. BOOLEAN
  239. IsHpfs(
  240. );
  241. VIRTUAL
  242. BOOLEAN
  243. IsNtfs(
  244. );
  245. VIRTUAL
  246. ARC_STATUS
  247. MarkDirty(
  248. ) PURE;
  249. VIRTUAL
  250. ARC_STATUS
  251. Flush(
  252. IN BOOLEAN JustHandle
  253. ) PURE;
  254. protected:
  255. DECLARE_CONSTRUCTOR( VOL_LIODPDRV );
  256. NONVIRTUAL
  257. BOOLEAN
  258. Initialize(
  259. IN ULONG DeviceId,
  260. IN OUT PSUPERAREA SuperArea
  261. );
  262. private:
  263. NONVIRTUAL
  264. VOID
  265. Construct (
  266. );
  267. NONVIRTUAL
  268. VOID
  269. Destroy(
  270. );
  271. NONVIRTUAL
  272. SECTORCOUNT
  273. ReadABunch(
  274. IN OUT PHMEM HeapMem,
  275. IN LBN StartLbn,
  276. IN SECTORCOUNT NumSectors,
  277. IN OUT PMESSAGE Message DEFAULT NULL,
  278. IN PCWSTRING SrcDosDriveName DEFAULT NULL
  279. );
  280. PSUPERAREA _sa;
  281. INTSTACK _bad_sectors;
  282. };
  283. INLINE
  284. PSUPERAREA
  285. VOL_LIODPDRV::GetSa(
  286. )
  287. /*++
  288. Routine Description:
  289. This routine returns a pointer to the current super area.
  290. Arguments:
  291. None.
  292. Return Value:
  293. A pointer to the current super area.
  294. --*/
  295. {
  296. return _sa;
  297. }
  298. INLINE
  299. BOOLEAN
  300. VOL_LIODPDRV::IsHpfs(
  301. )
  302. /*++
  303. Routine Description:
  304. This method determines whether the volume is HPFS.
  305. Arguments:
  306. None.
  307. Return Value:
  308. TRUE if this volume is an HPFS volume.
  309. --*/
  310. {
  311. return FALSE;
  312. }
  313. INLINE
  314. BOOLEAN
  315. VOL_LIODPDRV::IsNtfs(
  316. )
  317. /*++
  318. Routine Description:
  319. This method determines whether the volume is NTFS.
  320. Arguments:
  321. None.
  322. Return Value:
  323. TRUE if this volume is an NTFS volume.
  324. --*/
  325. {
  326. return FALSE;
  327. }
  328. #endif
  329. #endif