Refine the first stage mount for DSU
* Open the ImageManager according to the saved DSU slot. * Load the saved install_dir when it presents. This is required when installing to an external storage and the current code seems to break it. * Remove an unnecessary C++ using. Test: gsi_tool install Bug: 144247097 Change-Id: I5b7be25787f235518a25abacefa612c33861f6ef
This commit is contained in:
parent
3bf8858105
commit
a841bd48f8
|
@ -26,6 +26,7 @@
|
|||
#include <fs_mgr_dm_linear.h>
|
||||
#include <libdm/loop_control.h>
|
||||
#include <libfiemap/split_fiemap_writer.h>
|
||||
#include <libgsi/libgsi.h>
|
||||
|
||||
#include "metadata.h"
|
||||
#include "utility.h"
|
||||
|
@ -34,6 +35,7 @@ namespace android {
|
|||
namespace fiemap {
|
||||
|
||||
using namespace std::literals;
|
||||
using android::base::ReadFileToString;
|
||||
using android::base::unique_fd;
|
||||
using android::dm::DeviceMapper;
|
||||
using android::dm::DmDeviceState;
|
||||
|
@ -53,6 +55,11 @@ static constexpr char kTestImageMetadataDir[] = "/metadata/gsi/test";
|
|||
std::unique_ptr<ImageManager> ImageManager::Open(const std::string& dir_prefix) {
|
||||
auto metadata_dir = "/metadata/gsi/" + dir_prefix;
|
||||
auto data_dir = "/data/gsi/" + dir_prefix;
|
||||
auto install_dir_file = gsi::DsuInstallDirFile(gsi::GetDsuSlot(dir_prefix));
|
||||
std::string path;
|
||||
if (ReadFileToString(install_dir_file, &path)) {
|
||||
data_dir = path;
|
||||
}
|
||||
return Open(metadata_dir, data_dir);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,6 @@ using android::fs_mgr::ReadDefaultFstab;
|
|||
using android::fs_mgr::ReadFstabFromDt;
|
||||
using android::fs_mgr::SkipMountingPartitions;
|
||||
using android::fs_mgr::TransformFstabForDsu;
|
||||
using android::init::WriteFile;
|
||||
using android::snapshot::SnapshotManager;
|
||||
|
||||
using namespace std::literals;
|
||||
|
@ -612,7 +611,13 @@ void FirstStageMount::UseDsuIfPresent() {
|
|||
}
|
||||
return InitRequiredDevices(std::move(devices));
|
||||
};
|
||||
auto images = IImageManager::Open("dsu", 0ms);
|
||||
std::string active_dsu;
|
||||
if (!gsi::GetActiveDsu(&active_dsu)) {
|
||||
LOG(ERROR) << "Failed to GetActiveDsu";
|
||||
return;
|
||||
}
|
||||
LOG(INFO) << "DSU slot: " << active_dsu;
|
||||
auto images = IImageManager::Open("dsu/" + active_dsu, 0ms);
|
||||
if (!images || !images->MapAllImages(init_devices)) {
|
||||
LOG(ERROR) << "DSU partition layout could not be instantiated";
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue