diff options
author | Erfan Abdi <erfangplus@gmail.com> | 2020-04-14 23:07:33 +0430 |
---|---|---|
committer | alk3pInjection <webmaster@raspii.tech> | 2022-01-29 00:06:32 +0800 |
commit | 07f3841a58e699cc0613763201ae8b5fef34ed13 (patch) | |
tree | be02f1a25b21d4791612296e4ec18c53126829fc | |
parent | c6e3e15a582d2a3be5774bf52d832a329106f671 (diff) |
recovery: Map logical partitions before installation
Change-Id: I785b49086a2baf462e97be831b495d7db72f7a42
-rw-r--r-- | recovery_main.cpp | 2 | ||||
-rw-r--r-- | recovery_utils/include/recovery_utils/roots.h | 2 | ||||
-rw-r--r-- | recovery_utils/roots.cpp | 17 |
3 files changed, 20 insertions, 1 deletions
diff --git a/recovery_main.cpp b/recovery_main.cpp index 80cba61d..b7cf0574 100644 --- a/recovery_main.cpp +++ b/recovery_main.cpp @@ -538,7 +538,7 @@ int main(int argc, char** argv) { } case Device::ENTER_FASTBOOT: - if (android::fs_mgr::LogicalPartitionsMapped()) { + if (logical_partitions_mapped()) { ui->Print("Partitions may be mounted - rebooting to enter fastboot."); Reboot("fastboot"); } else { diff --git a/recovery_utils/include/recovery_utils/roots.h b/recovery_utils/include/recovery_utils/roots.h index 92ee756f..bd6dbea0 100644 --- a/recovery_utils/include/recovery_utils/roots.h +++ b/recovery_utils/include/recovery_utils/roots.h @@ -56,3 +56,5 @@ int setup_install_mounts(); // Returns true if there is /cache in the volumes. bool HasCache(); + +bool logical_partitions_mapped();
\ No newline at end of file diff --git a/recovery_utils/roots.cpp b/recovery_utils/roots.cpp index 52eae384..0de61ae8 100644 --- a/recovery_utils/roots.cpp +++ b/recovery_utils/roots.cpp @@ -37,6 +37,7 @@ #include <ext4_utils/wipe.h> #include <fs_mgr.h> #include <fs_mgr/roots.h> +#include <fs_mgr_dm_linear.h> #include "otautil/sysutil.h" @@ -290,6 +291,8 @@ int format_volume(const std::string& volume) { return format_volume(volume, ""); } +static bool logical_partitions_auto_mapped = false; + int setup_install_mounts() { if (fstab.empty()) { LOG(ERROR) << "can't set up install mounts: no fstab loaded"; @@ -314,6 +317,16 @@ int setup_install_mounts() { } } } + // Map logical partitions + if (android::base::GetBoolProperty("ro.boot.dynamic_partitions", false) && + !logical_partitions_mapped()) { + std::string super_name = fs_mgr_get_super_partition_name(); + if (!android::fs_mgr::CreateLogicalPartitions("/dev/block/by-name/" + super_name)) { + LOG(ERROR) << "Failed to map logical partitions"; + } else { + logical_partitions_auto_mapped = true; + } + } return 0; } @@ -322,3 +335,7 @@ bool HasCache() { static bool has_cache = volume_for_mount_point(CACHE_ROOT) != nullptr; return has_cache; } + +bool logical_partitions_mapped() { + return android::fs_mgr::LogicalPartitionsMapped() || logical_partitions_auto_mapped; +} |