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.

1128 lines
23 KiB

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