diff --git a/partition.cpp b/partition.cpp index cf5c8816..54522a91 100755 --- a/partition.cpp +++ b/partition.cpp @@ -1615,9 +1615,18 @@ bool TWPartition::Mount(bool Display_Error) { if (Removable) Update_Size(Display_Error); - if (!Symlink_Mount_Point.empty() && TWFunc::Path_Exists(Symlink_Path)) { - string Command = "/system/bin/mount -o bind '" + Symlink_Path + "' '" + Symlink_Mount_Point + "'"; - TWFunc::Exec_Cmd(Command); + if (!Symlink_Mount_Point.empty()) { + if (!Bind_Mount(false)) + return false; + } + return true; +} + +bool TWPartition::Bind_Mount(bool Display_Error) { + if (TWFunc::Path_Exists(Symlink_Path)) { + if (mount(Symlink_Path.c_str(), Symlink_Mount_Point.c_str(), "", MS_BIND, NULL) < 0) { + return false; + } } return true; } @@ -1750,8 +1759,8 @@ bool TWPartition::Wipe(string New_File_System) { } } - // if (Is_Storage && Mount(false)) - // PartitionManager.Add_MTP_Storage(MTP_Storage_ID); + if (Is_Storage && Mount(false)) + PartitionManager.Add_MTP_Storage(MTP_Storage_ID); } return wiped; @@ -2057,10 +2066,10 @@ bool TWPartition::Wipe_Encryption() { Is_Encrypted = false; if (Wipe(Fstab_File_System)) { Has_Data_Media = Save_Data_Media; - // if (Has_Data_Media && !Symlink_Mount_Point.empty()) { - // if (Mount(false)) - // PartitionManager.Add_MTP_Storage(MTP_Storage_ID); - // } + if (Has_Data_Media && !Symlink_Mount_Point.empty()) { + if (Mount(false)) + PartitionManager.Add_MTP_Storage(MTP_Storage_ID); + } DataManager::SetValue(TW_IS_ENCRYPTED, 0); #ifndef TW_OEM_BUILD gui_msg("format_data_msg=You may need to reboot recovery to be able to use /data again."); diff --git a/partitionmanager.cpp b/partitionmanager.cpp index 284fe2bc..9a30249d 100755 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -1766,6 +1766,8 @@ void TWPartitionManager::Post_Decrypt(const string& Block_Device) { DataManager::LoadTWRPFolderInfo(); Update_System_Details(); Output_Partition(dat); + if (!dat->Bind_Mount(false)) + LOGERR("Unable to bind mount /sdcard to %s\n", dat->Storage_Path.c_str()); } else LOGERR("Unable to locate data partition.\n"); } diff --git a/partitions.hpp b/partitions.hpp index a3c45281..03a603e4 100755 --- a/partitions.hpp +++ b/partitions.hpp @@ -126,6 +126,7 @@ public: bool UnMount(bool Display_Error); // Unmounts the partition if it is mounted bool ReMount(bool Display_Error); // Remounts the partition bool ReMount_RW(bool Display_Error); // Remounts the partition with read/write access + bool Bind_Mount(bool Display_Error); // Bind mount partition if symlink mountpoint is populated bool Wipe(string New_File_System); // Wipes the partition bool Wipe(); // Wipes the partition bool Wipe_AndSec(); // Wipes android secure