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.

334 lines
7.2 KiB

  1. /*++
  2. Copyright (c) 1991-2001 Microsoft Corporation
  3. Module Name:
  4. supera.hxx
  5. Abstract:
  6. This class models the root of a file system. This abstract class is
  7. currently the base class of an HPFS and a FAT super area.
  8. Author:
  9. Norbert Kusters (norbertk) 25-July-91
  10. --*/
  11. #if !defined(SUPERA_DEFN)
  12. #define SUPERA_DEFN
  13. #include "secrun.hxx"
  14. #include "volume.hxx"
  15. #include "ifsentry.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. enum PHYSTYPE { // ptype
  24. PHYS_REMOVABLE, // physical drive is removable
  25. PHYS_FIXED = 0x80 // physical drive is fixed
  26. };
  27. //
  28. // These symbols are used by Chkdsk functions to return an appropriate
  29. // exit status to the chkdsk program.
  30. // In order of most important first, the error level order are as follows:
  31. // 3 > 1 > 2 > 0
  32. // An error level of 3 will overwrite an error level of 1, 2, or 0.
  33. #define CHKDSK_EXIT_SUCCESS 0
  34. #define CHKDSK_EXIT_ERRS_FIXED 1
  35. #define CHKDSK_EXIT_MINOR_ERRS 2 // whether or not "/f"
  36. #define CHKDSK_EXIT_CLEANUP_WORK 2 // whether or not "/f"
  37. #define CHKDSK_EXIT_COULD_NOT_CHK 3
  38. #define CHKDSK_EXIT_ERRS_NOT_FIXED 3
  39. #define CHKDSK_EXIT_COULD_NOT_FIX 3
  40. //
  41. // This macros updates the exit status of CHKDSK_INFO at the end of
  42. // a routine. It will not overwrite the exit status if an error
  43. // of level 3 has occurred.
  44. //
  45. #define UPDATE_EXIT_STATUS_FIXED(x, y) \
  46. if ((x) != CHKDSK_EXIT_SUCCESS && \
  47. (y)->ExitStatus != CHKDSK_EXIT_ERRS_NOT_FIXED) \
  48. (y)->ExitStatus = CHKDSK_EXIT_ERRS_FIXED;
  49. DECLARE_CLASS( SUPERAREA );
  50. DECLARE_CLASS( NUMBER_SET );
  51. DECLARE_CLASS( MESSAGE );
  52. DECLARE_CLASS( WSTRING );
  53. class SUPERAREA : public SECRUN {
  54. public:
  55. VIRTUAL
  56. IFSUTIL_EXPORT
  57. ~SUPERAREA(
  58. );
  59. VIRTUAL
  60. PVOID
  61. GetBuf(
  62. );
  63. VIRTUAL
  64. BOOLEAN
  65. Create(
  66. IN PCNUMBER_SET BadSectors,
  67. IN OUT PMESSAGE Message,
  68. IN PCWSTRING Label DEFAULT NULL,
  69. IN ULONG Flags DEFAULT FORMAT_BACKWARD_COMPATIBLE,
  70. IN ULONG ClusterSize DEFAULT 0,
  71. IN ULONG VirtualSize DEFAULT 0
  72. ) PURE;
  73. VIRTUAL
  74. BOOLEAN
  75. VerifyAndFix(
  76. IN FIX_LEVEL FixLevel,
  77. IN OUT PMESSAGE Message,
  78. IN ULONG Flags DEFAULT FALSE,
  79. IN ULONG LogFileSize DEFAULT 0,
  80. IN USHORT Algorithm DEFAULT 0,
  81. OUT PULONG ExitStatus DEFAULT NULL,
  82. IN PCWSTRING DriveLetter DEFAULT NULL
  83. ) PURE;
  84. VIRTUAL
  85. BOOLEAN
  86. RecoverFile(
  87. IN PCWSTRING FullPathFileName,
  88. IN OUT PMESSAGE Message
  89. ) PURE;
  90. VIRTUAL
  91. PARTITION_SYSTEM_ID
  92. QuerySystemId(
  93. ) CONST PURE;
  94. STATIC
  95. IFSUTIL_EXPORT
  96. VOLID
  97. ComputeVolId(
  98. IN VOLID Seed DEFAULT 0
  99. );
  100. NTSTATUS
  101. FormatNotification(
  102. IN PWSTRING Label DEFAULT NULL,
  103. OUT PFILE_FS_SIZE_INFORMATION FsSizeInfo DEFAULT NULL,
  104. OUT PFILE_FS_VOLUME_INFORMATION FsVolInfo DEFAULT NULL
  105. );
  106. STATIC
  107. IFSUTIL_EXPORT
  108. NTSTATUS
  109. GenerateLabelNotification(
  110. IN PCWSTRING NtDriveName,
  111. IN PWSTRING Label DEFAULT NULL,
  112. OUT PFILE_FS_SIZE_INFORMATION FsSizeInfo DEFAULT NULL,
  113. OUT PFILE_FS_VOLUME_INFORMATION FsVolInfo DEFAULT NULL
  114. );
  115. NONVIRTUAL
  116. IFSUTIL_EXPORT
  117. PMESSAGE
  118. GetMessage(
  119. );
  120. NONVIRTUAL
  121. IFSUTIL_EXPORT
  122. PIO_DP_DRIVE
  123. GetDrive(
  124. );
  125. VIRTUAL
  126. VOID
  127. PrintFormatReport (
  128. IN OUT PMESSAGE Message,
  129. IN PFILE_FS_SIZE_INFORMATION FsSizeInfo,
  130. IN PFILE_FS_VOLUME_INFORMATION FsVolInfo
  131. ) PURE;
  132. protected:
  133. IFSUTIL_EXPORT
  134. DECLARE_CONSTRUCTOR( SUPERAREA );
  135. NONVIRTUAL
  136. IFSUTIL_EXPORT
  137. BOOLEAN
  138. Initialize(
  139. IN OUT PMEM Mem,
  140. IN OUT PLOG_IO_DP_DRIVE Drive,
  141. IN SECTORCOUNT NumberOfSectors,
  142. IN OUT PMESSAGE Message
  143. );
  144. #if !defined( _SETUP_LOADER_ )
  145. NONVIRTUAL
  146. BOOLEAN
  147. SetSystemId(
  148. );
  149. #endif // _SETUP_LOADER_
  150. PLOG_IO_DP_DRIVE _drive;
  151. PUCHAR _bootcode;
  152. ULONG _bootcodesize;
  153. private:
  154. NONVIRTUAL
  155. VOID
  156. Construct(
  157. );
  158. NONVIRTUAL
  159. VOID
  160. Destroy(
  161. );
  162. };
  163. INLINE
  164. PVOID
  165. SUPERAREA::GetBuf(
  166. )
  167. /*++
  168. Routine Description:
  169. This routine returns a pointer to the beginning of the read/write
  170. buffer.
  171. Arguments:
  172. None.
  173. Return Value:
  174. A pointer to a read/write buffer.
  175. --*/
  176. {
  177. return SECRUN::GetBuf();
  178. }
  179. #if !defined( _SETUP_LOADER_ )
  180. INLINE
  181. BOOLEAN
  182. SUPERAREA::SetSystemId(
  183. )
  184. /*++
  185. Routine Description:
  186. Set the current volume's file system sub-type.
  187. The volume stores the file system type on disk with a
  188. strong bias to the FAT. However, this may not continue
  189. in the future so a common interface to this type is supported.
  190. The current on disk file system subtypes are:
  191. UNKNOWN, no format done yet
  192. 12 bit fat
  193. 16 bit fat on a < 32M volume
  194. 16 bit fat on a >= 32M volume
  195. IFS
  196. OS/2 2.0 does not support this interface so we must set the
  197. information via the MBR, NT will provide an ioctl to set this
  198. information.
  199. This information MUST be maintained to stay disk compatable.
  200. This activity should only be done by format so this is
  201. a protected method.
  202. Arguments:
  203. None.
  204. Return Value:
  205. FALSE - Failure.
  206. TRUE - Success.
  207. --*/
  208. {
  209. return _drive->SetSystemId(QuerySystemId());
  210. }
  211. INLINE
  212. PMESSAGE
  213. SUPERAREA::GetMessage(
  214. )
  215. /*++
  216. Routine Description:
  217. Retrieve the message object.
  218. Arguments:
  219. N/A
  220. Return Value:
  221. The message object.
  222. --*/
  223. {
  224. if (_drive)
  225. return _drive->GetMessage();
  226. else
  227. return NULL;
  228. }
  229. INLINE
  230. PIO_DP_DRIVE
  231. SUPERAREA::GetDrive(
  232. )
  233. /*++
  234. Routine Description:
  235. Retrieve the drive object.
  236. Arguments:
  237. N/A
  238. Return Value:
  239. The drive object.
  240. --*/
  241. {
  242. return _drive;
  243. }
  244. #endif // _SETUP_LOADER_
  245. #endif // SUPERA_DEFN