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.

1106 lines
21 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. rfatsa.hxx
  5. Abstract:
  6. --*/
  7. #ifndef REAL_FAT_SA_DEFN
  8. #define REAL_FAT_SA_DEFN
  9. #include "hmem.hxx"
  10. #include "message.hxx"
  11. #include "fatsa.hxx"
  12. #include "bpb.hxx"
  13. #if defined ( _AUTOCHECK_ ) || defined( _EFICHECK_ )
  14. #define UFAT_EXPORT
  15. #elif defined ( _UFAT_MEMBER_ )
  16. #define UFAT_EXPORT __declspec(dllexport)
  17. #else
  18. #define UFAT_EXPORT __declspec(dllimport)
  19. #endif
  20. //
  21. // Forward references
  22. //
  23. DECLARE_CLASS( ARRAY );
  24. DECLARE_CLASS( BITVECTOR );
  25. DECLARE_CLASS( EA_HEADER );
  26. DECLARE_CLASS( FAT );
  27. DECLARE_CLASS( FAT_SA );
  28. DECLARE_CLASS( FAT_DIRENT );
  29. DECLARE_CLASS( FATDIR );
  30. DECLARE_CLASS( GENERIC_STRING );
  31. #if !defined(_EFICHECK_)
  32. DECLARE_CLASS( INTSTACK );
  33. #endif
  34. DECLARE_CLASS( NUMBER_SET );
  35. DECLARE_CLASS( LOG_IO_DP_DRIVE );
  36. DECLARE_CLASS( MESSAGE );
  37. DECLARE_CLASS( ROOTDIR );
  38. DECLARE_CLASS( SORTED_LIST );
  39. DECLARE_CLASS( TIMEINFO );
  40. DECLARE_CLASS( WSTRING );
  41. DEFINE_POINTER_TYPES( PFATDIR );
  42. // Internal data types
  43. // Possible return status after validating a given cluster size
  44. typedef enum _VALIDATION_STATUS
  45. {
  46. VALID,
  47. TOO_SMALL,
  48. TOO_BIG
  49. } VALIDATION_STATUS;
  50. class REAL_FAT_SA : public FAT_SA {
  51. public:
  52. UFAT_EXPORT
  53. DECLARE_CONSTRUCTOR(REAL_FAT_SA);
  54. VIRTUAL
  55. UFAT_EXPORT
  56. ~REAL_FAT_SA(
  57. );
  58. NONVIRTUAL
  59. UFAT_EXPORT
  60. BOOLEAN
  61. Initialize(
  62. IN OUT PLOG_IO_DP_DRIVE Drive,
  63. IN OUT PMESSAGE Message,
  64. IN BOOLEAN Formatted DEFAULT TRUE
  65. );
  66. NONVIRTUAL
  67. UFAT_EXPORT
  68. BOOLEAN
  69. InitFATChkDirty(
  70. IN OUT PLOG_IO_DP_DRIVE Drive,
  71. IN OUT PMESSAGE Message
  72. );
  73. NONVIRTUAL
  74. BOOLEAN
  75. Create(
  76. IN PCNUMBER_SET BadSectors,
  77. IN OUT PMESSAGE Message,
  78. IN PCWSTRING Label DEFAULT NULL,
  79. IN BOOLEAN BackwardCompatible DEFAULT TRUE,
  80. IN ULONG ClusterSize DEFAULT 0,
  81. IN ULONG VirtualSize DEFAULT 0
  82. );
  83. NONVIRTUAL
  84. BOOLEAN
  85. RecoverFile(
  86. IN PCWSTRING FullPathFileName,
  87. IN OUT PMESSAGE Message
  88. );
  89. NONVIRTUAL
  90. UFAT_EXPORT
  91. BOOLEAN
  92. Read(
  93. IN OUT PMESSAGE Message
  94. );
  95. NONVIRTUAL
  96. BOOLEAN
  97. Write(
  98. IN OUT PMESSAGE Message
  99. );
  100. NONVIRTUAL
  101. VOID
  102. QueryGeometry(
  103. OUT PUSHORT SectorSize,
  104. OUT PUSHORT SectorsPerTrack,
  105. OUT PUSHORT Heads,
  106. OUT PULONG HiddenSectors
  107. );
  108. NONVIRTUAL
  109. USHORT
  110. QuerySectorsPerCluster(
  111. ) CONST;
  112. NONVIRTUAL
  113. ULONG
  114. QuerySectorsPerFat(
  115. ) CONST;
  116. NONVIRTUAL
  117. USHORT
  118. QueryReservedSectors(
  119. ) CONST;
  120. NONVIRTUAL
  121. USHORT
  122. QueryFats(
  123. ) CONST;
  124. NONVIRTUAL
  125. ULONG
  126. QueryRootEntries(
  127. ) CONST;
  128. NONVIRTUAL
  129. PARTITION_SYSTEM_ID
  130. QuerySystemId(
  131. ) CONST;
  132. NONVIRTUAL
  133. LBN
  134. QueryStartDataLbn(
  135. ) CONST;
  136. NONVIRTUAL
  137. ULONG
  138. QueryClusterCount(
  139. ) CONST;
  140. NONVIRTUAL
  141. UFAT_EXPORT
  142. SECTORCOUNT
  143. QueryFreeSectors(
  144. ) CONST;
  145. NONVIRTUAL
  146. FATTYPE
  147. QueryFatType(
  148. ) CONST;
  149. NONVIRTUAL
  150. BYTE
  151. QueryVolumeFlags(
  152. ) CONST;
  153. NONVIRTUAL
  154. VOID
  155. SetVolumeFlags(
  156. BYTE Flags,
  157. BOOLEAN ResetFlags
  158. );
  159. NONVIRTUAL
  160. BOOLEAN
  161. RecoverChain(
  162. IN OUT PULONG StartingCluster,
  163. OUT PBOOLEAN ChangesMade,
  164. IN ULONG EndingCluster DEFAULT 0,
  165. IN BOOLEAN Replace DEFAULT FALSE
  166. );
  167. STATIC
  168. USHORT
  169. ComputeSecClus(
  170. IN SECTORCOUNT Sectors,
  171. IN FATTYPE FatType,
  172. #if defined(FE_SB) && defined(_X86_)
  173. IN MEDIA_TYPE MediaType,
  174. IN ULONG SectorSize = 512
  175. #else
  176. IN MEDIA_TYPE MediaType
  177. #endif
  178. );
  179. NONVIRTUAL
  180. BOOLEAN
  181. IsCompressed(
  182. ) CONST;
  183. NONVIRTUAL
  184. BOOLEAN
  185. IsVolumeDataAligned(
  186. ) CONST;
  187. NONVIRTUAL
  188. BOOLEAN
  189. ReadSectorZero(
  190. );
  191. NONVIRTUAL
  192. PBIOS_PARAMETER_BLOCK
  193. GetBpb(
  194. );
  195. NONVIRTUAL
  196. SECTORCOUNT
  197. QueryVirtualSectors(
  198. ) CONST;
  199. private:
  200. HMEM _mem; // memory for SECRUN
  201. // _fat inherited from FAT_SA
  202. // _fattype inherited from FAT_SA
  203. // _dir inherited from FAT_SA
  204. HMEM _mem2; // memory for SECRUN2
  205. SECRUN _secrun2; // secrun to hold one sector FAT sector
  206. LBN _StartDataLbn; // LBN of files, or data area
  207. ULONG _ClusterCount; // number of clusters in Super Area
  208. // It actually means the number of
  209. // fat entries.
  210. PARTITION_SYSTEM_ID _sysid; // system id
  211. ULONG _sec_per_boot; // sectors for boot code.
  212. EXTENDED_BIOS_PARAMETER_BLOCK
  213. _sector_zero;
  214. PUCHAR _sector_sig; // sector signature
  215. BOOLEAN _data_aligned; // TRUE if data clusters are aligned to
  216. // FAT_FIRST_DATA_CLUSTER_ALIGNMENT boundary
  217. ULONG _AdditionalReservedSectors; // padding to be added for data alignment
  218. NONVIRTUAL
  219. VOID
  220. Construct(
  221. );
  222. NONVIRTUAL
  223. VOID
  224. Destroy(
  225. );
  226. NONVIRTUAL
  227. VALIDATION_STATUS
  228. ValidateClusterSize(
  229. IN ULONG ClusterSize,
  230. IN ULONG Sectors,
  231. IN ULONG SectorSize,
  232. IN ULONG Fats,
  233. IN OUT FATTYPE *FatType,
  234. OUT PULONG FatSize,
  235. OUT PULONG ClusterCount
  236. );
  237. NONVIRTUAL
  238. ULONG
  239. ComputeDefaultClusterSize(
  240. IN ULONG Sectors,
  241. IN ULONG SectorSize,
  242. IN ULONG ReservedSectors,
  243. IN ULONG Fats,
  244. IN MEDIA_TYPE MediaType,
  245. IN FATTYPE FatType,
  246. OUT PULONG FatSize,
  247. OUT PULONG ClusterCount
  248. );
  249. NONVIRTUAL
  250. ULONG
  251. DetermineClusterCountAndFatType (
  252. IN OUT PULONG StartingDataLbn,
  253. IN OUT FATTYPE *Fattype
  254. );
  255. NONVIRTUAL
  256. BOOLEAN
  257. InitializeRootDirectory (
  258. IN PMESSAGE Message
  259. );
  260. NONVIRTUAL
  261. BOOLEAN
  262. SetBpb(
  263. IN ULONG ClusterSize,
  264. IN BOOLEAN BackwardCompatible,
  265. IN PMESSAGE Message
  266. );
  267. NONVIRTUAL
  268. BOOLEAN
  269. SetBpb(
  270. );
  271. NONVIRTUAL
  272. BOOLEAN
  273. DupFats(
  274. );
  275. NONVIRTUAL
  276. LBN
  277. ComputeStartDataLbn(
  278. ) CONST;
  279. NONVIRTUAL
  280. ULONG
  281. ComputeRootEntries(
  282. ) CONST;
  283. NONVIRTUAL
  284. BOOLEAN
  285. ValidateDirent(
  286. IN OUT PFAT_DIRENT Dirent,
  287. IN PCWSTRING FilePath,
  288. IN FIX_LEVEL FixLevel,
  289. IN BOOLEAN RecoverAlloc,
  290. IN OUT PMESSAGE Message,
  291. IN OUT PBOOLEAN NeedErrorsMessage,
  292. IN OUT PBITVECTOR FatBitMap,
  293. OUT PBOOLEAN CrossLinkDetected,
  294. OUT PULONG CrossLinkPreviousCluster
  295. );
  296. NONVIRTUAL
  297. BOOLEAN
  298. CopyClusters(
  299. IN ULONG SourceChain,
  300. OUT PULONG DestChain,
  301. IN OUT PBITVECTOR FatBitMap,
  302. IN FIX_LEVEL FixLevel,
  303. IN OUT PMESSAGE Message
  304. );
  305. #if !defined(_EFICHECK_)
  306. NONVIRTUAL
  307. BOOLEAN
  308. InitRelocationList(
  309. IN OUT PINTSTACK RelocationStack,
  310. IN OUT PULONG RelocatedChain,
  311. IN OUT PSORTED_LIST ClustersToRelocate,
  312. OUT PBOOLEAN Relocated
  313. );
  314. NONVIRTUAL
  315. BOOLEAN
  316. RelocateFirstCluster(
  317. IN OUT PFAT_DIRENT Dirent
  318. );
  319. NONVIRTUAL
  320. ULONG
  321. RelocateOneCluster(
  322. IN ULONG Cluster,
  323. IN ULONG Previous
  324. );
  325. NONVIRTUAL
  326. BOOLEAN
  327. DoDirectoryCensusAndRelocation(
  328. IN OUT PFATDIR Directory,
  329. IN OUT PCENSUS_REPORT CensusReport,
  330. IN OUT PSORTED_LIST ClustersToRelocate,
  331. IN OUT PULONG RelocatedChain,
  332. OUT PBOOLEAN Relocated
  333. );
  334. NONVIRTUAL
  335. BOOLEAN
  336. DoVolumeCensusAndRelocation(
  337. IN OUT PCENSUS_REPORT CensusReport,
  338. IN OUT PSORTED_LIST ClustersToRelocate,
  339. IN OUT PULONG RelocatedChain,
  340. OUT PBOOLEAN Relocated
  341. );
  342. #endif
  343. NONVIRTUAL
  344. ULONG
  345. SecPerBoot(
  346. );
  347. NONVIRTUAL
  348. VOLID
  349. QueryVolId(
  350. ) CONST;
  351. NONVIRTUAL
  352. VOLID
  353. SetVolId(
  354. IN VOLID VolId
  355. );
  356. NONVIRTUAL
  357. UCHAR
  358. QueryMediaByte(
  359. ) CONST;
  360. VIRTUAL
  361. VOID
  362. SetMediaByte(
  363. UCHAR MediaByte
  364. );
  365. NONVIRTUAL
  366. BOOLEAN
  367. VerifyBootSector(
  368. );
  369. NONVIRTUAL
  370. BOOLEAN
  371. CreateBootSector(
  372. IN ULONG ClusterSize,
  373. IN BOOLEAN BackwardCompatible,
  374. IN PMESSAGE Message
  375. );
  376. BOOLEAN
  377. REAL_FAT_SA::SetBootCode(
  378. );
  379. NONVIRTUAL
  380. BOOLEAN
  381. SetPhysicalDriveType(
  382. IN PHYSTYPE PhysType
  383. );
  384. NONVIRTUAL
  385. BOOLEAN
  386. SetOemData(
  387. );
  388. NONVIRTUAL
  389. BOOLEAN
  390. SetSignature(
  391. );
  392. NONVIRTUAL
  393. BOOLEAN
  394. SetBootSignature(
  395. IN UCHAR Signature DEFAULT sigBOOTSTRAP
  396. );
  397. BOOLEAN
  398. DosSaInit(
  399. IN OUT PMEM Mem,
  400. IN OUT PLOG_IO_DP_DRIVE Drive,
  401. IN SECTORCOUNT NumberOfSectors,
  402. IN OUT PMESSAGE Message
  403. );
  404. BOOLEAN
  405. DosSaSetBpb(
  406. );
  407. BOOLEAN
  408. RecoverOrphans(
  409. IN OUT PBITVECTOR FatBitMap,
  410. IN FIX_LEVEL FixLevel,
  411. IN OUT PMESSAGE Message,
  412. IN OUT PBOOLEAN NeedErrorsMessage,
  413. IN OUT PFATCHK_REPORT Report,
  414. OUT PBOOLEAN Changes
  415. );
  416. NONVIRTUAL
  417. ULONG
  418. QuerySectorFromCluster(
  419. IN ULONG Cluster,
  420. OUT PUCHAR NumSectors DEFAULT NULL
  421. );
  422. NONVIRTUAL
  423. BOOLEAN
  424. IsClusterCompressed(
  425. IN ULONG Cluster
  426. ) CONST;
  427. NONVIRTUAL
  428. VOID
  429. SetClusterCompressed(
  430. IN ULONG Cluster,
  431. IN BOOLEAN fCompressed
  432. );
  433. NONVIRTUAL
  434. UCHAR
  435. QuerySectorsRequiredForPlainData(
  436. IN ULONG Cluster
  437. );
  438. NONVIRTUAL
  439. BOOLEAN
  440. VerifyFatExtensions(
  441. IN FIX_LEVEL FixLevel,
  442. IN PMESSAGE Message,
  443. IN PBOOLEAN pfNeedMsg
  444. );
  445. NONVIRTUAL
  446. VOID
  447. SetFat32RootDirStartingCluster(
  448. IN ULONG RootCluster
  449. );
  450. NONVIRTUAL
  451. ULONG
  452. QueryFat32RootDirStartingCluster(
  453. );
  454. NONVIRTUAL
  455. BOOLEAN
  456. CheckSectorHeapAllocation(
  457. IN FIX_LEVEL FixLevel,
  458. IN PMESSAGE Message,
  459. IN PBOOLEAN pfNeedMsg
  460. );
  461. NONVIRTUAL
  462. BOOLEAN
  463. FreeClusterData(
  464. ULONG Cluster
  465. );
  466. NONVIRTUAL
  467. BOOLEAN
  468. AllocateClusterData(
  469. ULONG Cluster,
  470. UCHAR NumSectors,
  471. BOOLEAN bCompressed,
  472. UCHAR PlainSize
  473. );
  474. //
  475. // The following routines are defined for the new lightweight
  476. // format.
  477. //
  478. NONVIRTUAL
  479. BOOLEAN
  480. DiskIsUsable (
  481. IN PCNUMBER_SET BadSectors,
  482. IN PMESSAGE Message
  483. );
  484. NONVIRTUAL
  485. BOOLEAN
  486. WriteNewFats (
  487. IN PCNUMBER_SET BadSectors,
  488. IN OUT PULONG BadClusters,
  489. IN PMESSAGE Message
  490. );
  491. NONVIRTUAL
  492. BOOLEAN
  493. WriteNewRootDirAndVolumeLabel (
  494. IN PCWSTRING Label,
  495. IN PMESSAGE Message
  496. );
  497. NONVIRTUAL
  498. BOOLEAN
  499. WriteNewBootArea (
  500. IN PMESSAGE Message
  501. );
  502. NONVIRTUAL
  503. VOID
  504. PrintFormatReport (
  505. IN ULONG BadClusters,
  506. IN PMESSAGE Message
  507. );
  508. };
  509. INLINE
  510. USHORT
  511. REAL_FAT_SA::QuerySectorsPerCluster(
  512. ) CONST
  513. /*++
  514. Routine Description:
  515. This routine computes the number of sectors per cluster for
  516. the volume.
  517. Arguments:
  518. None.
  519. Return Value:
  520. The number of sectors per cluster for the volume.
  521. --*/
  522. {
  523. return _sector_zero.Bpb.SectorsPerCluster ?
  524. _sector_zero.Bpb.SectorsPerCluster : 256;
  525. }
  526. INLINE
  527. ULONG
  528. REAL_FAT_SA::QuerySectorsPerFat(
  529. ) CONST
  530. /*++
  531. Routine Description:
  532. This routine computes the number of sectors per FAT for the volume.
  533. Arguments:
  534. None.
  535. Return Value:
  536. The number of sectors per FAT for the volume.
  537. --*/
  538. {
  539. if ( 0 == _sector_zero.Bpb.SectorsPerFat ) {
  540. return _sector_zero.Bpb.BigSectorsPerFat;
  541. } else {
  542. return _sector_zero.Bpb.SectorsPerFat;
  543. }
  544. }
  545. INLINE
  546. USHORT
  547. REAL_FAT_SA::QueryReservedSectors(
  548. ) CONST
  549. /*++
  550. Routine Description:
  551. This routine computes the volume's number of Reserved Sectors,
  552. i.e. the number of sectors before the first FAT.
  553. Arguments:
  554. None.
  555. Return Value:
  556. The number of Reserved Sectors.
  557. --*/
  558. {
  559. return _sector_zero.Bpb.ReservedSectors;
  560. }
  561. INLINE
  562. USHORT
  563. REAL_FAT_SA::QueryFats(
  564. ) CONST
  565. /*++
  566. Routine Description:
  567. This routine computes the number of FATs on the volume.
  568. Arguments:
  569. None.
  570. Return Value:
  571. The number of FATs on the volume.
  572. --*/
  573. {
  574. return _sector_zero.Bpb.Fats;
  575. }
  576. INLINE
  577. ULONG
  578. REAL_FAT_SA::QueryRootEntries(
  579. ) CONST
  580. /*++
  581. Routine Description:
  582. This routine returns the number of entries in the root
  583. directory.
  584. Arguments:
  585. None.
  586. Return Value:
  587. The number of root directory entries.
  588. --*/
  589. {
  590. return _sector_zero.Bpb.RootEntries;
  591. }
  592. INLINE
  593. PARTITION_SYSTEM_ID
  594. REAL_FAT_SA::QuerySystemId(
  595. ) CONST
  596. /*++
  597. Routine Description:
  598. This routine computes the system ID for the volume.
  599. Arguments:
  600. None.
  601. Return Value:
  602. The system ID for the volume.
  603. --*/
  604. {
  605. return _sysid;
  606. }
  607. INLINE
  608. LBN
  609. REAL_FAT_SA::QueryStartDataLbn(
  610. ) CONST
  611. /*++
  612. Routine Description:
  613. This routine computes the LBN of the first logical cluster of the
  614. volume.
  615. Arguments:
  616. None.
  617. Return Value:
  618. The LBN of the first logical cluster of the volume.
  619. --*/
  620. {
  621. return _StartDataLbn;
  622. }
  623. INLINE
  624. ULONG
  625. REAL_FAT_SA::QueryClusterCount(
  626. ) CONST
  627. /*++
  628. Routine Description:
  629. This routine computes the total number of clusters for the volume.
  630. That is to say that the largest addressable cluster on the disk
  631. is cluster number 'QueryClusterCount() - 1'. Note that the
  632. smallest addressable cluster on the disk is 2.
  633. Arguments:
  634. None.
  635. Return Value:
  636. The total number of clusters for the volume.
  637. --*/
  638. {
  639. return _ClusterCount;
  640. }
  641. INLINE BOOLEAN
  642. REAL_FAT_SA::IsCompressed(
  643. ) CONST
  644. /*++
  645. Routine Description:
  646. This routine tells whether this volume is doublespaced or not.
  647. Since the class is REAL_FAT_SA, we know it's not.
  648. Arguments:
  649. Return Value:
  650. TRUE - Compressed.
  651. FALSE - Not compressed.
  652. --*/
  653. {
  654. return FALSE;
  655. }
  656. INLINE BOOLEAN
  657. REAL_FAT_SA::IsVolumeDataAligned(
  658. ) CONST
  659. /*++
  660. Routine Description:
  661. This routine tells whether the data clusters of this volume is
  662. aligned to FAT_FIRST_DATA_CLUSTER_ALIGNMENT boundary.
  663. Arguments:
  664. Return Value:
  665. TRUE - Aligned.
  666. FALSE - Not aligned.
  667. --*/
  668. {
  669. return _data_aligned;
  670. }
  671. INLINE BOOLEAN
  672. REAL_FAT_SA::ReadSectorZero(
  673. )
  674. /*++
  675. Routine Description:
  676. This routine used to be DOS_SUPERAREA::Read().
  677. Arguments:
  678. Return Value:
  679. TRUE - Success.
  680. FALSE - Failure.
  681. --*/
  682. {
  683. BOOLEAN b;
  684. PEXTENDED_BIOS_PARAMETER_BLOCK Pbios;
  685. b = SECRUN::Read();
  686. if (!b)
  687. return FALSE;
  688. Pbios = (PEXTENDED_BIOS_PARAMETER_BLOCK)SECRUN::GetBuf();
  689. UnpackExtendedBios(&_sector_zero, Pbios);
  690. return TRUE;
  691. }
  692. INLINE
  693. PBIOS_PARAMETER_BLOCK
  694. REAL_FAT_SA::GetBpb(
  695. )
  696. {
  697. return &(_sector_zero.Bpb);
  698. }
  699. INLINE
  700. UCHAR
  701. REAL_FAT_SA::QueryMediaByte(
  702. ) CONST
  703. /*++
  704. Routine Description:
  705. This routine fetches the media byte from the super area's data.
  706. Arguments:
  707. None.
  708. Return Value:
  709. The media byte residing in the super area.
  710. --*/
  711. {
  712. return _sector_zero.Bpb.Media;
  713. }
  714. INLINE
  715. VOID
  716. REAL_FAT_SA::SetMediaByte(
  717. UCHAR MediaByte
  718. )
  719. /*++
  720. Routine Description:
  721. This routine sets the media byte in the super area's data.
  722. Arguments:
  723. MediaByte -- Supplies the new media byte.
  724. Return Value:
  725. None.
  726. --*/
  727. {
  728. _sector_zero.Bpb.Media = MediaByte;
  729. }
  730. INLINE
  731. SECTORCOUNT
  732. REAL_FAT_SA::QueryVirtualSectors(
  733. ) CONST
  734. /*++
  735. Routine Description:
  736. This routine computes the number of sectors on the volume according
  737. to the file system.
  738. Arguments:
  739. None.
  740. Return Value:
  741. The number of sectors on the volume according to the file system.
  742. --*/
  743. {
  744. return _sector_zero.Bpb.Sectors ? _sector_zero.Bpb.Sectors :
  745. _sector_zero.Bpb.LargeSectors;
  746. }
  747. INLINE
  748. VOLID
  749. REAL_FAT_SA::QueryVolId(
  750. ) CONST
  751. /*++
  752. Routine Description:
  753. This routine fetches the volume ID from the super area's data.
  754. This routine will return 0 if volume serial numbers are not
  755. supported by the partition.
  756. Arguments:
  757. None.
  758. Return Value:
  759. The volume ID residing in the super area.
  760. --*/
  761. {
  762. return (_sector_zero.Signature == 0x28 || _sector_zero.Signature == 0x29) ?
  763. _sector_zero.SerialNumber : 0;
  764. }
  765. INLINE
  766. VOLID
  767. REAL_FAT_SA::SetVolId(
  768. IN VOLID VolId
  769. )
  770. /*++
  771. Routine Description:
  772. This routine puts the volume ID into the super area's data.
  773. Arguments:
  774. VolId - The new volume ID.
  775. Return Value:
  776. The volume ID that was put.
  777. --*/
  778. {
  779. return _sector_zero.SerialNumber = VolId;
  780. }
  781. INLINE
  782. BOOLEAN
  783. REAL_FAT_SA::SetBootSignature(
  784. IN UCHAR Signature
  785. )
  786. /*++
  787. Routine Description:
  788. This routine sets the boot signature in the super area.
  789. Arguments:
  790. Signature - Supplies the character to set the signature to.
  791. Return Value:
  792. FALSE - Failure.
  793. TRUE - Success.
  794. --*/
  795. {
  796. _sector_zero.Signature = Signature;
  797. return TRUE;
  798. }
  799. INLINE
  800. VOID
  801. REAL_FAT_SA::QueryGeometry(
  802. OUT PUSHORT SectorSize,
  803. OUT PUSHORT SectorsPerTrack,
  804. OUT PUSHORT Heads,
  805. OUT PULONG HiddenSectors
  806. )
  807. /*++
  808. Routine Description:
  809. This method returns the geometry information stored in
  810. the Bios Parameter Block.
  811. Arguments:
  812. SectorSize -- Receives the recorded sector size.
  813. SectorsPerTrack -- Receives the recorded sectors per track.
  814. Heads -- Receives the recorded number of heads.
  815. HiddenSectors -- Receives the recorded number of hidden sectors.
  816. Return Value:
  817. None.
  818. --*/
  819. {
  820. *SectorSize = _sector_zero.Bpb.BytesPerSector;
  821. *SectorsPerTrack = _sector_zero.Bpb.SectorsPerTrack;
  822. *Heads = _sector_zero.Bpb.Heads;
  823. *HiddenSectors = _sector_zero.Bpb.HiddenSectors;
  824. }
  825. INLINE
  826. BOOLEAN
  827. AllocateClusterData(
  828. ULONG Cluster,
  829. UCHAR NumSectors,
  830. BOOLEAN bCompressed,
  831. UCHAR PlainSize
  832. )
  833. {
  834. DebugAbort("Didn't expect REAL_FAT_SA::AllocateClusterData() to be called");
  835. return FALSE;
  836. }
  837. //
  838. // Defines for the volume flags in the BPB current head field.
  839. //
  840. #define FAT_BPB_RESERVED_DIRTY 0x01
  841. #define FAT_BPB_RESERVED_TEST_SURFACE 0x02
  842. //
  843. // Defines for the volume flags in FAT[1].
  844. //
  845. #define CLUS1CLNSHUTDWNFAT16 0x00008000
  846. #define CLUS1NOHRDERRFAT16 0x00004000
  847. #define CLUS1CLNSHUTDWNFAT32 0x08000000
  848. #define CLUS1NOHRDERRFAT32 0x04000000
  849. #endif // REAL_FAT_SA_DEFN