summaryrefslogtreecommitdiffstats
path: root/partitionmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'partitionmanager.cpp')
-rw-r--r--partitionmanager.cpp53
1 files changed, 41 insertions, 12 deletions
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 0bed258ea..d7f1600ef 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -184,6 +184,10 @@ void TWPartitionManager::Output_Partition(TWPartition* Part) {
printf("Is_Decrypted ");
if (Part->Has_Data_Media)
printf("Has_Data_Media ");
+ if (Part->Can_Encrypt_Backup)
+ printf("Can_Encrypt_Backup ");
+ if (Part->Use_Userdata_Encryption)
+ printf("Use_Userdata_Encryption ");
if (Part->Has_Android_Secure)
printf("Has_Android_Secure ");
if (Part->Is_Storage)
@@ -532,18 +536,20 @@ bool TWPartitionManager::Make_MD5(bool generate_md5, string Backup_Folder, strin
string strfn;
sprintf(filename, "%s%03i", Full_File.c_str(), index);
strfn = filename;
- while (TWFunc::Path_Exists(filename) == true) {
+ while (index < 1000) {
md5sum.setfn(filename);
- if (md5sum.computeMD5() == 0) {
- if (md5sum.write_md5digest() != 0)
- {
- gui_print(" * MD5 Error.\n");
+ if (TWFunc::Path_Exists(filename)) {
+ if (md5sum.computeMD5() == 0) {
+ if (md5sum.write_md5digest() != 0)
+ {
+ gui_print(" * MD5 Error.\n");
+ return false;
+ }
+ } else {
+ gui_print(" * Error computing MD5.\n");
return false;
}
}
- else {
- return -1;
- }
index++;
sprintf(filename, "%s%03i", Full_File.c_str(), index);
strfn = filename;
@@ -902,7 +908,9 @@ int TWPartitionManager::Run_Restore(string Restore_Name) {
void TWPartitionManager::Set_Restore_Files(string Restore_Name) {
// Start with the default values
string Restore_List;
- bool get_date = true;
+ bool get_date = true, check_encryption = true;
+
+ DataManager::SetValue("tw_restore_encrypted", 0);
DIR* d;
d = opendir(Restore_Name.c_str());
@@ -956,10 +964,20 @@ void TWPartitionManager::Set_Restore_Files(string Restore_Name) {
extn = ptr;
}
- if (strcmp(fstype, "log") == 0) continue;
+ if (fstype == NULL || extn == NULL || strcmp(fstype, "log") == 0) continue;
int extnlength = strlen(extn);
- if (extn == NULL || (extnlength != 3 && extnlength != 6)) continue;
- if (extnlength == 3 && strncmp(extn, "win", 3) != 0) continue;
+ if (extnlength != 3 && extnlength != 6) continue;
+ if (extnlength >= 3 && strncmp(extn, "win", 3) != 0) continue;
+ //if (extnlength == 6 && strncmp(extn, "win000", 6) != 0) continue;
+
+ if (check_encryption) {
+ string filename = Restore_Name + "/";
+ filename += de->d_name;
+ if (TWFunc::Get_File_Type(filename) == 2) {
+ LOGINFO("'%s' is encrypted\n", filename.c_str());
+ DataManager::SetValue("tw_restore_encrypted", 1);
+ }
+ }
if (extnlength == 6 && strncmp(extn, "win000", 6) != 0) continue;
TWPartition* Part = Find_Partition_By_Path(label);
@@ -1173,6 +1191,9 @@ int TWPartitionManager::Wipe_Media_From_Data(void) {
return -1;
if (dat->Has_Data_Media) {
dat->Recreate_Media_Folder();
+ // Unmount and remount - slightly hackish way to ensure that the "/sdcard" folder is still mounted properly after wiping
+ dat->UnMount(false);
+ dat->Mount(false);
}
return true;
} else {
@@ -1399,6 +1420,7 @@ int TWPartitionManager::Decrypt_Device(string Password) {
dat->Is_Decrypted = true;
dat->Decrypted_Block_Device = crypto_blkdev;
dat->Setup_File_System(false);
+ dat->Current_File_System = dat->Fstab_File_System; // Needed if we're ignoring blkid because encrypted devices start out as emmc
gui_print("Data successfully decrypted, new block device: '%s'\n", crypto_blkdev);
#ifdef CRYPTO_SD_FS_TYPE
@@ -1830,6 +1852,13 @@ void TWPartitionManager::Get_Partition_List(string ListType, std::vector<Partiti
part.selected = 0;
Partition_List->push_back(part);
}
+ if ((*iter)->Has_Data_Media) {
+ struct PartitionList datamedia;
+ datamedia.Display_Name = (*iter)->Storage_Name;
+ datamedia.Mount_Point = "INTERNAL";
+ datamedia.selected = 0;
+ Partition_List->push_back(datamedia);
+ }
}
} else {
LOGERR("Unknown list type '%s' requested for TWPartitionManager::Get_Partition_List\n", ListType.c_str());