reactos/base/setup/lib/utils/partlist.h

400 lines
10 KiB
C
Raw Normal View History

/*
* PROJECT: ReactOS Setup Library
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Partition list functions
* COPYRIGHT: Copyright 2003-2019 Casper S. Hornstrup (chorns@users.sourceforge.net)
* Copyright 2018-2019 Hermes Belusca-Maito
*/
#pragma once
/* HELPERS FOR PARTITION TYPES **********************************************/
typedef struct _PARTITION_TYPE
{
UCHAR Type;
PCHAR Description;
} PARTITION_TYPE, *PPARTITION_TYPE;
#define NUM_PARTITION_TYPE_ENTRIES 143
extern PARTITION_TYPE PartitionTypes[NUM_PARTITION_TYPE_ENTRIES];
/* EXTRA HANDFUL MACROS *****************************************************/
// NOTE: They should be moved into some global header.
/* OEM MBR partition types recognized by NT (see [MS-DMRP] Appendix B) */
#define PARTITION_EISA 0x12 // EISA partition
#define PARTITION_HIBERNATION 0x84 // Hibernation partition for laptops
#define PARTITION_DIAGNOSTIC 0xA0 // Diagnostic partition on some Hewlett-Packard (HP) notebooks
#define PARTITION_DELL 0xDE // Dell partition
#define PARTITION_IBM 0xFE // IBM Initial Microprogram Load (IML) partition
#define IsOEMPartition(PartitionType) \
( ((PartitionType) == PARTITION_EISA) || \
((PartitionType) == PARTITION_HIBERNATION) || \
((PartitionType) == PARTITION_DIAGNOSTIC) || \
((PartitionType) == PARTITION_DELL) || \
((PartitionType) == PARTITION_IBM) )
/* PARTITION UTILITY FUNCTIONS **********************************************/
typedef enum _FORMATSTATE
{
Unformatted,
UnformattedOrDamaged,
UnknownFormat,
Preformatted,
Formatted
} FORMATSTATE, *PFORMATSTATE;
typedef struct _PARTENTRY
{
LIST_ENTRY ListEntry;
/* The disk this partition belongs to */
struct _DISKENTRY *DiskEntry;
/* Partition geometry */
ULARGE_INTEGER StartSector;
ULARGE_INTEGER SectorCount;
BOOLEAN BootIndicator; // NOTE: See comment for the PARTLIST::SystemPartition member.
UCHAR PartitionType;
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 */
WCHAR DriveLetter;
WCHAR VolumeLabel[20];
WCHAR FileSystem[MAX_PATH+1];
FORMATSTATE FormatState;
BOOLEAN LogicalPartition;
/* Partition is partitioned disk space */
BOOLEAN IsPartitioned;
/** The following three properties may be replaced by flags **/
/* Partition is new, table does not exist on disk yet */
BOOLEAN New;
/* Partition was created automatically */
BOOLEAN AutoCreate;
/* Partition must be checked */
BOOLEAN NeedsCheck;
} PARTENTRY, *PPARTENTRY;
typedef struct _DISKENTRY
{
LIST_ENTRY ListEntry;
/* The list of disks/partitions this disk belongs to */
struct _PARTLIST *PartList;
[SETUPLIB][USETUP] Improve disk HW numbering, removable disk support, and "super-floppy" partitioning. Nowadays more and more people try to install ReactOS from removable drives (e.g. USB sticks) onto fixed HDDs, or try to install it into USB sticks too. Both fixed and removable drives, as well as partitions on these, are represented in NT using the same device name format: \Device\HarddiskM\PartitionN , with an increasing disk number M. Using this number for building the corresponding firmware-specific ARC multi(x)disk(y)rdisk(z) path used by the NT/ROS loader (FreeLdr, ...) is then prone to error since there may have been removable drives inserted and accounted for in the calculation of the disk number. These drives must be correctly subtracted in order to generate the correct ARC path, valid once all the removable drives have been ejected (which should also be the situation seen from the BIOS when booting up, except of course if you boot on a USB stick). This problem is now solved. Note that it matters only for the disks that have also been enumerated by the firmware (BIOS; Int 13h). We don't have to care about the other drives, since the ARC path will be of a different format and will not use the disk number (instead, the SCSI coordinates are used). We also try to enumerate all the disks found in all the possible disk adapters and controllers enumerated in the Hardware registry tree (and that are visible by FreeLdr) in order to cover all. Finally, we detect whether a disk reports as a "super-floppy", i.e. an unpartitioned disk with a valid VBR. This is indeed how a standard floppy disk looks like, or how USB sticks are partitioned on Windows. Such disk is reported has having only one single partition starting at the beginning of the disk, with partition number == 0, its type being FAT16 non-bootable. This allows us to forbid creating any new partitions on such disks. Note that accessing either \Device\HarddiskN\Partition0 or Partition1 on such a disk returns the same data. Note also that on the contrary, regular MBR-partitioned disks would report at least four partitions entries, instead of just one. The other improvements are: - Do *NOT* write any MBR on a disk partitioned as "super-floppy". CORE-13703 - Fix the computed disk identifier, of format: %08x-%08x-%c . The numbers are respectively the checksum of the first sector, and the disk signature. The terminating letter is A or X, depending whether the first sector ends with 0x55AA/0xAA55 or not (see also commit 5053f1f5). - Warn if the user attempts to install ReactOS on a disk that is not visible by the firmware of his computer, because it may not be bootable.
2019-03-11 23:13:25 +00:00
MEDIA_TYPE MediaType; /* FixedMedia or RemovableMedia */
/* Disk geometry */
ULONGLONG Cylinders;
ULONG TracksPerCylinder;
ULONG SectorsPerTrack;
ULONG BytesPerSector;
ULARGE_INTEGER SectorCount;
ULONG SectorAlignment;
ULONG CylinderAlignment;
[SETUPLIB][USETUP] Improve disk HW numbering, removable disk support, and "super-floppy" partitioning. Nowadays more and more people try to install ReactOS from removable drives (e.g. USB sticks) onto fixed HDDs, or try to install it into USB sticks too. Both fixed and removable drives, as well as partitions on these, are represented in NT using the same device name format: \Device\HarddiskM\PartitionN , with an increasing disk number M. Using this number for building the corresponding firmware-specific ARC multi(x)disk(y)rdisk(z) path used by the NT/ROS loader (FreeLdr, ...) is then prone to error since there may have been removable drives inserted and accounted for in the calculation of the disk number. These drives must be correctly subtracted in order to generate the correct ARC path, valid once all the removable drives have been ejected (which should also be the situation seen from the BIOS when booting up, except of course if you boot on a USB stick). This problem is now solved. Note that it matters only for the disks that have also been enumerated by the firmware (BIOS; Int 13h). We don't have to care about the other drives, since the ARC path will be of a different format and will not use the disk number (instead, the SCSI coordinates are used). We also try to enumerate all the disks found in all the possible disk adapters and controllers enumerated in the Hardware registry tree (and that are visible by FreeLdr) in order to cover all. Finally, we detect whether a disk reports as a "super-floppy", i.e. an unpartitioned disk with a valid VBR. This is indeed how a standard floppy disk looks like, or how USB sticks are partitioned on Windows. Such disk is reported has having only one single partition starting at the beginning of the disk, with partition number == 0, its type being FAT16 non-bootable. This allows us to forbid creating any new partitions on such disks. Note that accessing either \Device\HarddiskN\Partition0 or Partition1 on such a disk returns the same data. Note also that on the contrary, regular MBR-partitioned disks would report at least four partitions entries, instead of just one. The other improvements are: - Do *NOT* write any MBR on a disk partitioned as "super-floppy". CORE-13703 - Fix the computed disk identifier, of format: %08x-%08x-%c . The numbers are respectively the checksum of the first sector, and the disk signature. The terminating letter is A or X, depending whether the first sector ends with 0x55AA/0xAA55 or not (see also commit 5053f1f5). - Warn if the user attempts to install ReactOS on a disk that is not visible by the firmware of his computer, because it may not be bootable.
2019-03-11 23:13:25 +00:00
/* BIOS Firmware parameters */
BOOLEAN BiosFound;
[SETUPLIB][USETUP] Improve disk HW numbering, removable disk support, and "super-floppy" partitioning. Nowadays more and more people try to install ReactOS from removable drives (e.g. USB sticks) onto fixed HDDs, or try to install it into USB sticks too. Both fixed and removable drives, as well as partitions on these, are represented in NT using the same device name format: \Device\HarddiskM\PartitionN , with an increasing disk number M. Using this number for building the corresponding firmware-specific ARC multi(x)disk(y)rdisk(z) path used by the NT/ROS loader (FreeLdr, ...) is then prone to error since there may have been removable drives inserted and accounted for in the calculation of the disk number. These drives must be correctly subtracted in order to generate the correct ARC path, valid once all the removable drives have been ejected (which should also be the situation seen from the BIOS when booting up, except of course if you boot on a USB stick). This problem is now solved. Note that it matters only for the disks that have also been enumerated by the firmware (BIOS; Int 13h). We don't have to care about the other drives, since the ARC path will be of a different format and will not use the disk number (instead, the SCSI coordinates are used). We also try to enumerate all the disks found in all the possible disk adapters and controllers enumerated in the Hardware registry tree (and that are visible by FreeLdr) in order to cover all. Finally, we detect whether a disk reports as a "super-floppy", i.e. an unpartitioned disk with a valid VBR. This is indeed how a standard floppy disk looks like, or how USB sticks are partitioned on Windows. Such disk is reported has having only one single partition starting at the beginning of the disk, with partition number == 0, its type being FAT16 non-bootable. This allows us to forbid creating any new partitions on such disks. Note that accessing either \Device\HarddiskN\Partition0 or Partition1 on such a disk returns the same data. Note also that on the contrary, regular MBR-partitioned disks would report at least four partitions entries, instead of just one. The other improvements are: - Do *NOT* write any MBR on a disk partitioned as "super-floppy". CORE-13703 - Fix the computed disk identifier, of format: %08x-%08x-%c . The numbers are respectively the checksum of the first sector, and the disk signature. The terminating letter is A or X, depending whether the first sector ends with 0x55AA/0xAA55 or not (see also commit 5053f1f5). - Warn if the user attempts to install ReactOS on a disk that is not visible by the firmware of his computer, because it may not be bootable.
2019-03-11 23:13:25 +00:00
ULONG HwAdapterNumber;
ULONG HwControllerNumber;
ULONG HwDiskNumber; /* Disk number currently assigned on the system */
ULONG HwFixedDiskNumber; /* Disk number on the system when *ALL* removable disks are not connected */
// ULONG Signature; // Obtained from LayoutBuffer->Signature
// ULONG Checksum;
/* SCSI parameters */
ULONG DiskNumber;
// SCSI_ADDRESS;
USHORT Port;
USHORT Bus;
USHORT Id;
/* Has the partition list been modified? */
BOOLEAN Dirty;
BOOLEAN NewDisk; /* If TRUE, the disk is uninitialized */
PARTITION_STYLE DiskStyle; /* MBR/GPT-partitioned disk, or uninitialized disk (RAW) */
UNICODE_STRING DriverName;
PDRIVE_LAYOUT_INFORMATION LayoutBuffer;
// TODO: When adding support for GPT disks:
// Use PDRIVE_LAYOUT_INFORMATION_EX which indicates whether
// the disk is MBR, GPT, or unknown (uninitialized).
// Depending on the style, either use the MBR or GPT partition info.
LIST_ENTRY PrimaryPartListHead; /* List of primary partitions */
LIST_ENTRY LogicalPartListHead; /* List of logical partitions (Valid only for MBR-partitioned disks) */
/* Pointer to the unique extended partition on this disk (Valid only for MBR-partitioned disks) */
PPARTENTRY ExtendedPartition;
} DISKENTRY, *PDISKENTRY;
[SETUPLIB][USETUP] Improve disk HW numbering, removable disk support, and "super-floppy" partitioning. Nowadays more and more people try to install ReactOS from removable drives (e.g. USB sticks) onto fixed HDDs, or try to install it into USB sticks too. Both fixed and removable drives, as well as partitions on these, are represented in NT using the same device name format: \Device\HarddiskM\PartitionN , with an increasing disk number M. Using this number for building the corresponding firmware-specific ARC multi(x)disk(y)rdisk(z) path used by the NT/ROS loader (FreeLdr, ...) is then prone to error since there may have been removable drives inserted and accounted for in the calculation of the disk number. These drives must be correctly subtracted in order to generate the correct ARC path, valid once all the removable drives have been ejected (which should also be the situation seen from the BIOS when booting up, except of course if you boot on a USB stick). This problem is now solved. Note that it matters only for the disks that have also been enumerated by the firmware (BIOS; Int 13h). We don't have to care about the other drives, since the ARC path will be of a different format and will not use the disk number (instead, the SCSI coordinates are used). We also try to enumerate all the disks found in all the possible disk adapters and controllers enumerated in the Hardware registry tree (and that are visible by FreeLdr) in order to cover all. Finally, we detect whether a disk reports as a "super-floppy", i.e. an unpartitioned disk with a valid VBR. This is indeed how a standard floppy disk looks like, or how USB sticks are partitioned on Windows. Such disk is reported has having only one single partition starting at the beginning of the disk, with partition number == 0, its type being FAT16 non-bootable. This allows us to forbid creating any new partitions on such disks. Note that accessing either \Device\HarddiskN\Partition0 or Partition1 on such a disk returns the same data. Note also that on the contrary, regular MBR-partitioned disks would report at least four partitions entries, instead of just one. The other improvements are: - Do *NOT* write any MBR on a disk partitioned as "super-floppy". CORE-13703 - Fix the computed disk identifier, of format: %08x-%08x-%c . The numbers are respectively the checksum of the first sector, and the disk signature. The terminating letter is A or X, depending whether the first sector ends with 0x55AA/0xAA55 or not (see also commit 5053f1f5). - Warn if the user attempts to install ReactOS on a disk that is not visible by the firmware of his computer, because it may not be bootable.
2019-03-11 23:13:25 +00:00
typedef struct _BIOSDISKENTRY
{
LIST_ENTRY ListEntry;
ULONG AdapterNumber;
ULONG ControllerNumber;
ULONG DiskNumber;
ULONG Signature;
ULONG Checksum;
PDISKENTRY DiskEntry; /* Corresponding recognized disk; is NULL if the disk is not recognized */ // RecognizedDiskEntry;
CM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry;
CM_INT13_DRIVE_PARAMETER Int13DiskData;
} BIOSDISKENTRY, *PBIOSDISKENTRY;
typedef struct _PARTLIST
{
/*
* The system partition where the boot manager resides.
* The corresponding system disk is obtained via:
* SystemPartition->DiskEntry.
*/
// NOTE: It seems to appear that the specifications of ARC and (u)EFI
// actually allow for multiple system partitions to exist on the system.
// If so we should instead rely on the BootIndicator bit of the PARTENTRY
// structure in order to find these.
PPARTENTRY SystemPartition;
LIST_ENTRY DiskListHead;
LIST_ENTRY BiosDiskListHead;
} PARTLIST, *PPARTLIST;
#define PARTITION_TBL_SIZE 4
#define PARTITION_MAGIC 0xAA55
/* Defines system type for MBR showing that a GPT is following */
#define EFI_PMBR_OSTYPE_EFI 0xEE
#include <pshpack1.h>
typedef struct _PARTITION
{
unsigned char BootFlags; /* bootable? 0=no, 128=yes */
unsigned char StartingHead; /* beginning head number */
unsigned char StartingSector; /* beginning sector number */
unsigned char StartingCylinder; /* 10 bit nmbr, with high 2 bits put in begsect */
unsigned char PartitionType; /* Operating System type indicator code */
unsigned char EndingHead; /* ending head number */
unsigned char EndingSector; /* ending sector number */
unsigned char EndingCylinder; /* also a 10 bit nmbr, with same high 2 bit trick */
unsigned int StartingBlock; /* first sector relative to start of disk */
unsigned int SectorCount; /* number of sectors in partition */
} PARTITION, *PPARTITION;
typedef struct _PARTITION_SECTOR
{
UCHAR BootCode[440]; /* 0x000 */
ULONG Signature; /* 0x1B8 */
UCHAR Reserved[2]; /* 0x1BC */
PARTITION Partition[PARTITION_TBL_SIZE]; /* 0x1BE */
USHORT Magic; /* 0x1FE */
} PARTITION_SECTOR, *PPARTITION_SECTOR;
#include <poppack.h>
typedef struct
{
LIST_ENTRY ListEntry;
ULONG DiskNumber;
ULONG Identifier;
ULONG Signature;
} BIOS_DISK, *PBIOS_DISK;
ULONGLONG
AlignDown(
IN ULONGLONG Value,
IN ULONG Alignment);
ULONGLONG
AlignUp(
IN ULONGLONG Value,
IN ULONG Alignment);
ULONGLONG
RoundingDivide(
IN ULONGLONG Dividend,
IN ULONGLONG Divisor);
[SETUPLIB][USETUP] Improve disk HW numbering, removable disk support, and "super-floppy" partitioning. Nowadays more and more people try to install ReactOS from removable drives (e.g. USB sticks) onto fixed HDDs, or try to install it into USB sticks too. Both fixed and removable drives, as well as partitions on these, are represented in NT using the same device name format: \Device\HarddiskM\PartitionN , with an increasing disk number M. Using this number for building the corresponding firmware-specific ARC multi(x)disk(y)rdisk(z) path used by the NT/ROS loader (FreeLdr, ...) is then prone to error since there may have been removable drives inserted and accounted for in the calculation of the disk number. These drives must be correctly subtracted in order to generate the correct ARC path, valid once all the removable drives have been ejected (which should also be the situation seen from the BIOS when booting up, except of course if you boot on a USB stick). This problem is now solved. Note that it matters only for the disks that have also been enumerated by the firmware (BIOS; Int 13h). We don't have to care about the other drives, since the ARC path will be of a different format and will not use the disk number (instead, the SCSI coordinates are used). We also try to enumerate all the disks found in all the possible disk adapters and controllers enumerated in the Hardware registry tree (and that are visible by FreeLdr) in order to cover all. Finally, we detect whether a disk reports as a "super-floppy", i.e. an unpartitioned disk with a valid VBR. This is indeed how a standard floppy disk looks like, or how USB sticks are partitioned on Windows. Such disk is reported has having only one single partition starting at the beginning of the disk, with partition number == 0, its type being FAT16 non-bootable. This allows us to forbid creating any new partitions on such disks. Note that accessing either \Device\HarddiskN\Partition0 or Partition1 on such a disk returns the same data. Note also that on the contrary, regular MBR-partitioned disks would report at least four partitions entries, instead of just one. The other improvements are: - Do *NOT* write any MBR on a disk partitioned as "super-floppy". CORE-13703 - Fix the computed disk identifier, of format: %08x-%08x-%c . The numbers are respectively the checksum of the first sector, and the disk signature. The terminating letter is A or X, depending whether the first sector ends with 0x55AA/0xAA55 or not (see also commit 5053f1f5). - Warn if the user attempts to install ReactOS on a disk that is not visible by the firmware of his computer, because it may not be bootable.
2019-03-11 23:13:25 +00:00
BOOLEAN
IsSuperFloppy(
IN PDISKENTRY DiskEntry);
[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...
2019-08-24 23:32:46 +00:00
BOOLEAN
IsPartitionActive(
IN PPARTENTRY PartEntry);
PPARTLIST
CreatePartitionList(VOID);
VOID
DestroyPartitionList(
IN PPARTLIST List);
PDISKENTRY
GetDiskByBiosNumber(
IN PPARTLIST List,
[SETUPLIB][USETUP] Improve disk HW numbering, removable disk support, and "super-floppy" partitioning. Nowadays more and more people try to install ReactOS from removable drives (e.g. USB sticks) onto fixed HDDs, or try to install it into USB sticks too. Both fixed and removable drives, as well as partitions on these, are represented in NT using the same device name format: \Device\HarddiskM\PartitionN , with an increasing disk number M. Using this number for building the corresponding firmware-specific ARC multi(x)disk(y)rdisk(z) path used by the NT/ROS loader (FreeLdr, ...) is then prone to error since there may have been removable drives inserted and accounted for in the calculation of the disk number. These drives must be correctly subtracted in order to generate the correct ARC path, valid once all the removable drives have been ejected (which should also be the situation seen from the BIOS when booting up, except of course if you boot on a USB stick). This problem is now solved. Note that it matters only for the disks that have also been enumerated by the firmware (BIOS; Int 13h). We don't have to care about the other drives, since the ARC path will be of a different format and will not use the disk number (instead, the SCSI coordinates are used). We also try to enumerate all the disks found in all the possible disk adapters and controllers enumerated in the Hardware registry tree (and that are visible by FreeLdr) in order to cover all. Finally, we detect whether a disk reports as a "super-floppy", i.e. an unpartitioned disk with a valid VBR. This is indeed how a standard floppy disk looks like, or how USB sticks are partitioned on Windows. Such disk is reported has having only one single partition starting at the beginning of the disk, with partition number == 0, its type being FAT16 non-bootable. This allows us to forbid creating any new partitions on such disks. Note that accessing either \Device\HarddiskN\Partition0 or Partition1 on such a disk returns the same data. Note also that on the contrary, regular MBR-partitioned disks would report at least four partitions entries, instead of just one. The other improvements are: - Do *NOT* write any MBR on a disk partitioned as "super-floppy". CORE-13703 - Fix the computed disk identifier, of format: %08x-%08x-%c . The numbers are respectively the checksum of the first sector, and the disk signature. The terminating letter is A or X, depending whether the first sector ends with 0x55AA/0xAA55 or not (see also commit 5053f1f5). - Warn if the user attempts to install ReactOS on a disk that is not visible by the firmware of his computer, because it may not be bootable.
2019-03-11 23:13:25 +00:00
IN ULONG HwDiskNumber);
PDISKENTRY
GetDiskByNumber(
IN PPARTLIST List,
IN ULONG DiskNumber);
PDISKENTRY
GetDiskBySCSI(
IN PPARTLIST List,
IN USHORT Port,
IN USHORT Bus,
IN USHORT Id);
PDISKENTRY
GetDiskBySignature(
IN PPARTLIST List,
IN ULONG Signature);
PPARTENTRY
GetPartition(
// IN PPARTLIST List,
IN PDISKENTRY DiskEntry,
IN ULONG PartitionNumber);
BOOLEAN
GetDiskOrPartition(
IN PPARTLIST List,
IN ULONG DiskNumber,
IN ULONG PartitionNumber OPTIONAL,
OUT PDISKENTRY* pDiskEntry,
OUT PPARTENTRY* pPartEntry OPTIONAL);
PPARTENTRY
SelectPartition(
IN PPARTLIST List,
IN ULONG DiskNumber,
IN ULONG PartitionNumber);
PPARTENTRY
GetNextPartition(
IN PPARTLIST List,
IN PPARTENTRY CurrentPart OPTIONAL);
PPARTENTRY
GetPrevPartition(
IN PPARTLIST List,
IN PPARTENTRY CurrentPart OPTIONAL);
BOOLEAN
CreatePrimaryPartition(
IN PPARTLIST List,
[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...
2019-08-24 23:32:46 +00:00
IN OUT PPARTENTRY PartEntry,
IN ULONGLONG SectorCount,
IN BOOLEAN AutoCreate);
BOOLEAN
CreateExtendedPartition(
IN PPARTLIST List,
[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...
2019-08-24 23:32:46 +00:00
IN OUT PPARTENTRY PartEntry,
IN ULONGLONG SectorCount);
BOOLEAN
CreateLogicalPartition(
IN PPARTLIST List,
[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...
2019-08-24 23:32:46 +00:00
IN OUT PPARTENTRY PartEntry,
IN ULONGLONG SectorCount,
IN BOOLEAN AutoCreate);
[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...
2019-08-24 23:32:46 +00:00
NTSTATUS
DismountVolume(
IN PPARTENTRY PartEntry);
BOOLEAN
DeletePartition(
IN PPARTLIST List,
IN PPARTENTRY PartEntry,
OUT PPARTENTRY* FreeRegion OPTIONAL);
PPARTENTRY
FindSupportedSystemPartition(
IN PPARTLIST List,
IN BOOLEAN ForceSelect,
IN PDISKENTRY AlternativeDisk OPTIONAL,
IN PPARTENTRY AlternativePart OPTIONAL);
BOOLEAN
SetActivePartition(
IN PPARTLIST List,
IN PPARTENTRY PartEntry,
IN PPARTENTRY OldActivePart OPTIONAL);
NTSTATUS
WritePartitions(
IN PDISKENTRY DiskEntry);
BOOLEAN
WritePartitionsToDisk(
IN PPARTLIST List);
BOOLEAN
SetMountedDeviceValue(
IN WCHAR Letter,
IN ULONG Signature,
IN LARGE_INTEGER StartingOffset);
BOOLEAN
SetMountedDeviceValues(
IN PPARTLIST List);
VOID
SetMBRPartitionType(
IN PPARTENTRY PartEntry,
IN UCHAR PartitionType);
ERROR_NUMBER
PrimaryPartitionCreationChecks(
IN PPARTENTRY PartEntry);
ERROR_NUMBER
ExtendedPartitionCreationChecks(
IN PPARTENTRY PartEntry);
ERROR_NUMBER
LogicalPartitionCreationChecks(
IN PPARTENTRY PartEntry);
BOOLEAN
GetNextUnformattedPartition(
IN PPARTLIST List,
OUT PDISKENTRY *pDiskEntry OPTIONAL,
OUT PPARTENTRY *pPartEntry);
BOOLEAN
GetNextUncheckedPartition(
IN PPARTLIST List,
OUT PDISKENTRY *pDiskEntry OPTIONAL,
OUT PPARTENTRY *pPartEntry);
/* EOF */