mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-21 02:15:11 -04:00
[core] more drive handling improvements
* Use retries when locking the volume * Wait for volume availability after partitioning * Don't halt on errors that can be ignored * Other small improvements and fixes * The above should help with addressing #122
This commit is contained in:
parent
cd5665881c
commit
6be21bbdbc
4 changed files with 111 additions and 70 deletions
10
src/rufus.h
10
src/rufus.h
|
@ -36,6 +36,8 @@
|
|||
#define STR_NO_LABEL "NO_LABEL"
|
||||
#define RUFUS_CANCELBOX_TITLE APPLICATION_NAME " - Cancellation"
|
||||
#define RUFUS_BLOCKING_IO_TITLE APPLICATION_NAME " - Flushing buffers"
|
||||
#define DRIVE_ACCESS_TIMEOUT 10000 // How long we should retry drive access (in ms)
|
||||
#define DRIVE_ACCESS_RETRIES 20 // How many times we should retry
|
||||
#define DRIVE_INDEX_MIN 0x00000080
|
||||
#define DRIVE_INDEX_MAX 0x000000C0
|
||||
#define MAX_DRIVES (DRIVE_INDEX_MAX - DRIVE_INDEX_MIN)
|
||||
|
@ -60,7 +62,6 @@
|
|||
#define IsChecked(CheckBox_ID) (IsDlgButtonChecked(hMainDialog, CheckBox_ID) == BST_CHECKED)
|
||||
|
||||
#define safe_free(p) do {free((void*)p); p = NULL;} while(0)
|
||||
#define safe_closehandle(h) do {if (h != INVALID_HANDLE_VALUE) {CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)
|
||||
#define safe_min(a, b) min((size_t)(a), (size_t)(b))
|
||||
#define safe_strcp(dst, dst_max, src, count) do {memcpy(dst, src, safe_min(count, dst_max)); \
|
||||
((char*)dst)[safe_min(count, dst_max)-1] = 0;} while(0)
|
||||
|
@ -71,8 +72,8 @@
|
|||
#define safe_stricmp(str1, str2) _stricmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2))
|
||||
#define safe_strncmp(str1, str2, count) strncmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2), count)
|
||||
#define safe_strnicmp(str1, str2, count) _strnicmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2), count)
|
||||
#define safe_closehandle(h) do {if (h != INVALID_HANDLE_VALUE) {CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)
|
||||
#define safe_unlockclose(h) do {if (h != INVALID_HANDLE_VALUE) {UnlockDrive(h); CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)
|
||||
#define safe_closehandle(h) do {if ((h != INVALID_HANDLE_VALUE) && (h != NULL)) {CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)
|
||||
#define safe_unlockclose(h) do {if ((h != INVALID_HANDLE_VALUE) && (h != NULL)) {UnlockDrive(h); CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)
|
||||
#define safe_sprintf(dst, count, ...) do {_snprintf(dst, count, __VA_ARGS__); (dst)[(count)-1] = 0; } while(0)
|
||||
#define safe_strlen(str) ((((char*)str)==NULL)?0:strlen(str))
|
||||
#define safe_strdup _strdup
|
||||
|
@ -302,7 +303,8 @@ extern BOOL InstallSyslinux(DWORD drive_index, char drive_letter);
|
|||
DWORD WINAPI FormatThread(void* param);
|
||||
extern char* GetPhysicalName(DWORD DriveIndex);
|
||||
extern HANDLE GetPhysicalHandle(DWORD DriveIndex, BOOL bWriteAccess, BOOL bLockDrive);
|
||||
extern char* GetLogicalName(DWORD DriveIndex, BOOL bKeepTrailingBackslash);
|
||||
extern BOOL WaitForLogical(DWORD DriveIndex);
|
||||
extern char* GetLogicalName(DWORD DriveIndex, BOOL bKeepTrailingBackslash, BOOL bSilent);
|
||||
extern HANDLE GetLogicalHandle(DWORD DriveIndex, BOOL bWriteAccess, BOOL bLockDrive);
|
||||
extern char GetDriveLetter(DWORD DriveIndex);
|
||||
extern char GetUnusedDriveLetter(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue