diff options
-rw-r--r-- | partition.cpp | 4 | ||||
-rw-r--r-- | partitionmanager.cpp | 7 |
2 files changed, 10 insertions, 1 deletions
diff --git a/partition.cpp b/partition.cpp index f2386d7a8..076c1cfb1 100644 --- a/partition.cpp +++ b/partition.cpp @@ -705,7 +705,9 @@ bool TWPartition::Mount(bool Display_Error) { return false; } else { #ifdef TW_INCLUDE_CRYPTO_SAMSUNG - if (EcryptFS_Password.size() > 0 && PartitionManager.Mount_By_Path("/data", false)) { + string MetaEcfsFile = EXPAND(TW_EXTERNAL_STORAGE_PATH); + MetaEcfsFile += "/.MetaEcfsFile"; + if (EcryptFS_Password.size() > 0 && PartitionManager.Mount_By_Path("/data", false) && TWFunc::Path_Exists(MetaEcfsFile)) { if (mount_ecryptfs_drive(EcryptFS_Password.c_str(), Mount_Point.c_str(), Mount_Point.c_str(), 0) != 0) { if (Display_Error) LOGE("Unable to mount ecryptfs for '%s'\n", Mount_Point.c_str()); diff --git a/partitionmanager.cpp b/partitionmanager.cpp index e752a129c..7ebd64f0b 100644 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -1650,6 +1650,13 @@ int TWPartitionManager::Decrypt_Device(string Password) { sdcard->Is_Decrypted = true; sdcard->EcryptFS_Password = Password; sdcard->Decrypted_Block_Device = sdcard->Actual_Block_Device; + string MetaEcfsFile = EXPAND(TW_EXTERNAL_STORAGE_PATH); + MetaEcfsFile += "/.MetaEcfsFile"; + if (!TWFunc::Path_Exists(MetaEcfsFile)) { + // External storage isn't actually encrypted so unmount and remount without ecryptfs + sdcard->UnMount(false); + sdcard->Mount(false); + } } else { sdcard->Is_Decrypted = false; sdcard->Decrypted_Block_Device = ""; |