[format] only clear the extra 1MB for large FAT32

* Clearing that extra MB can take a long time on slow drives
This commit is contained in:
Pete Batard 2013-12-05 18:56:05 +00:00
parent 77234442f7
commit 34f467a26e
2 changed files with 11 additions and 9 deletions

View File

@ -791,7 +791,7 @@ static BOOL AnalyzePBR(HANDLE hLogicalVolume)
return TRUE;
}
static BOOL ClearMBRGPT(HANDLE hPhysicalDrive, LONGLONG DiskSize, DWORD SectorSize)
static BOOL ClearMBRGPT(HANDLE hPhysicalDrive, LONGLONG DiskSize, DWORD SectorSize, BOOL add1MB)
{
BOOL r = FALSE;
uint64_t i, last_sector = DiskSize/SectorSize;
@ -807,7 +807,9 @@ static BOOL ClearMBRGPT(HANDLE hPhysicalDrive, LONGLONG DiskSize, DWORD SectorSi
// with reluctant access to large drive.
// Must clear at least 1MB + the PBR for large FAT32 format to work on a large drive
for (i=0; i<(2048+MAX_SECTORS_TO_CLEAR); i++) {
// Don't do it if Large FAT32 is not enabled, as it can take time for slow drives.
uprintf("Erasing %d sectors", (add1MB?2048:0)+MAX_SECTORS_TO_CLEAR);
for (i=0; i<((add1MB?2048:0)+MAX_SECTORS_TO_CLEAR); i++) {
if ((IS_ERROR(FormatStatus)) || (write_sectors(hPhysicalDrive, SectorSize, i, 1, pBuf) != SectorSize)) {
goto out;
}
@ -1276,7 +1278,7 @@ DWORD WINAPI FormatThread(LPVOID param)
uprintf("Bad blocks: Check failed.\n");
if (!IS_ERROR(FormatStatus))
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_BADBLOCKS_FAILURE);
ClearMBRGPT(hPhysicalDrive, SelectedDrive.DiskSize, SelectedDrive.Geometry.BytesPerSector);
ClearMBRGPT(hPhysicalDrive, SelectedDrive.DiskSize, SelectedDrive.Geometry.BytesPerSector, FALSE);
fclose(log_fd);
_unlink(logfile);
goto out;
@ -1321,7 +1323,7 @@ DWORD WINAPI FormatThread(LPVOID param)
// Especially after destructive badblocks test, you must zero the MBR/GPT completely
// before repartitioning. Else, all kind of bad things happen.
if (!ClearMBRGPT(hPhysicalDrive, SelectedDrive.DiskSize, SelectedDrive.Geometry.BytesPerSector)) {
if (!ClearMBRGPT(hPhysicalDrive, SelectedDrive.DiskSize, SelectedDrive.Geometry.BytesPerSector, use_large_fat32)) {
uprintf("unable to zero MBR/GPT\n");
if (!IS_ERROR(FormatStatus))
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_WRITE_FAULT;

View File

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 329
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Rufus v1.4.1.348"
CAPTION "Rufus v1.4.1.349"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
@ -288,8 +288,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,4,1,348
PRODUCTVERSION 1,4,1,348
FILEVERSION 1,4,1,349
PRODUCTVERSION 1,4,1,349
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -306,13 +306,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.4.1.348"
VALUE "FileVersion", "1.4.1.349"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2013 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.4.1.348"
VALUE "ProductVersion", "1.4.1.349"
END
END
BLOCK "VarFileInfo"