summaryrefslogtreecommitdiffstats
path: root/partitionmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--partitionmanager.cpp46
1 files changed, 16 insertions, 30 deletions
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 40e08634a..f94b6aa22 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -362,8 +362,7 @@ void TWPartitionManager::Output_Partition(TWPartition* Part) {
printf(" Format_Block_Size: %lu\n", Part->Format_Block_Size);
if (!Part->MTD_Name.empty())
printf(" MTD_Name: %s\n", Part->MTD_Name.c_str());
- string back_meth = Part->Backup_Method_By_Name();
- printf(" Backup_Method: %s\n", back_meth.c_str());
+ printf(" Backup_Method: %s\n", Part->Backup_Method_By_Name().c_str());
if (Part->Mount_Flags || !Part->Mount_Options.empty())
printf(" Mount_Options: %s\n", Part->Mount_Options.c_str());
if (Part->MTP_Storage_ID)
@@ -569,10 +568,9 @@ bool TWPartitionManager::Make_MD5(PartitionSettings *part_settings)
return true;
}
-
bool TWPartitionManager::Backup_Partition(PartitionSettings *part_settings) {
time_t start, stop;
- int use_compression, adb_control_bu_fd;
+ int use_compression;
string backup_log = part_settings->Backup_Folder + "/recovery.log";
if (part_settings->Part == NULL)
@@ -585,13 +583,11 @@ bool TWPartitionManager::Backup_Partition(PartitionSettings *part_settings) {
if (part_settings->Part->Backup(part_settings, &tar_fork_pid)) {
bool md5Success = false;
- if (part_settings->adbbackup) {
+ if (part_settings->adbbackup)
md5Success = true;
- }
else
md5Success = Make_MD5(part_settings);
- TWFunc::SetPerformanceMode(false);
if (part_settings->Part->Has_SubPartition) {
std::vector<TWPartition*>::iterator subpart;
TWPartition *parentPart = part_settings->Part;
@@ -600,10 +596,10 @@ bool TWPartitionManager::Backup_Partition(PartitionSettings *part_settings) {
if ((*subpart)->Can_Be_Backed_Up && (*subpart)->Is_SubPartition && (*subpart)->SubPartition_Of == parentPart->Mount_Point) {
part_settings->Part = *subpart;
if (!(*subpart)->Backup(part_settings, &tar_fork_pid)) {
- TWFunc::SetPerformanceMode(false);
Clean_Backup_Folder(part_settings->Backup_Folder);
TWFunc::copy_file("/tmp/recovery.log", backup_log, 0644);
tw_set_default_metadata(backup_log.c_str());
+ TWFunc::SetPerformanceMode(false);
return false;
}
sync();
@@ -628,6 +624,7 @@ bool TWPartitionManager::Backup_Partition(PartitionSettings *part_settings) {
}
+ TWFunc::SetPerformanceMode(false);
return md5Success;
} else {
Clean_Backup_Folder(part_settings->Backup_Folder);
@@ -697,14 +694,14 @@ int TWPartitionManager::Cancel_Backup() {
int TWPartitionManager::Run_Backup(bool adbbackup) {
PartitionSettings part_settings;
- int check, partition_count = 0, disable_free_space_check = 0, do_md5 = 0;
+ int partition_count = 0, disable_free_space_check = 0, do_md5 = 0;
int gui_adb_backup;
string Backup_Name, Backup_List, backup_path;
- unsigned long long total_bytes = 0, free_space = 0, subpart_size;
+ unsigned long long total_bytes = 0, free_space = 0;
TWPartition* storage = NULL;
std::vector<TWPartition*>::iterator subpart;
struct tm *t;
- time_t start, stop, seconds, total_start, total_stop;
+ time_t seconds, total_start, total_stop;
size_t start_pos = 0, end_pos = 0;
stop_backup.set_value(0);
seconds = time(0);
@@ -730,7 +727,6 @@ int TWPartitionManager::Run_Backup(bool adbbackup) {
if (!Mount_Current_Storage(true))
return false;
-
DataManager::GetValue(TW_SKIP_MD5_GENERATE_VAR, do_md5);
if (do_md5 == 0)
part_settings.generate_md5 = true;
@@ -842,7 +838,6 @@ int TWPartitionManager::Run_Backup(bool adbbackup) {
part_settings.Part = Find_Partition_By_Path(backup_path);
if (part_settings.Part != NULL) {
if (!Backup_Partition(&part_settings))
-
return false;
} else {
gui_msg(Msg(msg::kError, "unable_to_locate_partition=Unable to locate '{1}' partition for backup calculations.")(backup_path));
@@ -877,6 +872,7 @@ int TWPartitionManager::Run_Backup(bool adbbackup) {
int prev_img_bps = 0, use_compression = 0;
unsigned long long prev_file_bps = 0;
+ DataManager::GetValue(TW_BACKUP_AVG_IMG_RATE, prev_img_bps);
img_bps += (prev_img_bps * 4);
img_bps /= 5;
@@ -920,7 +916,6 @@ bool TWPartitionManager::Restore_Partition(PartitionSettings *part_settings) {
time(&Start);
-
if (!part_settings->Part->Restore(part_settings)) {
TWFunc::SetPerformanceMode(false);
return false;
@@ -949,8 +944,7 @@ bool TWPartitionManager::Restore_Partition(PartitionSettings *part_settings) {
int TWPartitionManager::Run_Restore(const string& Restore_Name) {
PartitionSettings part_settings;
- int check_md5, check, partition_count = 0;
- TWPartition* restore_part = NULL;
+ int check_md5;
time_t rStart, rStop;
time(&rStart);
@@ -1519,9 +1513,7 @@ void TWPartitionManager::Post_Decrypt(const string& Block_Device) {
int TWPartitionManager::Decrypt_Device(string Password) {
#ifdef TW_INCLUDE_CRYPTO
- int ret_val, password_len;
char crypto_state[PROPERTY_VALUE_MAX], crypto_blkdev[PROPERTY_VALUE_MAX], cPassword[255];
- size_t result;
std::vector<TWPartition*>::iterator iter;
// Mount any partitions that need to be mounted for decrypt
@@ -1587,7 +1579,6 @@ int TWPartitionManager::Decrypt_Device(string Password) {
}
int TWPartitionManager::Fix_Contexts(void) {
-#ifdef HAVE_SELINUX
std::vector<TWPartition*>::iterator iter;
for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
if ((*iter)->Has_Data_Media) {
@@ -1600,10 +1591,6 @@ int TWPartitionManager::Fix_Contexts(void) {
UnMount_Main_Partitions();
gui_msg("done=Done.");
return 0;
-#else
- LOGERR("Cannot fix contexts, no selinux support present.\n");
- return -1;
-#endif
}
TWPartition* TWPartitionManager::Find_Next_Storage(string Path, bool Exclude_Data_Media) {
@@ -1650,7 +1637,7 @@ int TWPartitionManager::Open_Lun_File(string Partition_Path, string Lun_File) {
}
int TWPartitionManager::usb_storage_enable(void) {
- int has_dual, has_data_media;
+ int has_data_media;
char lun_file[255];
bool has_multiple_lun = false;
@@ -1763,7 +1750,7 @@ void TWPartitionManager::UnMount_Main_Partitions(void) {
}
int TWPartitionManager::Partition_SDCard(void) {
- char mkdir_path[255], temp[255], line[512];
+ char temp[255];
string Storage_Path, Command, Device, fat_str, ext_str, start_loc, end_loc, ext_format, sd_path, tmpdevice;
int ext, swap, total_size = 0, fat_size;
@@ -2078,13 +2065,13 @@ TWPartition *TWPartitionManager::Get_Default_Storage_Partition()
{
TWPartition *res = NULL;
for (std::vector<TWPartition*>::iterator iter = Partitions.begin(); iter != Partitions.end(); ++iter) {
- if(!(*iter)->Is_Storage)
+ if (!(*iter)->Is_Storage)
continue;
- if((*iter)->Is_Settings_Storage)
+ if ((*iter)->Is_Settings_Storage)
return *iter;
- if(!res)
+ if (!res)
res = *iter;
}
return res;
@@ -2310,7 +2297,7 @@ bool TWPartitionManager::Remove_MTP_Storage(unsigned int Storage_ID) {
}
bool TWPartitionManager::Flash_Image(string& path, string& filename) {
- int check, partition_count = 0;
+ int partition_count = 0;
TWPartition* flash_part = NULL;
string Flash_List, flash_path, full_filename;
size_t start_pos = 0, end_pos = 0;
@@ -2448,7 +2435,6 @@ void TWPartitionManager::Decrypt_Adopted() {
char* xmlFile = PageManager::LoadFileToBuffer("/data/system/storage.xml", NULL);
xml_document<> *doc = NULL;
xml_node<>* volumes = NULL;
- xml_node<>* volume = NULL;
string Primary_Storage_UUID = "";
if (xmlFile != NULL) {
LOGINFO("successfully loaded storage.xml\n");