[core] use Linux Data GUID for ext GPT partitions

* Also add an IS_EXT() macro
This commit is contained in:
Pete Batard 2022-06-08 19:37:24 +01:00
parent c2cd5185a3
commit d8af83dd14
No known key found for this signature in database
GPG Key ID: 38E0CF5E69EDD671
6 changed files with 26 additions and 16 deletions

View File

@ -2427,7 +2427,12 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
return FALSE;
}
} else {
DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionType = write_as_esp ? PARTITION_GENERIC_ESP : PARTITION_MICROSOFT_DATA;
if (write_as_esp)
DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionType = PARTITION_GENERIC_ESP;
else if (IS_EXT(file_system))
DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionType = PARTITION_LINUX_DATA;
else
DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionType = PARTITION_MICROSOFT_DATA;
IGNORE_RETVAL(CoCreateGuid(&DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionId));
wcsncpy(DriveLayoutEx.PartitionEntry[pn].Gpt.Name, main_part_name, ARRAYSIZE(DriveLayoutEx.PartitionEntry[pn].Gpt.Name));
}
@ -2453,9 +2458,14 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
partition_offset[PI_ESP] = SelectedDrive.PartitionOffset[pn];
if (partition_style == PARTITION_STYLE_GPT) {
DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionType = (extra_partitions & XP_ESP) ? PARTITION_GENERIC_ESP : PARTITION_MICROSOFT_DATA;
if (extra_partitions & XP_ESP)
DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionType = PARTITION_GENERIC_ESP;
else if (extra_partitions & XP_CASPER)
DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionType = PARTITION_LINUX_DATA;
else
DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionType = PARTITION_MICROSOFT_DATA;
if (extra_partitions & XP_UEFI_NTFS) {
// Prevent a drive letter to be assigned to the UEFI:NTFS partition
// Prevent a drive letter from being assigned to the UEFI:NTFS partition
DriveLayoutEx.PartitionEntry[pn].Gpt.Attributes = GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER;
#if !defined(_DEBUG)
// Also make the partition read-only for release versions

View File

@ -671,7 +671,7 @@ static BOOL FormatPartition(DWORD DriveIndex, uint64_t PartitionOffset, DWORD Un
actual_fs_type = FSType;
if ((FSType == FS_FAT32) && ((SelectedDrive.DiskSize > LARGE_FAT32_SIZE) || (force_large_fat32) || (Flags & FP_LARGE_FAT32)))
return FormatLargeFAT32(DriveIndex, PartitionOffset, UnitAllocationSize, FileSystemLabel[FSType], Label, Flags);
else if (FSType >= FS_EXT2)
else if (IS_EXT(FSType))
return FormatExtFs(DriveIndex, PartitionOffset, UnitAllocationSize, FileSystemLabel[FSType], Label, Flags);
else if (use_vds)
return FormatNativeVds(DriveIndex, PartitionOffset, UnitAllocationSize, FileSystemLabel[FSType], Label, Flags);
@ -1925,15 +1925,14 @@ DWORD WINAPI FormatThread(void* param)
extra_partitions = XP_COMPAT;
// On pre 1703 platforms (and even on later ones), anything with ext2/ext3 doesn't sit
// too well with Windows. Same with ESPs. Relaxing our locking rules seems to help...
if ((extra_partitions & (XP_ESP | XP_CASPER)) || (fs_type >= FS_EXT2))
if ((extra_partitions & (XP_ESP | XP_CASPER)) || IS_EXT(fs_type))
actual_lock_drive = FALSE;
// Windows 11 is a lot more proactive in locking ESPs and MSRs than previous versions
// were, meaning that we also can't lock the drive without incurring errors...
if ((nWindowsVersion >= WINDOWS_11) && extra_partitions)
actual_lock_drive = FALSE;
// Fixed drives + ext2/ext3 don't play nice and require the same handling as ESPs
write_as_ext = (fs_type >= FS_EXT2 && fs_type <= FS_EXT4) &&
(GetDriveTypeFromIndex(DriveIndex) == DRIVE_FIXED);
write_as_ext = IS_EXT(fs_type) && (GetDriveTypeFromIndex(DriveIndex) == DRIVE_FIXED);
PrintInfoDebug(0, MSG_225);
hPhysicalDrive = GetPhysicalHandle(DriveIndex, actual_lock_drive, FALSE, !actual_lock_drive);
@ -2254,7 +2253,7 @@ DWORD WINAPI FormatThread(void* param)
if ((fs_type < FS_EXT2) && !GetVolumeInformationU(drive_name, img_report.usb_label,
ARRAYSIZE(img_report.usb_label), NULL, NULL, NULL, NULL, 0)) {
uprintf("Warning: Failed to refresh label: %s", WindowsErrorString());
} else if ((fs_type >= FS_EXT2) && (fs_type <= FS_EXT4)) {
} else if (IS_EXT(fs_type)) {
const char* ext_label = GetExtFsLabel(DriveIndex, 0);
if (ext_label != NULL)
static_strcpy(img_report.usb_label, label);

View File

@ -782,7 +782,7 @@ static void EnableExtendedLabel(BOOL enable, BOOL remove_checkboxes)
static UINT checked, state = 0;
HWND hCtrl = GetDlgItem(hMainDialog, IDC_EXTENDED_LABEL);
if ((fs_type >= FS_EXT2) || ((boot_type == BT_IMAGE) && IS_DD_ONLY(img_report)))
if (IS_EXT(fs_type) || ((boot_type == BT_IMAGE) && IS_DD_ONLY(img_report)))
enable = FALSE;
if (remove_checkboxes) {

View File

@ -339,7 +339,8 @@ enum checksum_type {
#define IS_BIOS_BOOTABLE(r) (HAS_BOOTMGR(r) || HAS_SYSLINUX(r) || HAS_WINPE(r) || HAS_GRUB(r) || HAS_REACTOS(r) || HAS_KOLIBRIOS(r))
#define HAS_WINTOGO(r) (HAS_BOOTMGR(r) && IS_EFI_BOOTABLE(r) && HAS_WININST(r))
#define HAS_PERSISTENCE(r) ((HAS_SYSLINUX(r) || HAS_GRUB(r)) && !(HAS_WINDOWS(r) || HAS_REACTOS(r) || HAS_KOLIBRIOS(r)))
#define IS_FAT(fs) ((fs_type == FS_FAT16) || (fs_type == FS_FAT32))
#define IS_FAT(fs) ((fs == FS_FAT16) || (fs == FS_FAT32))
#define IS_EXT(fs) ((fs >= FS_EXT2) && (fs <= FS_EXT4))
#define SYMLINKS_RR 0x01
#define SYMLINKS_UDF 0x02

View File

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 3.19.1895"
CAPTION "Rufus 3.19.1896"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -395,8 +395,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,19,1895,0
PRODUCTVERSION 3,19,1895,0
FILEVERSION 3,19,1896,0
PRODUCTVERSION 3,19,1896,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -414,13 +414,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.19.1895"
VALUE "FileVersion", "3.19.1896"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2022 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-3.19.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.19.1895"
VALUE "ProductVersion", "3.19.1896"
END
END
BLOCK "VarFileInfo"

View File

@ -1201,7 +1201,7 @@ void InitProgress(BOOL bOnlyFormat)
// So, yeah, if you're doing slow format, or using Large FAT32, and have persistence, you'll see
// the progress bar revert during format on account that we reuse the same operation for both
// partitions. Maybe one day I'll be bothered to handle two separate OP_FORMAT ops...
if ((!IsChecked(IDC_QUICK_FORMAT)) || (persistence_size != 0) || (fs_type >= FS_EXT2) ||
if ((!IsChecked(IDC_QUICK_FORMAT)) || (persistence_size != 0) || IS_EXT(fs_type) ||
((fs_type == FS_FAT32) && ((SelectedDrive.DiskSize >= LARGE_FAT32_SIZE) || (force_large_fat32)))) {
nb_slots[OP_FORMAT] = -1;
nb_slots[OP_CREATE_FS] = 0;