diff options
author | David Anderson <dvander@google.com> | 2018-10-30 02:48:56 +0100 |
---|---|---|
committer | David Anderson <dvander@google.com> | 2018-10-30 21:47:59 +0100 |
commit | 2b2f423ef694a03f4fd429b1d3fa221619131df4 (patch) | |
tree | ebf4be0805c18d4bb9f450be8bfcd2742e16845b | |
parent | Merge "Add description for the new translation" (diff) | |
download | android_bootable_recovery-2b2f423ef694a03f4fd429b1d3fa221619131df4.tar android_bootable_recovery-2b2f423ef694a03f4fd429b1d3fa221619131df4.tar.gz android_bootable_recovery-2b2f423ef694a03f4fd429b1d3fa221619131df4.tar.bz2 android_bootable_recovery-2b2f423ef694a03f4fd429b1d3fa221619131df4.tar.lz android_bootable_recovery-2b2f423ef694a03f4fd429b1d3fa221619131df4.tar.xz android_bootable_recovery-2b2f423ef694a03f4fd429b1d3fa221619131df4.tar.zst android_bootable_recovery-2b2f423ef694a03f4fd429b1d3fa221619131df4.zip |
-rw-r--r-- | recovery_main.cpp | 9 | ||||
-rw-r--r-- | roots.cpp | 25 | ||||
-rw-r--r-- | roots.h | 2 |
3 files changed, 34 insertions, 2 deletions
diff --git a/recovery_main.cpp b/recovery_main.cpp index 78350944c..19ef4f3d0 100644 --- a/recovery_main.cpp +++ b/recovery_main.cpp @@ -478,8 +478,13 @@ int main(int argc, char** argv) { break; case Device::ENTER_FASTBOOT: - LOG(INFO) << "Entering fastboot"; - fastboot = true; + if (logical_partitions_mapped()) { + ui->Print("Partitions may be mounted - rebooting to enter fastboot."); + android::base::SetProperty(ANDROID_RB_PROPERTY, "reboot,fastboot"); + } else { + LOG(INFO) << "Entering fastboot"; + fastboot = true; + } break; case Device::ENTER_RECOVERY: @@ -38,10 +38,12 @@ #include <cryptfs.h> #include <ext4_utils/wipe.h> #include <fs_mgr.h> +#include <fs_mgr_dm_linear.h> #include "otautil/mounts.h" static struct fstab* fstab = nullptr; +static bool did_map_logical_partitions = false; extern struct selabel_handle* sehandle; @@ -117,6 +119,25 @@ int ensure_path_mounted_at(const char* path, const char* mount_point) { mount_point = v->mount_point; } + // If we can't acquire the block device for a logical partition, it likely + // was never created. In that case we try to create it. + if (fs_mgr_is_logical(v) && !fs_mgr_update_logical_partition(v)) { + if (did_map_logical_partitions) { + LOG(ERROR) << "Failed to find block device for partition"; + return -1; + } + std::string super_name = fs_mgr_get_super_partition_name(); + if (!android::fs_mgr::CreateLogicalPartitions(super_name)) { + LOG(ERROR) << "Failed to create logical partitions"; + return -1; + } + did_map_logical_partitions = true; + if (!fs_mgr_update_logical_partition(v)) { + LOG(ERROR) << "Failed to find block device for partition"; + return -1; + } + } + const MountedVolume* mv = find_mounted_volume_by_mount_point(mount_point); if (mv != nullptr) { // Volume is already mounted. @@ -387,3 +408,7 @@ int setup_install_mounts() { } return 0; } + +bool logical_partitions_mapped() { + return did_map_logical_partitions; +} @@ -53,4 +53,6 @@ int format_volume(const char* volume, const char* directory); // mounted (/tmp and /cache) are mounted. Returns 0 on success. int setup_install_mounts(); +bool logical_partitions_mapped(); + #endif // RECOVERY_ROOTS_H_ |