Merge "recovery: Fix mounting /system with dynamic partitions." am: 023807fcf7

am: e3f6814451

Change-Id: I90b1fba26ecfb0a6405a0e80291ce7a7b05d1ad5
This commit is contained in:
David Anderson 2018-10-31 14:31:59 -07:00 committed by android-build-merger
commit fd23585aa5
3 changed files with 34 additions and 2 deletions

View file

@ -478,8 +478,13 @@ int main(int argc, char** argv) {
break; break;
case Device::ENTER_FASTBOOT: case Device::ENTER_FASTBOOT:
LOG(INFO) << "Entering fastboot"; if (logical_partitions_mapped()) {
fastboot = true; 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; break;
case Device::ENTER_RECOVERY: case Device::ENTER_RECOVERY:

View file

@ -38,10 +38,12 @@
#include <cryptfs.h> #include <cryptfs.h>
#include <ext4_utils/wipe.h> #include <ext4_utils/wipe.h>
#include <fs_mgr.h> #include <fs_mgr.h>
#include <fs_mgr_dm_linear.h>
#include "otautil/mounts.h" #include "otautil/mounts.h"
static struct fstab* fstab = nullptr; static struct fstab* fstab = nullptr;
static bool did_map_logical_partitions = false;
extern struct selabel_handle* sehandle; 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; 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); const MountedVolume* mv = find_mounted_volume_by_mount_point(mount_point);
if (mv != nullptr) { if (mv != nullptr) {
// Volume is already mounted. // Volume is already mounted.
@ -387,3 +408,7 @@ int setup_install_mounts() {
} }
return 0; return 0;
} }
bool logical_partitions_mapped() {
return did_map_logical_partitions;
}

View file

@ -53,4 +53,6 @@ int format_volume(const char* volume, const char* directory);
// mounted (/tmp and /cache) are mounted. Returns 0 on success. // mounted (/tmp and /cache) are mounted. Returns 0 on success.
int setup_install_mounts(); int setup_install_mounts();
bool logical_partitions_mapped();
#endif // RECOVERY_ROOTS_H_ #endif // RECOVERY_ROOTS_H_