recovery: Add ability to unmount system
* Correct system mount text while we are at it
Change-Id: I955173e84767e61d729fb55b4e53a84e310e786e
recovery.cpp: Fix typo when unmounting system
Signed-off-by: Mohammad Hasan Keramat J <ikeramat@protonmail.com>
Change-Id: I86c245c1e624bea045eac25657af02b45cd1d605
diff --git a/recovery.cpp b/recovery.cpp
index fb39b15..7fb0b95 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/mount.h>
#include <sys/types.h>
#include <unistd.h>
@@ -601,16 +602,26 @@
break;
}
- case Device::MOUNT_SYSTEM:
- // For Virtual A/B, set up the snapshot devices (if exist).
- if (!CreateSnapshotPartitions()) {
- ui->Print("Virtual A/B: snapshot partitions creation failed.\n");
- break;
- }
- if (ensure_path_mounted_at(android::fs_mgr::GetSystemRoot(), "/mnt/system") != -1) {
- ui->Print("Mounted /system.\n");
+ case Device::MOUNT_SYSTEM: {
+ static bool mounted = false;
+ if (!mounted) {
+ // For Virtual A/B, set up the snapshot devices (if exist).
+ if (!logical_partitions_mapped() && !CreateSnapshotPartitions()) {
+ ui->Print("Virtual A/B: snapshot partitions creation failed.\n");
+ break;
+ }
+ if (ensure_path_mounted_at(android::fs_mgr::GetSystemRoot(), "/mnt/system") != -1) {
+ ui->Print("Mounted /mnt/system.\n");
+ mounted = true;
+ }
+ } else {
+ if (umount("/mnt/system") != -1) {
+ ui->Print("Unmounted /mnt/system.\n");
+ mounted = false;
+ }
}
break;
+ }
case Device::KEY_INTERRUPTED:
return Device::KEY_INTERRUPTED;