Skip to content

Commit

Permalink
[core] avoid the creation of 'System Volume Information' for ESPs wri…
Browse files Browse the repository at this point in the history
…tten in DD mode

* Trying to mount accessible partitions after writing an image may lead to the
  creation of the infamous 'System Volume Information' folder on ESPs, which in
  turn leads to checksum errors for Ubuntu's boot/grub/efi.img (that maps to the
  Ubuntu ESP). So comment out that code.
* Also fix a missing CRLFs in the log after displaying write progress.
  • Loading branch information
pbatard committed May 18, 2021
1 parent 03ef8aa commit 3bb8370
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion res/appstore/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Identity
Name="19453.net.Rufus"
Publisher="CN=7AC86D13-3E5A-491A-ADD5-80095C212740"
Version="3.14.1791.0" />
Version="3.14.1792.0" />

<Properties>
<DisplayName>Rufus</DisplayName>
Expand Down
22 changes: 14 additions & 8 deletions src/format.c
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,7 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, BOOL bZeroDrive)
// Read block and compare against the block that needs to be written
s = ReadFile(hPhysicalDrive, cmp_buffer, read_size[0], &comp_size, NULL);
if ((!s) || (comp_size != read_size[0])) {
uprintf("Read error: Could not read data for fast zeroing comparison - %s", WindowsErrorString());
uprintf("\r\nRead error: Could not read data for fast zeroing comparison - %s", WindowsErrorString());
goto out;
}

Expand All @@ -1585,7 +1585,7 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, BOOL bZeroDrive)
// Move the file pointer position back for writing
li.QuadPart = wb;
if (!SetFilePointerEx(hPhysicalDrive, li, NULL, FILE_BEGIN)) {
uprintf("Error: Could not reset position - %s", WindowsErrorString());
uprintf("\r\nError: Could not reset position - %s", WindowsErrorString());
goto out;
}
// Throttle read operations
Expand All @@ -1598,9 +1598,9 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, BOOL bZeroDrive)
if ((s) && (write_size == read_size[0]))
break;
if (s)
uprintf("Write error: Wrote %d bytes, expected %d bytes", write_size, read_size[0]);
uprintf("\r\nWrite error: Wrote %d bytes, expected %d bytes", write_size, read_size[0]);
else
uprintf("Write error at sector %lld: %s", wb / SelectedDrive.SectorSize, WindowsErrorString());
uprintf("\r\nWrite error at sector %lld: %s", wb / SelectedDrive.SectorSize, WindowsErrorString());
if (i < WRITE_RETRIES) {
li.QuadPart = wb;
uprintf("Retrying in %d seconds...", WRITE_TIMEOUT / 1000);
Expand Down Expand Up @@ -1688,7 +1688,7 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, BOOL bZeroDrive)
// 1. Wait for the current read operation to complete (and update the read size)
if ((!WaitFileAsync(hSourceImage, DRIVE_ACCESS_TIMEOUT)) ||
(!GetSizeAsync(hSourceImage, &read_size[read_bufnum]))) {
uprintf("Read error: %s", WindowsErrorString());
uprintf("\r\nRead error: %s", WindowsErrorString());
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_READ_FAULT;
goto out;
}
Expand Down Expand Up @@ -1716,9 +1716,9 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, BOOL bZeroDrive)
if ((s) && (write_size == read_size[proc_bufnum]))
break;
if (s)
uprintf("Write error: Wrote %d bytes, expected %d bytes", write_size, read_size[proc_bufnum]);
uprintf("\r\nWrite error: Wrote %d bytes, expected %d bytes", write_size, read_size[proc_bufnum]);
else
uprintf("Write error at sector %lld: %s", wb / SelectedDrive.SectorSize, WindowsErrorString());
uprintf("\r\nWrite error at sector %lld: %s", wb / SelectedDrive.SectorSize, WindowsErrorString());
if (i < WRITE_RETRIES) {
li.QuadPart = wb;
uprintf("Retrying in %d seconds...", WRITE_TIMEOUT / 1000);
Expand All @@ -1736,7 +1736,7 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, BOOL bZeroDrive)
if (i > WRITE_RETRIES)
goto out;
}

uprintfs("\r\n");
}
RefreshDriveLayout(hPhysicalDrive);
ret = TRUE;
Expand Down Expand Up @@ -1961,6 +1961,11 @@ DWORD WINAPI FormatThread(void* param)
if ((boot_type == BT_IMAGE) && write_as_image) {
WriteDrive(hPhysicalDrive, FALSE);

// Trying to mount accessible partitions after writing an image leads to the
// creation of the infamous 'System Volume Information' folder on ESPs, which
// in turn leads to checksum errors for Ubuntu's boot/grub/efi.img (that maps
// to the Ubuntu ESP). So we no longer call on the code below...
#if 0
// If the image contains a partition we might be able to access, try to re-mount it
safe_unlockclose(hPhysicalDrive);
safe_unlockclose(hLogicalVolume);
Expand All @@ -1971,6 +1976,7 @@ DWORD WINAPI FormatThread(void* param)
if ((volume_name != NULL) && (MountVolume(drive_name, volume_name)))
uprintf("Remounted %s as %C:", volume_name, drive_name[0]);
}
#endif
goto out;
}

Expand Down
10 changes: 5 additions & 5 deletions src/rufus.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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.14.1791"
CAPTION "Rufus 3.14.1792"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
Expand Down Expand Up @@ -395,8 +395,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,14,1791,0
PRODUCTVERSION 3,14,1791,0
FILEVERSION 3,14,1792,0
PRODUCTVERSION 3,14,1792,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -414,13 +414,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.14.1791"
VALUE "FileVersion", "3.14.1792"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2021 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-3.14.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.14.1791"
VALUE "ProductVersion", "3.14.1792"
END
END
BLOCK "VarFileInfo"
Expand Down

0 comments on commit 3bb8370

Please sign in to comment.