init: Pass a uevent regen callback to libsnapshot.

In first-stage init, libsnapshot needs to know how to wait for device
paths, since ueventd isn't running yet. We do this by passing a callback
wrapping BlockDevInitializer.

Bug: 173476209
Test: device boots into first-stage init after full VABC ota
Change-Id: I9a87f98824e65a9379cb0b99c001e28cccd9d205
This commit is contained in:
David Anderson 2020-11-21 13:43:47 -08:00
parent 231cfc4fe6
commit 32f281d77a
3 changed files with 12 additions and 3 deletions

View File

@ -40,8 +40,8 @@ bool BlockDevInitializer::InitDeviceMapper() {
return InitMiscDevice("device-mapper"); return InitMiscDevice("device-mapper");
} }
bool BlockDevInitializer::InitDmUser() { bool BlockDevInitializer::InitDmUser(const std::string& name) {
return InitMiscDevice("dm-user"); return InitMiscDevice("dm-user!" + name);
} }
bool BlockDevInitializer::InitMiscDevice(const std::string& name) { bool BlockDevInitializer::InitMiscDevice(const std::string& name) {

View File

@ -27,7 +27,7 @@ class BlockDevInitializer final {
BlockDevInitializer(); BlockDevInitializer();
bool InitDeviceMapper(); bool InitDeviceMapper();
bool InitDmUser(); bool InitDmUser(const std::string& name);
bool InitDevices(std::set<std::string> devices); bool InitDevices(std::set<std::string> devices);
bool InitDmDevice(const std::string& device); bool InitDmDevice(const std::string& device);

View File

@ -343,6 +343,15 @@ bool FirstStageMount::CreateLogicalPartitions() {
if (!InitRequiredDevices({"userdata"})) { if (!InitRequiredDevices({"userdata"})) {
return false; return false;
} }
sm->SetUeventRegenCallback([this](const std::string& device) -> bool {
if (android::base::StartsWith(device, "/dev/block/dm-")) {
return block_dev_init_.InitDmDevice(device);
}
if (android::base::StartsWith(device, "/dev/dm-user/")) {
return block_dev_init_.InitDmUser(android::base::Basename(device));
}
return block_dev_init_.InitDevices({device});
});
return sm->CreateLogicalAndSnapshotPartitions(super_path_); return sm->CreateLogicalAndSnapshotPartitions(super_path_);
} }
} }