mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[core] add tactical volume re-mount post format
This commit is contained in:
parent
d1e4ba278b
commit
22276ccb5a
3 changed files with 29 additions and 12 deletions
28
src/format.c
28
src/format.c
|
@ -390,7 +390,8 @@ void __cdecl FormatThread(void* param)
|
|||
HANDLE hPhysicalDrive = INVALID_HANDLE_VALUE;
|
||||
HANDLE hLogicalVolume = INVALID_HANDLE_VALUE;
|
||||
SYSTEMTIME lt;
|
||||
char drive_name[] = "?:";
|
||||
char drive_name[] = "?:\\";
|
||||
char drive_guid[50];
|
||||
char bb_msg[512];
|
||||
char logfile[MAX_PATH], *userdir;
|
||||
FILE* log_fd;
|
||||
|
@ -418,7 +419,6 @@ void __cdecl FormatThread(void* param)
|
|||
goto out;
|
||||
}
|
||||
UnmountDrive(hLogicalVolume);
|
||||
// TODO: DeleteVolumeMountPoint (and GetVolumeNameForVolumeMountPoint unless the GUID changes)
|
||||
|
||||
AnalyzeMBR(hPhysicalDrive);
|
||||
AnalyzePBR(hLogicalVolume);
|
||||
|
@ -481,7 +481,6 @@ void __cdecl FormatThread(void* param)
|
|||
}
|
||||
// Close the (unmounted) volume before formatting, but keep the lock
|
||||
safe_closehandle(hLogicalVolume);
|
||||
// TODO: do we have to sleep here for unmount to be effective?
|
||||
|
||||
// Especially after destructive badblocks test, you must zero the MBR completely
|
||||
// before repartitioning. Else, all kind of bad things happen
|
||||
|
@ -499,7 +498,7 @@ void __cdecl FormatThread(void* param)
|
|||
UpdateProgress(OP_PARTITION, -1.0f);
|
||||
|
||||
// Add a small delay after partitioning to be safe
|
||||
Sleep(500);
|
||||
Sleep(200);
|
||||
|
||||
if (!FormatDrive(drive_name[0])) {
|
||||
// Error will be set by FormatDrive() in FormatStatus
|
||||
|
@ -536,7 +535,8 @@ void __cdecl FormatThread(void* param)
|
|||
// Errorcode has already been set
|
||||
goto out;
|
||||
}
|
||||
// ...but we must have relinquished that lock to write the MS-DOS files
|
||||
|
||||
// We must close and unlock the volume to write files to it
|
||||
safe_unlockclose(hLogicalVolume);
|
||||
UpdateProgress(OP_DOS, -1.0f);
|
||||
if (ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType)) != DT_ISO) {
|
||||
|
@ -557,7 +557,23 @@ void __cdecl FormatThread(void* param)
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: SetVolumeMountPoint
|
||||
// We issue a complete remount of the filesystem at the end on account of:
|
||||
// - Ensuring the file explorer properly detects that the volume was updated
|
||||
// - Ensuring that an NTFS system will be reparsed so that it becomes bootable
|
||||
if (GetVolumeNameForVolumeMountPointA(drive_name, drive_guid, sizeof(drive_guid))) {
|
||||
if (DeleteVolumeMountPointA(drive_name)) {
|
||||
Sleep(200);
|
||||
if (SetVolumeMountPointA(drive_name, drive_guid)) {
|
||||
uprintf("Successfully remounted %s on %s\n", drive_guid, drive_name);
|
||||
} else {
|
||||
uprintf("Failed to remount %s on %s\n", drive_guid, drive_name);
|
||||
// This will leave the drive unaccessible and must be flagged as an error
|
||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_CANT_REMOUNT_VOLUME);
|
||||
}
|
||||
} else {
|
||||
uprintf("Could not remount %s %s\n", drive_name, WindowsErrorString());
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
safe_unlockclose(hLogicalVolume);
|
||||
|
|
|
@ -244,3 +244,4 @@ typedef struct {
|
|||
#define ERROR_BADBLOCKS_FAILURE 0x1206
|
||||
#define ERROR_ISO_SCAN 0x1207
|
||||
#define ERROR_ISO_EXTRACT 0x1208
|
||||
#define ERROR_CANT_REMOUNT_VOLUME 0x1209
|
||||
|
|
12
src/rufus.rc
12
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
|
|||
IDD_DIALOG DIALOGEX 12, 12, 206, 278
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_APPWINDOW
|
||||
CAPTION "Rufus v1.0.7.125"
|
||||
CAPTION "Rufus v1.0.7.126"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Start",IDC_START,94,236,50,14
|
||||
|
@ -71,7 +71,7 @@ BEGIN
|
|||
DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP
|
||||
CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL,
|
||||
"SysLink",WS_TABSTOP,46,47,114,9
|
||||
LTEXT "Version 1.0.7 (Build 125)",IDC_STATIC,46,19,78,8
|
||||
LTEXT "Version 1.0.7 (Build 126)",IDC_STATIC,46,19,78,8
|
||||
PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP
|
||||
EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL
|
||||
LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8
|
||||
|
@ -222,8 +222,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,7,125
|
||||
PRODUCTVERSION 1,0,7,125
|
||||
FILEVERSION 1,0,7,126
|
||||
PRODUCTVERSION 1,0,7,126
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -240,13 +240,13 @@ BEGIN
|
|||
BEGIN
|
||||
VALUE "CompanyName", "akeo.ie"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "1.0.7.125"
|
||||
VALUE "FileVersion", "1.0.7.126"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
||||
VALUE "OriginalFilename", "rufus.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "1.0.7.125"
|
||||
VALUE "ProductVersion", "1.0.7.126"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
Loading…
Reference in a new issue