mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[ext2fs] improve persistence partition creation's progress report
* Closes #691
This commit is contained in:
parent
d93ae1e598
commit
4b38483a68
6 changed files with 38 additions and 28 deletions
2
src/db.h
2
src/db.h
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Rufus: The Reliable USB Formatting Utility
|
||||
* DB of the hash values we know for downloadable content (GRUB, Syslinux, etc.)
|
||||
* Copyright © 2016-2017 Pete Batard <pete@akeo.ie>
|
||||
* Copyright © 2016-2019 Pete Batard <pete@akeo.ie>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
14
src/drive.c
14
src/drive.c
|
@ -1158,7 +1158,8 @@ BOOL MountVolume(char* drive_name, char *drive_guid)
|
|||
// If that is the case, update drive_name to that letter.
|
||||
if ( (GetVolumePathNamesForVolumeNameA(drive_guid, mounted_letter, sizeof(mounted_letter), &size))
|
||||
&& (size > 1) && (mounted_letter[0] != drive_name[0]) ) {
|
||||
uprintf("%s is already mounted as %C: instead of %C: - Will now use this target instead...", mounted_letter[0], drive_name[0]);
|
||||
uprintf("%s is already mounted as %C: instead of %C: - Will now use this target instead...",
|
||||
drive_guid, mounted_letter[0], drive_name[0]);
|
||||
drive_name[0] = mounted_letter[0];
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1404,7 +1405,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
|
|||
|
||||
// Adjust the size according to extra partitions (which we always align to a track)
|
||||
if (extra_partitions) {
|
||||
uprintf("Adding extra partition");
|
||||
uprintf("Adding %s partition", (extra_partitions & XP_CASPER) ? "casper-rw": "extra");
|
||||
if (extra_partitions & XP_EFI) {
|
||||
// The size of the EFI partition depends on the minimum size we're able to format in FAT32, which
|
||||
// in turn depends on the cluster size used, which in turn depends on the disk sector size.
|
||||
|
@ -1424,8 +1425,9 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
|
|||
assert(persistence_size != 0);
|
||||
extra_part_size_in_tracks = persistence_size / bytes_per_track;
|
||||
}
|
||||
uprintf("Reserved %" PRIi64" tracks (%s) for extra partition", extra_part_size_in_tracks,
|
||||
SizeToHumanReadable(extra_part_size_in_tracks * bytes_per_track, TRUE, FALSE));
|
||||
uprintf("Reserved %" PRIi64" tracks (%s) for %s partition", extra_part_size_in_tracks,
|
||||
SizeToHumanReadable(extra_part_size_in_tracks * bytes_per_track, TRUE, FALSE),
|
||||
(extra_partitions & XP_CASPER) ? "casper-rw" : "extra");
|
||||
main_part_size_in_sectors = ((main_part_size_in_sectors / SelectedDrive.SectorsPerTrack) -
|
||||
extra_part_size_in_tracks) * SelectedDrive.SectorsPerTrack;
|
||||
if (main_part_size_in_sectors <= 0)
|
||||
|
@ -1464,11 +1466,11 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
|
|||
DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart = DriveLayoutEx.PartitionEntry[pn-1].StartingOffset.QuadPart +
|
||||
DriveLayoutEx.PartitionEntry[pn-1].PartitionLength.QuadPart;
|
||||
DriveLayoutEx.PartitionEntry[pn].PartitionLength.QuadPart = (extra_partitions & XP_UEFI_NTFS)?uefi_ntfs_size:
|
||||
extra_part_size_in_tracks * SelectedDrive.SectorsPerTrack * SelectedDrive.SectorSize;
|
||||
extra_part_size_in_tracks * bytes_per_track;
|
||||
if (partition_style == PARTITION_STYLE_GPT) {
|
||||
const wchar_t* name = L"Basic Data";
|
||||
const GUID* guid = &PARTITION_BASIC_DATA_GUID;
|
||||
if (extra_partitions & XP_MSR) {
|
||||
if (extra_partitions & XP_EFI) {
|
||||
guid = &PARTITION_SYSTEM_GUID;
|
||||
name = L"EFI system partition";
|
||||
} else if (extra_partitions & XP_CASPER) {
|
||||
|
|
12
src/format.c
12
src/format.c
|
@ -791,13 +791,14 @@ const char* error_message(errcode_t error_code)
|
|||
}
|
||||
|
||||
static float ext2_percent_start = 0.0f, ext2_percent_share = 50.0f;
|
||||
const float ext2_max_marker = 80.0f;
|
||||
errcode_t ext2fs_print_progress(int64_t cur_value, int64_t max_value)
|
||||
{
|
||||
static int64_t last_value = -1;
|
||||
if (max_value == 0)
|
||||
return 0;
|
||||
UPDATE_PERCENT(MSG_217, ext2_percent_start + ext2_percent_share * cur_value / (float)max_value);
|
||||
cur_value = (int64_t)(((float)cur_value / (float)max_value) * min(80.0f, (float)max_value));
|
||||
cur_value = (int64_t)(((float)cur_value / (float)max_value) * min(ext2_max_marker, (float)max_value));
|
||||
if ((cur_value < last_value) || (cur_value > last_value)) {
|
||||
last_value = cur_value;
|
||||
uprintfs("+");
|
||||
|
@ -851,7 +852,7 @@ BOOL FormatExtFs(const char* label, uint32_t version)
|
|||
if ((version < 2) || (version > 3)) {
|
||||
if (version == 4)
|
||||
uprintf("ext4 file system is not supported, will use ext3 instead");
|
||||
else
|
||||
else if (version != 0)
|
||||
uprintf("invalid ext file system version requested, will use ext3");
|
||||
version = 3;
|
||||
}
|
||||
|
@ -941,7 +942,8 @@ BOOL FormatExtFs(const char* label, uint32_t version)
|
|||
|
||||
ext2_percent_start = 0.0f;
|
||||
ext2_percent_share = (version < 3) ? 100.0f : 50.0f;
|
||||
uprintf("Creating %d inode sets:", ext2fs->group_desc_count);
|
||||
uprintf("Creating %d inode sets: [1 marker = %0.1f set(s)]", ext2fs->group_desc_count,
|
||||
max((float)ext2fs->group_desc_count / ext2_max_marker, 1.0f));
|
||||
for (i = 0; i < (int)ext2fs->group_desc_count; i++) {
|
||||
if (ext2fs_print_progress((int64_t)i, (int64_t)ext2fs->group_desc_count))
|
||||
goto out;
|
||||
|
@ -955,7 +957,6 @@ BOOL FormatExtFs(const char* label, uint32_t version)
|
|||
}
|
||||
}
|
||||
uprintfs("\r\n");
|
||||
UPDATE_PERCENT(MSG_217, 25.0f);
|
||||
|
||||
// Create root and lost+found dirs
|
||||
r = ext2fs_mkdir(ext2fs, EXT2_ROOT_INO, EXT2_ROOT_INO, 0);
|
||||
|
@ -992,7 +993,8 @@ BOOL FormatExtFs(const char* label, uint32_t version)
|
|||
ext2_percent_start = 50.0f;
|
||||
journal_size = ext2fs_default_journal_size(ext2fs_blocks_count(ext2fs->super));
|
||||
journal_size /= 2; // That journal init is really killing us!
|
||||
uprintf("Creating %d journal blocks:", journal_size);
|
||||
uprintf("Creating %d journal blocks: [1 marker = %0.1f block(s)]", journal_size,
|
||||
max((float)journal_size / ext2_max_marker, 1.0f));
|
||||
// Even with EXT2_MKJOURNAL_LAZYINIT, this call is absolutely dreadful in terms of speed...
|
||||
r = ext2fs_add_journal_inode(ext2fs, journal_size, EXT2_MKJOURNAL_NO_MNT_CHECK | EXT2_MKJOURNAL_LAZYINIT);
|
||||
uprintfs("\r\n");
|
||||
|
|
|
@ -2598,7 +2598,9 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
|||
|
||||
if ((boot_type == BT_IMAGE) && IS_DD_BOOTABLE(img_report)) {
|
||||
if (img_report.is_iso) {
|
||||
// Ask users how they want to write ISOHybrid images
|
||||
// Ask users how they want to write ISOHybrid images,
|
||||
// but only do so if persistence has not been selected.
|
||||
if (persistence_size == 0) {
|
||||
char* iso_image = lmprintf(MSG_036);
|
||||
char* dd_image = lmprintf(MSG_095);
|
||||
char* choices[2] = { lmprintf(MSG_276, iso_image), lmprintf(MSG_277, dd_image) };
|
||||
|
@ -2608,6 +2610,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
|||
goto aborted_start;
|
||||
else if (i == 2)
|
||||
write_as_image = TRUE;
|
||||
}
|
||||
} else {
|
||||
write_as_image = TRUE;
|
||||
}
|
||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -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.6.1526"
|
||||
CAPTION "Rufus 3.6.1527"
|
||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||
|
@ -394,8 +394,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 3,6,1526,0
|
||||
PRODUCTVERSION 3,6,1526,0
|
||||
FILEVERSION 3,6,1527,0
|
||||
PRODUCTVERSION 3,6,1527,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -413,13 +413,13 @@ BEGIN
|
|||
VALUE "Comments", "https://akeo.ie"
|
||||
VALUE "CompanyName", "Akeo Consulting"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "3.6.1526"
|
||||
VALUE "FileVersion", "3.6.1527"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011-2019 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html"
|
||||
VALUE "OriginalFilename", "rufus-3.6.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "3.6.1526"
|
||||
VALUE "ProductVersion", "3.6.1527"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
5
src/ui.c
5
src/ui.c
|
@ -1170,7 +1170,10 @@ void InitProgress(BOOL bOnlyFormat)
|
|||
nb_slots[OP_FIX_MBR] = 1;
|
||||
nb_slots[OP_CREATE_FS] =
|
||||
nb_steps[ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem))];
|
||||
if ((!IsChecked(IDC_QUICK_FORMAT))
|
||||
// So, yeah, if you're doing slow format, or using Large FAT32, and have persistence, you'll see
|
||||
// the progress bar revert during format on account that we reuse the same operation for both
|
||||
// partitions. Maybe one day I'll be bothered to handle two separate OP_FORMAT ops...
|
||||
if ((!IsChecked(IDC_QUICK_FORMAT)) || (persistence_size != 0)
|
||||
|| ((fs_type == FS_FAT32) && ((SelectedDrive.DiskSize >= LARGE_FAT32_SIZE) || (force_large_fat32)))) {
|
||||
nb_slots[OP_FORMAT] = -1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue