[core] avoid the creation of 'System Volume Information' for ESPs written 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.
This commit is contained in:
Pete Batard 2021-05-18 15:18:28 +01:00
parent 03ef8aa024
commit 3bb83709da
No known key found for this signature in database
GPG Key ID: 38E0CF5E69EDD671
3 changed files with 20 additions and 14 deletions

View File

@ -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>

View File

@ -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;
}
@ -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
@ -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);
@ -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;
}
@ -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);
@ -1736,7 +1736,7 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, BOOL bZeroDrive)
if (i > WRITE_RETRIES)
goto out;
}
uprintfs("\r\n");
}
RefreshDriveLayout(hPhysicalDrive);
ret = TRUE;
@ -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);
@ -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;
}

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.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
@ -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
@ -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"