[SETUPLIB][USETUP] Cleanup some code in USETUP. Redefine FormatPartition() and ChkdskPartition() helpers

so that they wrap the needed init steps for formatting/chkdsk'ing.

These helpers now accept a PPARTENTRY, together with the usual
formatting/chkdsk parameters. The helpers now determine the actual
NT path to use, and can perform the init steps on the partition
before performing the actual operation.

In particular, FormatPartition() is now made GPT-compliant. The
partition type retrieved by FileSystemToMBRPartitionType() is now
used as a hint for choosing FAT32 over FAT12/16, and only in the
case of a MBR partition that is *NOT* a recognized OEM partition,
it is used for updating the corresponding partition type. (OEM
partitions must retain their original type.)

The OEM partition types we (and NT) can recognize are specified
e.g. in the Microsoft Open-Specification [MS-DMRP] Appendix B
5f5043a3-9e6d-40cc-a05b-1a4a3617df32

Introduce an IsOEMPartition() macro to help checking for these types
(its name is based on the Is***Partition() macros from ntdddisk.h,
and from a dmdskmgr.dll export of similar name).
This commit is contained in:
Hermès Bélusca-Maïto 2020-11-24 02:26:52 +01:00
parent 9735a8379f
commit 05cd77028c
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
8 changed files with 235 additions and 170 deletions

View file

@ -20,6 +20,25 @@ typedef struct _PARTITION_TYPE
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