SYSTEM_ROOT -> get_system_root
Add a get_system_root() function in roots.cpp
which returns / or /system based on fstab.
This factors out the 'if' check from recovery.cpp
and fsck_unshare_blocks.cpp.
Test: boot recovery, mount system
Bug: 118634720
Change-Id: If4947cba3a3f08dbe695fd2b50a9354cd302ee03
diff --git a/recovery.cpp b/recovery.cpp
index e17526a..7e1fa43 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -78,7 +78,6 @@
static constexpr const char* DATA_ROOT = "/data";
static constexpr const char* METADATA_ROOT = "/metadata";
static constexpr const char* SDCARD_ROOT = "/sdcard";
-static constexpr const char* SYSTEM_ROOT = "/system";
// We define RECOVERY_API_VERSION in Android.mk, which will be picked up by build system and packed
// into target_files.zip. Assert the version defined in code and in Android.mk are consistent.
@@ -837,14 +836,8 @@
}
case Device::MOUNT_SYSTEM:
// the system partition is mounted at /mnt/system
- if (volume_for_mount_point(SYSTEM_ROOT) == nullptr) {
- if (ensure_path_mounted_at("/", "/mnt/system") != -1) {
- ui->Print("Mounted /system.\n");
- }
- } else {
- if (ensure_path_mounted_at(SYSTEM_ROOT, "/mnt/system") != -1) {
- ui->Print("Mounted /system.\n");
- }
+ if (ensure_path_mounted_at(get_system_root().c_str(), "/mnt/system") != -1) {
+ ui->Print("Mounted /system.\n");
}
break;