From 77a31917f2817d3f147dc6e727f52d537e11fe4d Mon Sep 17 00:00:00 2001 From: Mohd Faraz Date: Tue, 21 Apr 2020 18:56:44 +0530 Subject: [PATCH] partitionmanager: Unmount all directories mounted to same block * Like Xiaomi's some older devices uses cust as vendor and also mounts cust & vendor simultanously * This patch will unmount all directories mounted to same block Change-Id: Ic242e267a470b4d82098d847f74b807a461605c4 Signed-off-by: Mohd Faraz --- partitionmanager.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/partitionmanager.cpp b/partitionmanager.cpp index b2654698..3c2b1c65 100755 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -1285,6 +1285,7 @@ void TWPartitionManager::Set_Restore_Files(string Restore_Name) { int TWPartitionManager::Wipe_By_Path(string Path) { std::vector::iterator iter; + std::vector < TWPartition * >::iterator iter1; int ret = false; bool found = false; string Local_Path = TWFunc::Get_Root_Path(Path); @@ -1292,6 +1293,14 @@ int TWPartitionManager::Wipe_By_Path(string Path) { // Iterate through all partitions for (iter = Partitions.begin(); iter != Partitions.end(); iter++) { if ((*iter)->Mount_Point == Local_Path || (!(*iter)->Symlink_Mount_Point.empty() && (*iter)->Symlink_Mount_Point == Local_Path)) { + // iterate through all partitions since some legacy devices uses other partitions as vendor causes issues while wiping + (*iter)->Find_Actual_Block_Device(); + for (iter1 = Partitions.begin (); iter1 != Partitions.end (); iter1++) + { + (*iter1)->Find_Actual_Block_Device(); + if ((*iter)->Actual_Block_Device == (*iter1)->Actual_Block_Device && (*iter)->Mount_Point != (*iter1)->Mount_Point) + (*iter1)->UnMount(false); + } if (Path == "/and-sec") ret = (*iter)->Wipe_AndSec(); else