[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

@ -101,11 +101,23 @@ InstallBtrfsBootCode(
// Formatting routines
//
struct _PARTENTRY; // Defined in partlist.h
NTSTATUS
ChkdskPartition(
IN PPARTENTRY PartEntry,
IN BOOLEAN FixErrors,
IN BOOLEAN Verbose,
IN BOOLEAN CheckOnlyIfDirty,
IN BOOLEAN ScanDrive,
IN PFMIFSCALLBACK Callback);
BOOLEAN
PreparePartitionForFormatting(
IN struct _PARTENTRY* PartEntry,
IN PCWSTR FileSystemName);
NTSTATUS
FormatPartition(
IN PPARTENTRY PartEntry,
IN PCWSTR FileSystemName,
IN FMIFS_MEDIA_FLAG MediaFlag,
IN PCWSTR Label,
IN BOOLEAN QuickFormat,
IN ULONG ClusterSize,
IN PFMIFSCALLBACK Callback);
/* EOF */