From 9079c8534e301276bdb247cd99f04ebbbb933f5a Mon Sep 17 00:00:00 2001 From: bigbiff bigbiff Date: Tue, 30 Aug 2016 20:48:53 -0400 Subject: [PATCH 1/6] MD5 checking: fix issues introduced with adb backup patchset This patchset will fix issues with creating and checking md5 checksums with single partitions and subpartitions. Change-Id: Id2d46af0f0913c944aa1d800c44327cfb47e6bd7 --- partition.cpp | 6 +++--- partitionmanager.cpp | 35 ++++++++++++++++++++++------------- partitions.hpp | 6 +++--- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/partition.cpp b/partition.cpp index 89650db6cc..6edc36822d 100644 --- a/partition.cpp +++ b/partition.cpp @@ -1612,7 +1612,7 @@ bool TWPartition::Backup(PartitionSettings *part_settings, pid_t *tar_fork_pid) return false; } -bool TWPartition::Check_MD5(string restore_folder) { +bool TWPartition::Check_MD5(PartitionSettings *part_settings) { string Full_Filename, md5file; char split_filename[512]; int index = 0; @@ -1621,7 +1621,7 @@ bool TWPartition::Check_MD5(string restore_folder) { sync(); memset(split_filename, 0, sizeof(split_filename)); - Full_Filename = restore_folder + "/" + Backup_FileName; + Full_Filename = part_settings->Restore_Name + "/" + part_settings->Backup_FileName; if (!TWFunc::Path_Exists(Full_Filename)) { // This is a split archive, we presume sprintf(split_filename, "%s%03i", Full_Filename.c_str(), index); @@ -1647,7 +1647,7 @@ bool TWPartition::Check_MD5(string restore_folder) { // Single file archive md5file = Full_Filename + ".md5"; if (!TWFunc::Path_Exists(md5file)) { - gui_msg(Msg(msg::kError, "no_md5_found=No md5 file found for '{1}'. Please unselect Enable MD5 verification to restore.")(split_filename)); + gui_msg(Msg(msg::kError, "no_md5_found=No md5 file found for '{1}'. Please unselect Enable MD5 verification to restore.")(md5file)); return false; } md5sum.setfn(Full_Filename); diff --git a/partitionmanager.cpp b/partitionmanager.cpp index a326d79ce2..1c7a9702a3 100644 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -551,11 +551,21 @@ bool TWPartitionManager::Backup_Partition(PartitionSettings *part_settings) { part_settings->Backup_FileName = part_settings->Part->Backup_Name + "." + part_settings->Part->Current_File_System + ".win"; if (part_settings->Part->Backup(part_settings, &tar_fork_pid)) { bool md5Success = false; + if (part_settings->adbbackup) { + md5Success = true; + } + else + md5Success = Make_MD5(part_settings); + + TWFunc::SetPerformanceMode(false); if (part_settings->Part->Has_SubPartition) { std::vector::iterator subpart; + TWPartition *parentPart = part_settings->Part; for (subpart = Partitions.begin(); subpart != Partitions.end(); subpart++) { - if ((*subpart)->Can_Be_Backed_Up && (*subpart)->Is_SubPartition && (*subpart)->SubPartition_Of == part_settings->Part->Mount_Point) { + part_settings->Part = *subpart; + if ((*subpart)->Can_Be_Backed_Up && (*subpart)->Is_SubPartition && (*subpart)->SubPartition_Of == parentPart->Mount_Point) { + part_settings->Backup_FileName = part_settings->Part->Backup_Name + "." + part_settings->Part->Current_File_System + ".win"; if (!(*subpart)->Backup(part_settings, &tar_fork_pid)) { TWFunc::SetPerformanceMode(false); Clean_Backup_Folder(part_settings->Backup_Folder); @@ -577,6 +587,7 @@ bool TWPartitionManager::Backup_Partition(PartitionSettings *part_settings) { time(&stop); int backup_time = (int) difftime(stop, start); LOGINFO("Partition Backup time: %d\n", backup_time); + if (part_settings->Part->Backup_Method == BM_FILES) { part_settings->file_time += backup_time; } else { @@ -584,13 +595,6 @@ bool TWPartitionManager::Backup_Partition(PartitionSettings *part_settings) { } - if (part_settings->adbbackup) { - md5Success = true; - } - else - md5Success = Make_MD5(part_settings); - TWFunc::SetPerformanceMode(false); - return md5Success; } else { Clean_Backup_Folder(part_settings->Backup_Folder); @@ -889,10 +893,12 @@ bool TWPartitionManager::Restore_Partition(PartitionSettings *part_settings) { } if (part_settings->Part->Has_SubPartition) { std::vector::iterator subpart; + TWPartition *parentPart = part_settings->Part; for (subpart = Partitions.begin(); subpart != Partitions.end(); subpart++) { - - if ((*subpart)->Is_SubPartition && (*subpart)->SubPartition_Of == part_settings->Part->Mount_Point) { + part_settings->Part = *subpart; + if ((*subpart)->Is_SubPartition && (*subpart)->SubPartition_Of == parentPart->Mount_Point) { + part_settings->Part = (*subpart); if (!(*subpart)->Restore(part_settings)) { TWFunc::SetPerformanceMode(false); return false; @@ -953,16 +959,19 @@ int TWPartitionManager::Run_Restore(const string& Restore_Name) { return false; } - if (check_md5 > 0 && !part_settings.Part->Check_MD5(Restore_Name)) + if (check_md5 > 0 && !part_settings.Part->Check_MD5(&part_settings)) return false; part_settings.partition_count++; part_settings.total_restore_size += part_settings.Part->Get_Restore_Size(&part_settings); if (part_settings.Part->Has_SubPartition) { + TWPartition *parentPart = part_settings.Part; std::vector::iterator subpart; for (subpart = Partitions.begin(); subpart != Partitions.end(); subpart++) { - if ((*subpart)->Is_SubPartition && (*subpart)->SubPartition_Of == part_settings.Part->Mount_Point) { - if (check_md5 > 0 && !(*subpart)->Check_MD5(Restore_Name)) + part_settings.Backup_FileName = parentPart->Backup_Name + "." + parentPart->Current_File_System + ".win"; + part_settings.Part = *subpart; + if ((*subpart)->Is_SubPartition && (*subpart)->SubPartition_Of == parentPart->Mount_Point) { + if (check_md5 > 0 && !(*subpart)->Check_MD5(&part_settings)) return false; part_settings.total_restore_size += (*subpart)->Get_Restore_Size(&part_settings); } diff --git a/partitions.hpp b/partitions.hpp index 7416fbe4ce..201a4e1d18 100644 --- a/partitions.hpp +++ b/partitions.hpp @@ -60,8 +60,8 @@ struct PartitionSettings { uint64_t img_bytes; // total image bytes of all emmc partitions uint64_t file_bytes; // total file bytes of all file based partitions int partition_count; // Number of partitions to restore - ProgressTracking *progress; - enum PartitionManager_Op PM_Method; //Current operation of backup or restore + ProgressTracking *progress; // Keep track of progress in GUI + enum PartitionManager_Op PM_Method; // Current operation of backup or restore }; enum Backup_Method_enum { @@ -94,7 +94,7 @@ class TWPartition bool Can_Resize(); // Checks to see if we have everything needed to be able to resize the current file system bool Resize(); // Resizes the current file system bool Backup(PartitionSettings *part_settings, pid_t *tar_fork_pid); // Backs up the partition to the folder specified - bool Check_MD5(string restore_folder); // Checks MD5 of a backup + bool Check_MD5(PartitionSettings *part_settings); // Checks MD5 of a backup bool Restore(PartitionSettings *part_settings); // Restores the partition using the backup folder provided unsigned long long Get_Restore_Size(PartitionSettings *part_settings);// Returns the overall restore size of the backup string Backup_Method_By_Name(); // Returns a string of the backup method for human readable output From bedb920903819a9543354396e25c27c0efb51961 Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Thu, 1 Sep 2016 18:40:24 -0500 Subject: [PATCH 2/6] Fix restore of subpartitions Change-Id: Ie86bc7525a9097b2ab25661e17803b14a7c9ad79 --- partitionmanager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/partitionmanager.cpp b/partitionmanager.cpp index 1c7a9702a3..20c2aee7f9 100644 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -898,6 +898,7 @@ bool TWPartitionManager::Restore_Partition(PartitionSettings *part_settings) { for (subpart = Partitions.begin(); subpart != Partitions.end(); subpart++) { part_settings->Part = *subpart; if ((*subpart)->Is_SubPartition && (*subpart)->SubPartition_Of == parentPart->Mount_Point) { + part_settings->Backup_FileName = (*subpart)->Backup_Name + "." + (*subpart)->Current_File_System + ".win"; part_settings->Part = (*subpart); if (!(*subpart)->Restore(part_settings)) { TWFunc::SetPerformanceMode(false); @@ -968,7 +969,7 @@ int TWPartitionManager::Run_Restore(const string& Restore_Name) { std::vector::iterator subpart; for (subpart = Partitions.begin(); subpart != Partitions.end(); subpart++) { - part_settings.Backup_FileName = parentPart->Backup_Name + "." + parentPart->Current_File_System + ".win"; + part_settings.Backup_FileName = (*subpart)->Backup_Name + "." + (*subpart)->Current_File_System + ".win"; part_settings.Part = *subpart; if ((*subpart)->Is_SubPartition && (*subpart)->SubPartition_Of == parentPart->Mount_Point) { if (check_md5 > 0 && !(*subpart)->Check_MD5(&part_settings)) From c08b236bfc9ecfa1cf61ccb2566dc744cd3dda39 Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Mon, 12 Sep 2016 16:07:19 -0500 Subject: [PATCH 3/6] Fix compressed backups with split archives Change-Id: I526d4e6a009c40c7fc7803553ba0c70701fbfb77 --- twrpTar.cpp | 67 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 27 deletions(-) diff --git a/twrpTar.cpp b/twrpTar.cpp index dcbb28202a..b566237984 100644 --- a/twrpTar.cpp +++ b/twrpTar.cpp @@ -69,6 +69,8 @@ twrpTar::twrpTar(void) { Total_Backup_Size = 0; Archive_Current_Size = 0; include_root_dir = true; + input_fd = -1; + output_fd = -1; } twrpTar::~twrpTar(void) { @@ -915,10 +917,12 @@ int twrpTar::createTar() { // pigz Child close(pipes[1]); close(pipes[2]); - close(0); - dup2(pipes[0], 0); - close(1); - dup2(pipes[3], 1); + int stdinfd = fileno(stdin); + int stdoutfd = fileno(stdout); + close(stdinfd); + dup2(pipes[0], stdinfd); + close(stdoutfd); + dup2(pipes[3], stdoutfd); if (execlp("pigz", "pigz", "-", NULL) < 0) { LOGINFO("execlp pigz ERROR!\n"); gui_err("backup_error=Error creating backup."); @@ -943,10 +947,12 @@ int twrpTar::createTar() { close(pipes[0]); close(pipes[1]); close(pipes[3]); - close(0); - dup2(pipes[2], 0); - close(1); - dup2(output_fd, 1); + int stdinfd = fileno(stdin); + int stdoutfd = fileno(stdout); + close(stdinfd); + dup2(pipes[2], stdinfd); + close(stdoutfd); + dup2(output_fd, stdoutfd); if (execlp("openaes", "openaes", "enc", "--key", password.c_str(), NULL) < 0) { LOGINFO("execlp openaes ERROR!\n"); gui_err("backup_error=Error creating backup."); @@ -1007,8 +1013,8 @@ int twrpTar::createTar() { } else if (pigz_pid == 0) { // Child close(pigzfd[1]); // close unused output pipe - dup2(pigzfd[0], 0); // remap stdin - dup2(output_fd, 1); // remap stdout to output file + dup2(pigzfd[0], fileno(stdin)); // remap stdin + dup2(output_fd, fileno(stdout)); // remap stdout to output file if (execlp("pigz", "pigz", "-", NULL) < 0) { LOGINFO("execlp pigz ERROR!\n"); gui_err("backup_error=Error creating backup."); @@ -1057,8 +1063,8 @@ int twrpTar::createTar() { } else if (oaes_pid == 0) { // Child close(oaesfd[1]); // close unused - dup2(oaesfd[0], 0); // remap stdin - dup2(output_fd, 1); // remap stdout to output file + dup2(oaesfd[0], fileno(stdin)); // remap stdin + dup2(output_fd, fileno(stdout)); // remap stdout to output file if (execlp("openaes", "openaes", "enc", "--key", password.c_str(), NULL) < 0) { LOGINFO("execlp openaes ERROR!\n"); gui_err("backup_error=Error creating backup."); @@ -1147,10 +1153,12 @@ int twrpTar::openTar() { close(pipes[0]); // Close pipes that are not used by this child close(pipes[2]); close(pipes[3]); - close(0); - dup2(input_fd, 0); - close(1); - dup2(pipes[1], 1); + int stdinfd = fileno(stdin); + int stdoutfd = fileno(stdout); + close(stdinfd); + dup2(input_fd, stdinfd); + close(stdoutfd); + dup2(pipes[1], stdoutfd); if (execlp("openaes", "openaes", "dec", "--key", password.c_str(), NULL) < 0) { LOGINFO("execlp openaes ERROR!\n"); gui_err("restore_error=Error during restore process."); @@ -1173,10 +1181,12 @@ int twrpTar::openTar() { // pigz Child close(pipes[1]); // Close pipes not used by this child close(pipes[2]); - close(0); - dup2(pipes[0], 0); - close(1); - dup2(pipes[3], 1); + int stdinfd = fileno(stdin); + int stdoutfd = fileno(stdout); + close(stdinfd); + dup2(pipes[0], stdinfd); + close(stdoutfd); + dup2(pipes[3], stdoutfd); if (execlp("pigz", "pigz", "-d", "-c", NULL) < 0) { LOGINFO("execlp pigz ERROR!\n"); gui_err("restore_error=Error during restore process."); @@ -1226,9 +1236,10 @@ int twrpTar::openTar() { } else if (oaes_pid == 0) { // Child close(oaesfd[0]); // Close unused pipe - close(0); // close stdin - dup2(oaesfd[1], 1); // remap stdout - dup2(input_fd, 0); // remap input fd to stdin + int stdinfd = fileno(stdin); + close(stdinfd); // close stdin + dup2(oaesfd[1], fileno(stdout)); // remap stdout + dup2(input_fd, stdinfd); // remap input fd to stdin if (execlp("openaes", "openaes", "dec", "--key", password.c_str(), NULL) < 0) { LOGINFO("execlp openaes ERROR!\n"); gui_err("restore_error=Error during restore process."); @@ -1281,8 +1292,8 @@ int twrpTar::openTar() { } else if (pigz_pid == 0) { // Child close(pigzfd[0]); - dup2(pigzfd[1], 1); // remap stdout - dup2(input_fd, 0); // remap input fd to stdin + dup2(pigzfd[1], fileno(stdout)); // remap stdout + dup2(input_fd, fileno(stdin)); // remap input fd to stdin if (execlp("pigz", "pigz", "-d", "-c", NULL) < 0) { close(pigzfd[1]); close(input_fd); @@ -1396,8 +1407,10 @@ int twrpTar::closeTar() { if (!twadbbu::Write_TWEOF()) return -1; } - close(input_fd); - close(output_fd); + if (input_fd >= 0) + close(input_fd); + if (output_fd >= 0) + close(output_fd); return 0; } From c0d40deaae5f1f756ce584ed7bdd346680cdc74c Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Tue, 13 Sep 2016 14:41:53 -0500 Subject: [PATCH 4/6] Clean up PartitionSettings The PartitionSettings struct contains some data elements that are duplicates of data elements in the TWPartition class that is contained within the PartitionsSettings.Part element. We will eliminate this duplication to help reduce the chances for programming bugs. Specifically, this fixes problems where the current file system does not match the backed up file system. Change-Id: I02f236e72093362050556a2e53a09d1dbb9a269d --- gui/action.cpp | 8 +++++--- openrecoveryscript.cpp | 5 +---- partition.cpp | 41 ++++++++++++++++++++------------------ partitionmanager.cpp | 45 +++++++++++++++++++----------------------- partitions.hpp | 6 +----- 5 files changed, 49 insertions(+), 56 deletions(-) diff --git a/gui/action.cpp b/gui/action.cpp index 328fc2c528..3fde199d34 100644 --- a/gui/action.cpp +++ b/gui/action.cpp @@ -1739,9 +1739,11 @@ int GUIAction::flashimage(std::string arg __unused) PartitionSettings part_settings; operation_start("Flash Image"); - DataManager::GetValue("tw_zip_location", part_settings.Restore_Name); - DataManager::GetValue("tw_file", part_settings.Backup_FileName); - unsigned long long total_bytes = TWFunc::Get_File_Size(part_settings.Restore_Name + "/" + part_settings.Backup_FileName); + string path, filename; + DataManager::GetValue("tw_zip_location", path); + DataManager::GetValue("tw_file", filename); + part_settings.Backup_Folder = path + "/" + filename; + unsigned long long total_bytes = TWFunc::Get_File_Size(part_settings.Backup_Folder); ProgressTracking progress(total_bytes); part_settings.progress = &progress; part_settings.adbbackup = false; diff --git a/openrecoveryscript.cpp b/openrecoveryscript.cpp index 0d2268cd16..f9c610a7c2 100644 --- a/openrecoveryscript.cpp +++ b/openrecoveryscript.cpp @@ -840,11 +840,10 @@ int OpenRecoveryScript::Restore_ADB_Backup(void) { pos = Restore_Name.find_last_of("/"); Backup_FileName = Restore_Name.substr(pos + 1, Restore_Name.size()); part_settings.Part = PartitionManager.Find_Partition_By_Path(path); - part_settings.Restore_Name = path; + part_settings.Backup_Folder = path; part_settings.partition_count = partition_count; part_settings.adbbackup = true; part_settings.adb_compression = twimghdr.compressed; - part_settings.Backup_FileName = Backup_FileName; part_settings.PM_Method = PM_RESTORE; ProgressTracking progress(part_settings.total_restore_size); part_settings.progress = &progress; @@ -871,7 +870,6 @@ int OpenRecoveryScript::Restore_ADB_Backup(void) { pos = Restore_Name.find_last_of("/"); Backup_FileName = Restore_Name.substr(pos + 1, Restore_Name.size()); pos = Restore_Name.find_last_of("/"); - part_settings.Restore_Name = Restore_Name.substr(0, pos); part_settings.Part = PartitionManager.Find_Partition_By_Path(path); if (path.compare("/system") == 0) { @@ -893,7 +891,6 @@ int OpenRecoveryScript::Restore_ADB_Backup(void) { part_settings.partition_count = partition_count; part_settings.adbbackup = true; part_settings.adb_compression = twimghdr.compressed; - part_settings.Backup_FileName = Backup_FileName; part_settings.total_restore_size += part_settings.Part->Get_Restore_Size(&part_settings); part_settings.PM_Method = PM_RESTORE; ProgressTracking progress(part_settings.total_restore_size); diff --git a/partition.cpp b/partition.cpp index 6edc36822d..d34b465eec 100644 --- a/partition.cpp +++ b/partition.cpp @@ -1621,7 +1621,7 @@ bool TWPartition::Check_MD5(PartitionSettings *part_settings) { sync(); memset(split_filename, 0, sizeof(split_filename)); - Full_Filename = part_settings->Restore_Name + "/" + part_settings->Backup_FileName; + Full_Filename = part_settings->Backup_Folder + "/" + Backup_FileName; if (!TWFunc::Path_Exists(Full_Filename)) { // This is a split archive, we presume sprintf(split_filename, "%s%03i", Full_Filename.c_str(), index); @@ -1662,7 +1662,7 @@ bool TWPartition::Check_MD5(PartitionSettings *part_settings) { bool TWPartition::Restore(PartitionSettings *part_settings) { TWFunc::GUI_Operation_Text(TW_RESTORE_TEXT, Display_Name, gui_parse_text("{@restoring_hdr}")); - LOGINFO("Restore filename is: %s/%s\n", part_settings->Restore_Name.c_str(), part_settings->Backup_FileName.c_str()); + LOGINFO("Restore filename is: %s%s\n", part_settings->Backup_Folder.c_str(), Backup_FileName.c_str()); string Restore_File_System = Get_Restore_File_System(part_settings); @@ -1680,12 +1680,12 @@ string TWPartition::Get_Restore_File_System(PartitionSettings *part_settings) { string Restore_File_System; // Parse backup filename to extract the file system before wiping - first_period = part_settings->Backup_FileName.find("."); + first_period = Backup_FileName.find("."); if (first_period == string::npos) { LOGERR("Unable to find file system (first period).\n"); return string(); } - Restore_File_System = part_settings->Backup_FileName.substr(first_period + 1, part_settings->Backup_FileName.size() - first_period - 1); + Restore_File_System = Backup_FileName.substr(first_period + 1, Backup_FileName.size() - first_period - 1); second_period = Restore_File_System.find("."); if (second_period == string::npos) { LOGERR("Unable to find file system (second period).\n"); @@ -2167,14 +2167,14 @@ bool TWPartition::Backup_Tar(PartitionSettings *part_settings, pid_t *tar_fork_p #endif Backup_FileName = Backup_Name + "." + Current_File_System + ".win"; - Full_FileName = part_settings->Full_Backup_Path + Backup_FileName; + Full_FileName = part_settings->Backup_Folder + Backup_FileName; tar.has_data_media = Has_Data_Media; tar.part_settings = part_settings; tar.setdir(Backup_Path); tar.setfn(Full_FileName); tar.setsize(Backup_Size); tar.partition_name = Backup_Name; - tar.backup_folder = part_settings->Full_Backup_Path; + tar.backup_folder = part_settings->Backup_Folder; if (tar.createTarFork(tar_fork_pid) != 0) return false; return true; @@ -2191,10 +2191,10 @@ bool TWPartition::Backup_Image(PartitionSettings *part_settings) { if (part_settings->adbbackup) { Full_FileName = TW_ADB_BACKUP; - adb_file_name = part_settings->Full_Backup_Path + "/" + Backup_FileName; + adb_file_name = part_settings->Backup_Folder + "/" + Backup_FileName; } else - Full_FileName = part_settings->Full_Backup_Path + "/" + Backup_FileName; + Full_FileName = part_settings->Backup_Folder + "/" + Backup_FileName; part_settings->total_restore_size = Backup_Size; @@ -2227,14 +2227,14 @@ bool TWPartition::Raw_Read_Write(PartitionSettings *part_settings) { if (part_settings->adbbackup) destfn = TW_ADB_BACKUP; else - destfn = part_settings->Full_Backup_Path + part_settings->Backup_FileName; + destfn = part_settings->Backup_Folder + Backup_FileName; } else { destfn = Actual_Block_Device; if (part_settings->adbbackup) { srcfn = TW_ADB_RESTORE; } else { - srcfn = part_settings->Restore_Name + "/" + part_settings->Backup_FileName; + srcfn = part_settings->Backup_Folder + "/" + Backup_FileName; Remain = TWFunc::Get_File_Size(srcfn); } } @@ -2315,7 +2315,7 @@ bool TWPartition::Backup_Dump_Image(PartitionSettings *part_settings) { part_settings->progress->SetPartitionSize(Backup_Size); Backup_FileName = Backup_Name + "." + Current_File_System + ".win"; - Full_FileName = part_settings->Full_Backup_Path + "/" + Backup_FileName; + Full_FileName = part_settings->Backup_Folder + "/" + Backup_FileName; Command = "dump_image " + MTD_Name + " '" + Full_FileName + "'"; @@ -2335,7 +2335,7 @@ bool TWPartition::Backup_Dump_Image(PartitionSettings *part_settings) { unsigned long long TWPartition::Get_Restore_Size(PartitionSettings *part_settings) { if (!part_settings->adbbackup) { - InfoManager restore_info(part_settings->Restore_Name + "/" + Backup_Name + ".info"); + InfoManager restore_info(part_settings->Backup_Folder + "/" + Backup_Name + ".info"); if (restore_info.LoadValues() == 0) { if (restore_info.GetValue("backup_size", Restore_Size) == 0) { LOGINFO("Read info file, restore size is %llu\n", Restore_Size); @@ -2346,7 +2346,7 @@ unsigned long long TWPartition::Get_Restore_Size(PartitionSettings *part_setting string Full_FileName, Restore_File_System = Get_Restore_File_System(part_settings); - Full_FileName = part_settings->Restore_Name + "/" + Backup_FileName; + Full_FileName = part_settings->Backup_Folder + "/" + Backup_FileName; if (Is_Image(Restore_File_System)) { Restore_Size = TWFunc::Get_File_Size(Full_FileName); return Restore_Size; @@ -2363,7 +2363,7 @@ unsigned long long TWPartition::Get_Restore_Size(PartitionSettings *part_setting tar.setpassword(Password); #endif tar.partition_name = Backup_Name; - tar.backup_folder = part_settings->Restore_Name; + tar.backup_folder = part_settings->Backup_Folder; tar.part_settings = part_settings; Restore_Size = tar.get_size(); return Restore_Size; @@ -2395,7 +2395,7 @@ bool TWPartition::Restore_Tar(PartitionSettings *part_settings) { if (!ReMount_RW(true)) return false; - Full_FileName = part_settings->Restore_Name + "/" + part_settings->Backup_FileName; + Full_FileName = part_settings->Backup_Folder + "/" + Backup_FileName; twrpTar tar; tar.part_settings = part_settings; tar.setdir(Backup_Path); @@ -2448,7 +2448,7 @@ bool TWPartition::Restore_Image(PartitionSettings *part_settings) { if (part_settings->adbbackup) Full_FileName = TW_ADB_RESTORE; else - Full_FileName = part_settings->Full_Backup_Path + part_settings->Backup_FileName; + Full_FileName = part_settings->Backup_Folder + Backup_FileName; if (Restore_File_System == "emmc") { if (!part_settings->adbbackup) @@ -2607,9 +2607,12 @@ uint64_t TWPartition::Get_Max_FileSize() { bool TWPartition::Flash_Image(PartitionSettings *part_settings) { string Restore_File_System, full_filename; - full_filename = part_settings->Restore_Name + "/" + part_settings->Backup_FileName; + if (part_settings->Part != NULL) + full_filename = part_settings->Backup_Folder + "/" + Backup_FileName; + else + full_filename = part_settings->Backup_Folder; // Flash image action from GUI - LOGINFO("Image filename is: %s\n", part_settings->Backup_FileName.c_str()); + LOGINFO("Image filename is: %s\n", Backup_FileName.c_str()); if (Backup_Method == BM_FILES) { LOGERR("Cannot flash images to file systems\n"); @@ -2625,7 +2628,7 @@ bool TWPartition::Flash_Image(PartitionSettings *part_settings) { unsigned long long image_size = TWFunc::Get_File_Size(full_filename); if (image_size > Size) { LOGINFO("Size (%llu bytes) of image '%s' is larger than target device '%s' (%llu bytes)\n", - image_size, part_settings->Backup_FileName.c_str(), Actual_Block_Device.c_str(), Size); + image_size, Backup_FileName.c_str(), Actual_Block_Device.c_str(), Size); gui_err("img_size_err=Size of image is larger than target device"); return false; } diff --git a/partitionmanager.cpp b/partitionmanager.cpp index 20c2aee7f9..738f6ce3cc 100644 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -482,9 +482,11 @@ int TWPartitionManager::Check_Backup_Name(bool Display_Error) { bool TWPartitionManager::Make_MD5(PartitionSettings *part_settings) { - string command; - string Full_File = part_settings->Full_Backup_Path + part_settings->Backup_FileName; - string result; + string command, result; + + if (part_settings->Part == NULL) + return false; + string Full_File = part_settings->Backup_Folder + part_settings->Part->Backup_FileName; twrpDigest md5sum; if (!part_settings->generate_md5) @@ -548,7 +550,6 @@ bool TWPartitionManager::Backup_Partition(PartitionSettings *part_settings) { TWFunc::SetPerformanceMode(true); time(&start); - part_settings->Backup_FileName = part_settings->Part->Backup_Name + "." + part_settings->Part->Current_File_System + ".win"; if (part_settings->Part->Backup(part_settings, &tar_fork_pid)) { bool md5Success = false; if (part_settings->adbbackup) { @@ -563,9 +564,8 @@ bool TWPartitionManager::Backup_Partition(PartitionSettings *part_settings) { TWPartition *parentPart = part_settings->Part; for (subpart = Partitions.begin(); subpart != Partitions.end(); subpart++) { - part_settings->Part = *subpart; if ((*subpart)->Can_Be_Backed_Up && (*subpart)->Is_SubPartition && (*subpart)->SubPartition_Of == parentPart->Mount_Point) { - part_settings->Backup_FileName = part_settings->Part->Backup_Name + "." + part_settings->Part->Current_File_System + ".win"; + part_settings->Part = *subpart; if (!(*subpart)->Backup(part_settings, &tar_fork_pid)) { TWFunc::SetPerformanceMode(false); Clean_Backup_Folder(part_settings->Backup_Folder); @@ -705,18 +705,18 @@ int TWPartitionManager::Run_Backup(bool adbbackup) { part_settings.generate_md5 = false; DataManager::GetValue(TW_BACKUPS_FOLDER_VAR, part_settings.Backup_Folder); - DataManager::GetValue(TW_BACKUP_NAME, part_settings.Backup_Name); - if (part_settings.Backup_Name == gui_lookup("curr_date", "(Current Date)")) { - part_settings.Backup_Name = TWFunc::Get_Current_Date(); - } else if (part_settings.Backup_Name == gui_lookup("auto_generate", "(Auto Generate)") || part_settings.Backup_Name == "0" || part_settings.Backup_Name.empty()) { + DataManager::GetValue(TW_BACKUP_NAME, Backup_Name); + if (Backup_Name == gui_lookup("curr_date", "(Current Date)")) { + Backup_Name = TWFunc::Get_Current_Date(); + } else if (Backup_Name == gui_lookup("auto_generate", "(Auto Generate)") || Backup_Name == "0" || Backup_Name.empty()) { TWFunc::Auto_Generate_Backup_Name(); - DataManager::GetValue(TW_BACKUP_NAME, part_settings.Backup_Name); + DataManager::GetValue(TW_BACKUP_NAME, Backup_Name); } - LOGINFO("Backup Name is: '%s'\n", part_settings.Backup_Name.c_str()); - part_settings.Full_Backup_Path = part_settings.Backup_Folder + "/" + part_settings.Backup_Name + "/"; + LOGINFO("Backup Name is: '%s'\n", Backup_Name.c_str()); + part_settings.Backup_Folder = part_settings.Backup_Folder + "/" + Backup_Name + "/"; - LOGINFO("Full_Backup_Path is: '%s'\n", part_settings.Full_Backup_Path.c_str()); + LOGINFO("Full_Backup_Path is: '%s'\n", part_settings.Backup_Folder.c_str()); LOGINFO("Calculating backup details...\n"); DataManager::GetValue("tw_backup_list", Backup_List); @@ -792,8 +792,8 @@ int TWPartitionManager::Run_Backup(bool adbbackup) { part_settings.file_bytes_remaining = part_settings.file_bytes; gui_msg("backup_started=[BACKUP STARTED]"); - gui_msg(Msg("backup_folder= * Backup Folder: {1}")(part_settings.Full_Backup_Path)); - if (!TWFunc::Recursive_Mkdir(part_settings.Full_Backup_Path)) { + gui_msg(Msg("backup_folder= * Backup Folder: {1}")(part_settings.Backup_Folder)); + if (!TWFunc::Recursive_Mkdir(part_settings.Backup_Folder)) { gui_err("fail_backup_folder=Failed to make backup folder."); return false; } @@ -836,7 +836,7 @@ int TWPartitionManager::Run_Backup(bool adbbackup) { uint64_t actual_backup_size; if (!adbbackup) - actual_backup_size = du.Get_Folder_Size(part_settings.Full_Backup_Path); + actual_backup_size = du.Get_Folder_Size(part_settings.Backup_Folder); else actual_backup_size = part_settings.file_bytes + part_settings.img_bytes; actual_backup_size /= (1024LLU * 1024LLU); @@ -864,7 +864,7 @@ int TWPartitionManager::Run_Backup(bool adbbackup) { Update_System_Details(); UnMount_Main_Partitions(); gui_msg(Msg(msg::kHighlight, "backup_completed=[BACKUP COMPLETED IN {1} SECONDS]")(total_time)); // the end - string backup_log = part_settings.Full_Backup_Path + "recovery.log"; + string backup_log = part_settings.Backup_Folder + "recovery.log"; TWFunc::copy_file("/tmp/recovery.log", backup_log, 0644); tw_set_default_metadata(backup_log.c_str()); @@ -898,7 +898,6 @@ bool TWPartitionManager::Restore_Partition(PartitionSettings *part_settings) { for (subpart = Partitions.begin(); subpart != Partitions.end(); subpart++) { part_settings->Part = *subpart; if ((*subpart)->Is_SubPartition && (*subpart)->SubPartition_Of == parentPart->Mount_Point) { - part_settings->Backup_FileName = (*subpart)->Backup_Name + "." + (*subpart)->Current_File_System + ".win"; part_settings->Part = (*subpart); if (!(*subpart)->Restore(part_settings)) { TWFunc::SetPerformanceMode(false); @@ -924,7 +923,7 @@ int TWPartitionManager::Run_Restore(const string& Restore_Name) { string Restore_List, restore_path; size_t start_pos = 0, end_pos; - part_settings.Restore_Name = Restore_Name; + part_settings.Backup_Folder = Restore_Name; part_settings.Part = NULL; part_settings.partition_count = 0; part_settings.total_restore_size = 0; @@ -954,7 +953,6 @@ int TWPartitionManager::Run_Restore(const string& Restore_Name) { restore_path = Restore_List.substr(start_pos, end_pos - start_pos); part_settings.Part = Find_Partition_By_Path(restore_path); if (part_settings.Part != NULL) { - part_settings.Backup_FileName = part_settings.Part->Backup_Name + "." + part_settings.Part->Current_File_System + ".win"; if (part_settings.Part->Mount_Read_Only) { gui_msg(Msg(msg::kError, "restore_read_only=Cannot restore {1} -- mounted read only.")(part_settings.Part->Backup_Display_Name)); return false; @@ -969,7 +967,6 @@ int TWPartitionManager::Run_Restore(const string& Restore_Name) { std::vector::iterator subpart; for (subpart = Partitions.begin(); subpart != Partitions.end(); subpart++) { - part_settings.Backup_FileName = (*subpart)->Backup_Name + "." + (*subpart)->Current_File_System + ".win"; part_settings.Part = *subpart; if ((*subpart)->Is_SubPartition && (*subpart)->SubPartition_Of == parentPart->Mount_Point) { if (check_md5 > 0 && !(*subpart)->Check_MD5(&part_settings)) @@ -1006,8 +1003,6 @@ int TWPartitionManager::Run_Restore(const string& Restore_Name) { part_settings.Part = Find_Partition_By_Path(restore_path); if (part_settings.Part != NULL) { part_settings.partition_count++; - part_settings.Backup_FileName = part_settings.Part->Backup_Name + "." + part_settings.Part->Current_File_System + ".win"; - part_settings.Full_Backup_Path = part_settings.Backup_Folder + "/" + part_settings.Backup_FileName + "/"; if (!Restore_Partition(&part_settings)) return false; } else { @@ -2259,7 +2254,7 @@ bool TWPartitionManager::Flash_Image(PartitionSettings *part_settings) { string Flash_List, flash_path, full_filename; size_t start_pos = 0, end_pos = 0; - full_filename = part_settings->Restore_Name + "/" + part_settings->Backup_FileName; + full_filename = part_settings->Backup_Folder; gui_msg("image_flash_start=[IMAGE FLASH STARTED]"); gui_msg(Msg("img_to_flash=Image to flash: '{1}'")(full_filename)); diff --git a/partitions.hpp b/partitions.hpp index 201a4e1d18..aba1465e1d 100644 --- a/partitions.hpp +++ b/partitions.hpp @@ -44,11 +44,7 @@ class TWPartition; struct PartitionSettings { // Settings for backup session TWPartition* Part; // Partition to pass to the partition backup loop - std::string Backup_Folder; // Backup folder to put backup into - std::string Full_Backup_Path; // Path to the current backup storage setting - std::string Backup_Name; // Name of partition - std::string Restore_Name; // Path to restore folder - std::string Backup_FileName; // Name of the file to restore + std::string Backup_Folder; // Path to restore folder bool adbbackup; // tell the system we are backing up over adb bool adb_compression; // 0 == uncompressed, 1 == compressed bool generate_md5; // tell system to create md5 for partitions From d3ec059300b8c31cacce4cff45bc21831f4ddf06 Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Mon, 19 Sep 2016 13:50:25 -0500 Subject: [PATCH 5/6] Fix image flashing PS2: full_filename is not a dir PS3: use a consistent format of always assuming directory is missing the trailing / + fix whitespace alignment Change-Id: Ib963473ae10571b3d069b326d024ca04c7224dda --- gui/action.cpp | 9 +-------- partition.cpp | 13 +++++-------- partitionmanager.cpp | 27 ++++++++++++++++++--------- partitions.hpp | 44 ++++++++++++++++++++++---------------------- 4 files changed, 46 insertions(+), 47 deletions(-) diff --git a/gui/action.cpp b/gui/action.cpp index 3fde199d34..c156407605 100644 --- a/gui/action.cpp +++ b/gui/action.cpp @@ -1737,18 +1737,11 @@ int GUIAction::flashimage(std::string arg __unused) { int op_status = 0; - PartitionSettings part_settings; operation_start("Flash Image"); string path, filename; DataManager::GetValue("tw_zip_location", path); DataManager::GetValue("tw_file", filename); - part_settings.Backup_Folder = path + "/" + filename; - unsigned long long total_bytes = TWFunc::Get_File_Size(part_settings.Backup_Folder); - ProgressTracking progress(total_bytes); - part_settings.progress = &progress; - part_settings.adbbackup = false; - part_settings.PM_Method = PM_RESTORE; - if (PartitionManager.Flash_Image(&part_settings)) + if (PartitionManager.Flash_Image(path, filename)) op_status = 0; // success else op_status = 1; // fail diff --git a/partition.cpp b/partition.cpp index d34b465eec..f22a283dff 100644 --- a/partition.cpp +++ b/partition.cpp @@ -1662,7 +1662,7 @@ bool TWPartition::Check_MD5(PartitionSettings *part_settings) { bool TWPartition::Restore(PartitionSettings *part_settings) { TWFunc::GUI_Operation_Text(TW_RESTORE_TEXT, Display_Name, gui_parse_text("{@restoring_hdr}")); - LOGINFO("Restore filename is: %s%s\n", part_settings->Backup_Folder.c_str(), Backup_FileName.c_str()); + LOGINFO("Restore filename is: %s/%s\n", part_settings->Backup_Folder.c_str(), Backup_FileName.c_str()); string Restore_File_System = Get_Restore_File_System(part_settings); @@ -2167,7 +2167,7 @@ bool TWPartition::Backup_Tar(PartitionSettings *part_settings, pid_t *tar_fork_p #endif Backup_FileName = Backup_Name + "." + Current_File_System + ".win"; - Full_FileName = part_settings->Backup_Folder + Backup_FileName; + Full_FileName = part_settings->Backup_Folder + "/" + Backup_FileName; tar.has_data_media = Has_Data_Media; tar.part_settings = part_settings; tar.setdir(Backup_Path); @@ -2227,7 +2227,7 @@ bool TWPartition::Raw_Read_Write(PartitionSettings *part_settings) { if (part_settings->adbbackup) destfn = TW_ADB_BACKUP; else - destfn = part_settings->Backup_Folder + Backup_FileName; + destfn = part_settings->Backup_Folder + "/" + Backup_FileName; } else { destfn = Actual_Block_Device; @@ -2448,7 +2448,7 @@ bool TWPartition::Restore_Image(PartitionSettings *part_settings) { if (part_settings->adbbackup) Full_FileName = TW_ADB_RESTORE; else - Full_FileName = part_settings->Backup_Folder + Backup_FileName; + Full_FileName = part_settings->Backup_Folder + "/" + Backup_FileName; if (Restore_File_System == "emmc") { if (!part_settings->adbbackup) @@ -2607,10 +2607,7 @@ uint64_t TWPartition::Get_Max_FileSize() { bool TWPartition::Flash_Image(PartitionSettings *part_settings) { string Restore_File_System, full_filename; - if (part_settings->Part != NULL) - full_filename = part_settings->Backup_Folder + "/" + Backup_FileName; - else - full_filename = part_settings->Backup_Folder; // Flash image action from GUI + full_filename = part_settings->Backup_Folder + "/" + Backup_FileName; LOGINFO("Image filename is: %s\n", Backup_FileName.c_str()); diff --git a/partitionmanager.cpp b/partitionmanager.cpp index 738f6ce3cc..b04cc9ab81 100644 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -486,7 +486,7 @@ bool TWPartitionManager::Make_MD5(PartitionSettings *part_settings) if (part_settings->Part == NULL) return false; - string Full_File = part_settings->Backup_Folder + part_settings->Part->Backup_FileName; + string Full_File = part_settings->Backup_Folder + "/" + part_settings->Part->Backup_FileName; twrpDigest md5sum; if (!part_settings->generate_md5) @@ -622,7 +622,7 @@ void TWPartitionManager::Clean_Backup_Folder(string Backup_Folder) { if (!strcmp(p->d_name, ".") || !strcmp(p->d_name, "..")) continue; - string path = Backup_Folder + p->d_name; + string path = Backup_Folder + "/" + p->d_name; size_t dot = path.find_last_of(".") + 1; if (path.substr(dot) == "win" || path.substr(dot) == "md5" || path.substr(dot) == "info") { @@ -647,7 +647,7 @@ int TWPartitionManager::Cancel_Backup() { if (tar_fork_pid != 0) { DataManager::GetValue(TW_BACKUP_NAME, Backup_Name); DataManager::GetValue(TW_BACKUPS_FOLDER_VAR, Backup_Folder); - Full_Backup_Path = Backup_Folder + "/" + Backup_Name + "/"; + Full_Backup_Path = Backup_Folder + "/" + Backup_Name; LOGINFO("Killing pid: %d\n", tar_fork_pid); kill(tar_fork_pid, SIGUSR2); while (kill(tar_fork_pid, 0) == 0) { @@ -714,9 +714,9 @@ int TWPartitionManager::Run_Backup(bool adbbackup) { } LOGINFO("Backup Name is: '%s'\n", Backup_Name.c_str()); - part_settings.Backup_Folder = part_settings.Backup_Folder + "/" + Backup_Name + "/"; + part_settings.Backup_Folder = part_settings.Backup_Folder + "/" + Backup_Name; - LOGINFO("Full_Backup_Path is: '%s'\n", part_settings.Backup_Folder.c_str()); + LOGINFO("Backup_Folder is: '%s'\n", part_settings.Backup_Folder.c_str()); LOGINFO("Calculating backup details...\n"); DataManager::GetValue("tw_backup_list", Backup_List); @@ -864,7 +864,7 @@ int TWPartitionManager::Run_Backup(bool adbbackup) { Update_System_Details(); UnMount_Main_Partitions(); gui_msg(Msg(msg::kHighlight, "backup_completed=[BACKUP COMPLETED IN {1} SECONDS]")(total_time)); // the end - string backup_log = part_settings.Backup_Folder + "recovery.log"; + string backup_log = part_settings.Backup_Folder + "/recovery.log"; TWFunc::copy_file("/tmp/recovery.log", backup_log, 0644); tw_set_default_metadata(backup_log.c_str()); @@ -2248,13 +2248,13 @@ bool TWPartitionManager::Remove_MTP_Storage(unsigned int Storage_ID) { return false; } -bool TWPartitionManager::Flash_Image(PartitionSettings *part_settings) { +bool TWPartitionManager::Flash_Image(string& path, string& filename) { int check, partition_count = 0; TWPartition* flash_part = NULL; string Flash_List, flash_path, full_filename; size_t start_pos = 0, end_pos = 0; - full_filename = part_settings->Backup_Folder; + full_filename = path + "/" + filename; gui_msg("image_flash_start=[IMAGE FLASH STARTED]"); gui_msg(Msg("img_to_flash=Image to flash: '{1}'")(full_filename)); @@ -2269,6 +2269,14 @@ bool TWPartitionManager::Flash_Image(PartitionSettings *part_settings) { } } + PartitionSettings part_settings; + part_settings.Backup_Folder = path; + unsigned long long total_bytes = TWFunc::Get_File_Size(full_filename); + ProgressTracking progress(total_bytes); + part_settings.progress = &progress; + part_settings.adbbackup = false; + part_settings.PM_Method = PM_RESTORE; + gui_msg("calc_restore=Calculating restore details..."); DataManager::GetValue("tw_flash_partition", Flash_List); if (!Flash_List.empty()) { @@ -2298,7 +2306,8 @@ bool TWPartitionManager::Flash_Image(PartitionSettings *part_settings) { DataManager::SetProgress(0.0); if (flash_part) { - if (!flash_part->Flash_Image(part_settings)) + flash_part->Backup_FileName = filename; + if (!flash_part->Flash_Image(&part_settings)) return false; } else { gui_err("invalid_flash=Invalid flash partition specified."); diff --git a/partitions.hpp b/partitions.hpp index aba1465e1d..e301d9c70e 100644 --- a/partitions.hpp +++ b/partitions.hpp @@ -35,29 +35,29 @@ struct PartitionList { unsigned int selected; }; -enum PartitionManager_Op { // PartitionManager Restore Mode for Raw_Read_Write() +enum PartitionManager_Op { // PartitionManager Restore Mode for Raw_Read_Write() PM_BACKUP = 0, PM_RESTORE = 1, }; class TWPartition; -struct PartitionSettings { // Settings for backup session - TWPartition* Part; // Partition to pass to the partition backup loop - std::string Backup_Folder; // Path to restore folder - bool adbbackup; // tell the system we are backing up over adb - bool adb_compression; // 0 == uncompressed, 1 == compressed - bool generate_md5; // tell system to create md5 for partitions - uint64_t total_restore_size; // Total size of restored backup - uint64_t img_bytes_remaining; // remaining img/emmc bytes to backup for progress indicator - uint64_t file_bytes_remaining; // remaining file bytes to backup for progress indicator - uint64_t img_time; // used to calculate how fast we backup images - uint64_t file_time; // used to calculate how fast we backup files - uint64_t img_bytes; // total image bytes of all emmc partitions - uint64_t file_bytes; // total file bytes of all file based partitions - int partition_count; // Number of partitions to restore - ProgressTracking *progress; // Keep track of progress in GUI - enum PartitionManager_Op PM_Method; // Current operation of backup or restore +struct PartitionSettings { // Settings for backup session + TWPartition* Part; // Partition to pass to the partition backup loop + std::string Backup_Folder; // Path to restore folder + bool adbbackup; // tell the system we are backing up over adb + bool adb_compression; // 0 == uncompressed, 1 == compressed + bool generate_md5; // tell system to create md5 for partitions + uint64_t total_restore_size; // Total size of restored backup + uint64_t img_bytes_remaining; // remaining img/emmc bytes to backup for progress indicator + uint64_t file_bytes_remaining; // remaining file bytes to backup for progress indicator + uint64_t img_time; // used to calculate how fast we backup images + uint64_t file_time; // used to calculate how fast we backup files + uint64_t img_bytes; // total image bytes of all emmc partitions + uint64_t file_bytes; // total file bytes of all file based partitions + int partition_count; // Number of partitions to restore + ProgressTracking *progress; // Keep track of progress in GUI + enum PartitionManager_Op PM_Method; // Current operation of backup or restore }; enum Backup_Method_enum { @@ -92,7 +92,7 @@ class TWPartition bool Backup(PartitionSettings *part_settings, pid_t *tar_fork_pid); // Backs up the partition to the folder specified bool Check_MD5(PartitionSettings *part_settings); // Checks MD5 of a backup bool Restore(PartitionSettings *part_settings); // Restores the partition using the backup folder provided - unsigned long long Get_Restore_Size(PartitionSettings *part_settings);// Returns the overall restore size of the backup + unsigned long long Get_Restore_Size(PartitionSettings *part_settings); // Returns the overall restore size of the backup string Backup_Method_By_Name(); // Returns a string of the backup method for human readable output bool Decrypt(string Password); // Decrypts the partition, return 0 for failure and -1 for success bool Wipe_Encryption(); // Ignores wipe commands for /data/media devices and formats the original block device @@ -283,15 +283,15 @@ class TWPartitionManager void Decrypt_Adopted(); // Attempt to identy and decrypt any adopted storage partitions void Remove_Partition_By_Path(string Path); // Removes / erases a partition entry from the partition list - bool Flash_Image(PartitionSettings *part_settings); // Flashes an image to a selected partition from the partition list - bool Restore_Partition(struct PartitionSettings *part_settings); // Restore the partitions based on type + bool Flash_Image(string& path, string& filename); // Flashes an image to a selected partition from the partition list + bool Restore_Partition(struct PartitionSettings *part_settings); // Restore the partitions based on type TWAtomicInt stop_backup; private: void Setup_Settings_Storage_Partition(TWPartition* Part); // Sets up settings storage void Setup_Android_Secure_Location(TWPartition* Part); // Sets up .android_secure if needed - bool Make_MD5(struct PartitionSettings *part_settings); // Generates an MD5 after a backup is made - bool Backup_Partition(struct PartitionSettings *part_settings); // Backup the partitions based on type + bool Make_MD5(struct PartitionSettings *part_settings); // Generates an MD5 after a backup is made + bool Backup_Partition(struct PartitionSettings *part_settings); // Backup the partitions based on type void Output_Partition(TWPartition* Part); // Outputs partition details to the log TWPartition* Find_Partition_By_MTP_Storage_ID(unsigned int Storage_ID); // Returns a pointer to a partition based on MTP Storage ID bool Add_Remove_MTP_Storage(TWPartition* Part, int message_type); // Adds or removes an MTP Storage partition From f3c1b2f53c634ed302d8fcd8e7023dcc11f1e51a Mon Sep 17 00:00:00 2001 From: James Christopher Adduono Date: Tue, 25 Oct 2016 00:51:27 -0400 Subject: [PATCH 6/6] Fix image flashing: attempt 2 We missed a spot! Change-Id: Ic838f4a23107b4d52d3fb1d7a875e265726c4516 --- twrpTar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/twrpTar.cpp b/twrpTar.cpp index b566237984..ef07382325 100644 --- a/twrpTar.cpp +++ b/twrpTar.cpp @@ -445,7 +445,7 @@ int twrpTar::createTarFork(pid_t *tar_fork_pid) { part_settings->progress->UpdateDisplayDetails(true); if (!part_settings->adbbackup) { - InfoManager backup_info(backup_folder + partition_name + ".info"); + InfoManager backup_info(backup_folder + "/" + partition_name + ".info"); backup_info.SetValue("backup_size", size_backup); if (use_compression && use_encryption) backup_info.SetValue("backup_type", COMPRESSED_ENCRYPTED);