sdcard: bind mount in post decrypt

also uncomment wiping code that should not be commented

Change-Id: I445f688628dcedb67544c22c7b0775ee62e0b267
This commit is contained in:
bigbiff
2021-04-24 11:48:54 -04:00
parent a957f078be
commit be4f46cbc3
3 changed files with 21 additions and 9 deletions
+18 -9
View File
@@ -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.");
+2
View File
@@ -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");
}
+1
View File
@@ -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