sdcard: bind mount in post decrypt

also uncomment wiping code that should not be commented

Change-Id: I445f688628dcedb67544c22c7b0775ee62e0b267
diff --git a/partition.cpp b/partition.cpp
index cf5c881..54522a9 100755
--- a/partition.cpp
+++ b/partition.cpp
@@ -1615,9 +1615,18 @@
 	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 @@
 			}
 		}
 
-		// 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 @@
 	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 284fe2b..9a30249 100755
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -1766,6 +1766,8 @@
 		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 a3c4528..03a603e 100755
--- a/partitions.hpp
+++ b/partitions.hpp
@@ -126,6 +126,7 @@
 	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