From b60a2732d5947341e5919836e4dc6ed950e335bd Mon Sep 17 00:00:00 2001 From: Captain Throwback Date: Tue, 13 Oct 2020 17:55:43 -0400 Subject: [PATCH] Unmount vendor partition prior to switching slots On some devices, having the vendor partition mounted causes slot switching to fail ("Error getting bootctrl module") Automatically unmount vendor partition prior to switching slots to ensure the process completes successfully. Use lazy unmount if Unmount_by_Path function fails. TEST: Mount vendor partition, then switch slots. Vendor partition should be unmounted when switching completes Change-Id: If6198d4693141be464749c4d423a9088753d939e --- gui/action.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/gui/action.cpp b/gui/action.cpp index 19c3d093..bf7af748 100755 --- a/gui/action.cpp +++ b/gui/action.cpp @@ -1932,10 +1932,19 @@ int GUIAction::togglebacklight(std::string arg __unused) int GUIAction::setbootslot(std::string arg) { operation_start("Set Boot Slot"); - if (!simulate) - PartitionManager.Set_Active_Slot(arg); - else + if (!simulate) { + if (!PartitionManager.UnMount_By_Path("/vendor", false)) { + // PartitionManager failed to unmount /vendor, this should not happen, + // but in case it does, do a lazy unmount + LOGINFO("WARNING: vendor partition could not be unmounted normally!\n"); + umount2("/vendor", MNT_DETACH); + PartitionManager.Set_Active_Slot(arg); + } else { + PartitionManager.Set_Active_Slot(arg); + } + } else { simulate_progress_bar(); + } operation_end(0); return 0; }