From 746f91acc769b2b5b4ad44a31a1aa70e5619ae57 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Tue, 31 May 2022 16:30:19 +0100 Subject: [PATCH] [core] work around Windows refusing to mount Linux MBR partitions on FIXED drives * Fixes #1922. * Also fix a typo and apply minor updates for GitHub Actions workflows. --- .github/workflows/codeql.nope | 2 +- .github/workflows/coverity.yml | 2 -- .github/workflows/vs2022.yml | 2 +- src/format.c | 15 +++++++++------ src/rufus.rc | 10 +++++----- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/codeql.nope b/.github/workflows/codeql.nope index e1c70317..2939dae2 100644 --- a/.github/workflows/codeql.nope +++ b/.github/workflows/codeql.nope @@ -14,7 +14,7 @@ env: jobs: CodeQL-Build: - runs-on: windows-2022 + runs-on: windows-latest permissions: security-events: write diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index b9010753..d5da97b3 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -45,8 +45,6 @@ jobs: - name: Add MSBuild to PATH uses: microsoft/setup-msbuild@v1.1 - with: - msbuild-architecture: x64 - name: Build with Coverity run: | diff --git a/.github/workflows/vs2022.yml b/.github/workflows/vs2022.yml index df98e554..acefe4f4 100644 --- a/.github/workflows/vs2022.yml +++ b/.github/workflows/vs2022.yml @@ -31,7 +31,7 @@ env: jobs: VS2022-Build: - runs-on: windows-2022 + runs-on: windows-latest strategy: matrix: diff --git a/src/format.c b/src/format.c index 75908563..62980dc2 100644 --- a/src/format.c +++ b/src/format.c @@ -1884,7 +1884,7 @@ out: DWORD WINAPI FormatThread(void* param) { int r; - BOOL ret, use_large_fat32, windows_to_go, actual_lock_drive = lock_drive; + BOOL ret, use_large_fat32, windows_to_go, actual_lock_drive = lock_drive, write_as_ext = FALSE; // Windows 11 and VDS (which I suspect is what fmifs.dll's FormatEx() is now calling behind the scenes) // require us to unlock the physical drive to format the drive, else access denied is returned. BOOL need_logical = FALSE, must_unlock_physical = (use_vds || nWindowsVersion >= WINDOWS_11); @@ -1931,6 +1931,9 @@ DWORD WINAPI FormatThread(void* param) // 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); PrintInfoDebug(0, MSG_225); hPhysicalDrive = GetPhysicalHandle(DriveIndex, actual_lock_drive, FALSE, !actual_lock_drive); @@ -1993,7 +1996,7 @@ DWORD WINAPI FormatThread(void* param) goto out; // If the call succeeds (and we don't get a NULL logical handle as returned for // unpartitioned drives), try to unmount the volume. - } else if ((hLogicalVolume == NULL) && (!UnmountVolume(hLogicalVolume))) { + } else if ((hLogicalVolume != NULL) && (!UnmountVolume(hLogicalVolume))) { uprintf("Trying to continue regardless..."); } } @@ -2139,8 +2142,8 @@ DWORD WINAPI FormatThread(void* param) // Wait for the logical drive we just created to appear uprintf("Waiting for logical drive to reappear..."); Sleep(200); - if (write_as_esp) { - // Can't format the ESP unless we mount it ourself + if (write_as_esp || write_as_ext) { + // Can't format ESPs or ext2/ext3 partitions unless we mount them ourselves volume_name = AltMountVolume(DriveIndex, partition_offset[PI_MAIN], FALSE); if (volume_name == NULL) { FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_ASSIGN_LETTER); @@ -2214,7 +2217,7 @@ DWORD WINAPI FormatThread(void* param) } Sleep(200); - if (!write_as_esp) { + if (!write_as_esp && !write_as_ext) { WaitForLogical(DriveIndex, 0); // Try to continue CHECK_FOR_USER_CANCEL; @@ -2409,7 +2412,7 @@ DWORD WINAPI FormatThread(void* param) } out: - if (write_as_esp && volume_name != NULL) + if ((write_as_esp || write_as_ext) && volume_name != NULL) AltUnmountVolume(volume_name, TRUE); else safe_free(volume_name); diff --git a/src/rufus.rc b/src/rufus.rc index 4b93971e..e1e60a7e 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -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.1891" +CAPTION "Rufus 3.19.1892" 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,1891,0 - PRODUCTVERSION 3,19,1891,0 + FILEVERSION 3,19,1892,0 + PRODUCTVERSION 3,19,1892,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.1891" + VALUE "FileVersion", "3.19.1892" 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.1891" + VALUE "ProductVersion", "3.19.1892" END END BLOCK "VarFileInfo"