[SETUPLIB][USETUP] Code simplifications & fixes.

SETUPLIB:
=========

- Remove useless HiddenSectors member in PARTENTRY structure.
- InsertDiskRegion() helper returns a BOOLEAN success.
- CreateInsertBlankRegion() helper sets LogicalPartition.

- Simplify the InitializePartitionEntry() helper so that its PartEntry
  parameter is clearly the one that is being initialized (i.e. converted
  from a blank region to) an actual partition, and use the helper
  CreateInsertBlankRegion(). The calculations for the StartSector and
  SectorCount are exactly equivalent with the old version of this
  function. Also make it return a BOOLEAN success instead.
  + Add some extra validation checks.
  + Adjust CreatePrimaryPartition(), CreateExtendedPartition() and
    CreateLogicalPartition() in this regard.

- Better handling of "RAW"-mounted partitions: treat them as
  "Unformatted" only if they are RAW *AND* their PartitionType is one of
  those associated with FAT file-system. Otherwise we cannot decide
  whether they are indeed unformatted or have an unknown file-system on
  them, therefore treat them as the latter.
  In this regard, the IsSupportedActivePartition() helper should not
  look for FileSystem == RAW but instead only look whether the partition
  is Unformatted.

  This should help with situations similar to the one described in CORE-16274
  where a partition with a genuine file-system but not recognized by
  ReactOS (because we currently do not have the EXT2/3/4 filesystem
  driver loaded during 1st-stage setup due to commit 5a650f6b) and
  therefore mounted as RAW, was thought to be unformatted.

USETUP:
=======
- Use the "global" SystemPartition pointer: this is the "system"
  partition we will actually use. It can be different from the actual
  one of the computer, for example when we install ReactOS on a
  removable disk. This allows also to simplify the code.

- Remove the single-used DestinationDriveLetter variable.

- Remove BuildInstallPaths() helper and use InitDestinationPaths()
  directly instead.

- Always mention the disk where the partition being formatted is.
- Cleanup old code comments, add assertions here & there...
This commit is contained in:
Hermès Bélusca-Maïto 2019-08-25 01:32:46 +02:00
parent c9537b392b
commit 626c654a10
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
3 changed files with 238 additions and 185 deletions

View file

@ -44,7 +44,6 @@ typedef struct _PARTENTRY
BOOLEAN BootIndicator;
UCHAR PartitionType;
ULONG HiddenSectors;
ULONG OnDiskPartitionNumber; /* Enumerated partition number (primary partitions first, excluding the extended partition container, then the logical partitions) */
ULONG PartitionNumber; /* Current partition number, only valid for the currently running NTOS instance */
ULONG PartitionIndex; /* Index in the LayoutBuffer->PartitionEntry[] cached array of the corresponding DiskEntry */
@ -231,6 +230,9 @@ BOOLEAN
IsSuperFloppy(
IN PDISKENTRY DiskEntry);
BOOLEAN
IsPartitionActive(
IN PPARTENTRY PartEntry);
PPARTLIST
CreatePartitionList(VOID);
@ -294,23 +296,27 @@ GetPrevPartition(
BOOLEAN
CreatePrimaryPartition(
IN PPARTLIST List,
IN PPARTENTRY SelectedEntry,
IN OUT PPARTENTRY PartEntry,
IN ULONGLONG SectorCount,
IN BOOLEAN AutoCreate);
BOOLEAN
CreateExtendedPartition(
IN PPARTLIST List,
IN PPARTENTRY SelectedEntry,
IN OUT PPARTENTRY PartEntry,
IN ULONGLONG SectorCount);
BOOLEAN
CreateLogicalPartition(
IN PPARTLIST List,
IN PPARTENTRY SelectedEntry,
IN OUT PPARTENTRY PartEntry,
IN ULONGLONG SectorCount,
IN BOOLEAN AutoCreate);
NTSTATUS
DismountVolume(
IN PPARTENTRY PartEntry);
BOOLEAN
DeletePartition(
IN PPARTLIST List,