Skip to content

Commit

Permalink
recovery: Add ability to unmount system
Browse files Browse the repository at this point in the history
* Correct system mount text while we are at it

Change-Id: I955173e84767e61d729fb55b4e53a84e310e786e

recovery: Fix typo when unmounting system

Signed-off-by: Mohammad Hasan Keramat J <[email protected]>
Change-Id: I86c245c1e624bea045eac25657af02b45cd1d605
  • Loading branch information
mikeNG authored and xenxynon committed Dec 28, 2024
1 parent ae76895 commit c7df3ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
27 changes: 19 additions & 8 deletions recovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
#include <sys/types.h>
#include <sys/mount.h>
#include <fs_mgr.h>
Expand Down Expand Up @@ -608,16 +609,26 @@ static Device::BuiltinAction PromptAndWait(Device* device, InstallResult status)
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;
Expand Down
2 changes: 1 addition & 1 deletion recovery_ui/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static std::vector<std::pair<std::string, Device::BuiltinAction>> g_menu_actions
{ "Apply update from SD card", Device::APPLY_SDCARD },
{ "Wipe data/factory reset", Device::WIPE_DATA },
{ "Wipe cache partition", Device::WIPE_CACHE },
{ "Mount /system", Device::MOUNT_SYSTEM },
{ "Mount/unmount system", Device::MOUNT_SYSTEM },
{ "View recovery logs", Device::VIEW_RECOVERY_LOGS },
{ "Run graphics test", Device::RUN_GRAPHICS_TEST },
{ "Run locale test", Device::RUN_LOCALE_TEST },
Expand Down

0 comments on commit c7df3ff

Please sign in to comment.