1
1
Fork 0
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:
Pete Batard 2012-02-05 19:54:48 +00:00
parent d1e4ba278b
commit 22276ccb5a
3 changed files with 29 additions and 12 deletions

View file

@ -390,7 +390,8 @@ void __cdecl FormatThread(void* param)
HANDLE hPhysicalDrive = INVALID_HANDLE_VALUE; HANDLE hPhysicalDrive = INVALID_HANDLE_VALUE;
HANDLE hLogicalVolume = INVALID_HANDLE_VALUE; HANDLE hLogicalVolume = INVALID_HANDLE_VALUE;
SYSTEMTIME lt; SYSTEMTIME lt;
char drive_name[] = "?:"; char drive_name[] = "?:\\";
char drive_guid[50];
char bb_msg[512]; char bb_msg[512];
char logfile[MAX_PATH], *userdir; char logfile[MAX_PATH], *userdir;
FILE* log_fd; FILE* log_fd;
@ -418,7 +419,6 @@ void __cdecl FormatThread(void* param)
goto out; goto out;
} }
UnmountDrive(hLogicalVolume); UnmountDrive(hLogicalVolume);
// TODO: DeleteVolumeMountPoint (and GetVolumeNameForVolumeMountPoint unless the GUID changes)
AnalyzeMBR(hPhysicalDrive); AnalyzeMBR(hPhysicalDrive);
AnalyzePBR(hLogicalVolume); AnalyzePBR(hLogicalVolume);
@ -481,7 +481,6 @@ void __cdecl FormatThread(void* param)
} }
// Close the (unmounted) volume before formatting, but keep the lock // Close the (unmounted) volume before formatting, but keep the lock
safe_closehandle(hLogicalVolume); 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 // Especially after destructive badblocks test, you must zero the MBR completely
// before repartitioning. Else, all kind of bad things happen // before repartitioning. Else, all kind of bad things happen
@ -499,7 +498,7 @@ void __cdecl FormatThread(void* param)
UpdateProgress(OP_PARTITION, -1.0f); UpdateProgress(OP_PARTITION, -1.0f);
// Add a small delay after partitioning to be safe // Add a small delay after partitioning to be safe
Sleep(500); Sleep(200);
if (!FormatDrive(drive_name[0])) { if (!FormatDrive(drive_name[0])) {
// Error will be set by FormatDrive() in FormatStatus // Error will be set by FormatDrive() in FormatStatus
@ -536,7 +535,8 @@ void __cdecl FormatThread(void* param)
// Errorcode has already been set // Errorcode has already been set
goto out; 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); safe_unlockclose(hLogicalVolume);
UpdateProgress(OP_DOS, -1.0f); UpdateProgress(OP_DOS, -1.0f);
if (ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType)) != DT_ISO) { 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: out:
safe_unlockclose(hLogicalVolume); safe_unlockclose(hLogicalVolume);

View file

@ -244,3 +244,4 @@ typedef struct {
#define ERROR_BADBLOCKS_FAILURE 0x1206 #define ERROR_BADBLOCKS_FAILURE 0x1206
#define ERROR_ISO_SCAN 0x1207 #define ERROR_ISO_SCAN 0x1207
#define ERROR_ISO_EXTRACT 0x1208 #define ERROR_ISO_EXTRACT 0x1208
#define ERROR_CANT_REMOUNT_VOLUME 0x1209

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 278 IDD_DIALOG DIALOGEX 12, 12, 206, 278
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW EXSTYLE WS_EX_APPWINDOW
CAPTION "Rufus v1.0.7.125" CAPTION "Rufus v1.0.7.126"
FONT 8, "MS Shell Dlg", 400, 0, 0x1 FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,236,50,14 DEFPUSHBUTTON "Start",IDC_START,94,236,50,14
@ -71,7 +71,7 @@ BEGIN
DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP 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, CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL,
"SysLink",WS_TABSTOP,46,47,114,9 "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 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 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 LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8
@ -222,8 +222,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,7,125 FILEVERSION 1,0,7,126
PRODUCTVERSION 1,0,7,125 PRODUCTVERSION 1,0,7,126
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -240,13 +240,13 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "akeo.ie" VALUE "CompanyName", "akeo.ie"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.0.7.125" VALUE "FileVersion", "1.0.7.126"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe" VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.0.7.125" VALUE "ProductVersion", "1.0.7.126"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"