Skip to content

Commit 32f281d

Browse files
committed
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
1 parent 231cfc4 commit 32f281d

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

init/block_dev_initializer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ bool BlockDevInitializer::InitDeviceMapper() {
4040
return InitMiscDevice("device-mapper");
4141
}
4242

43-
bool BlockDevInitializer::InitDmUser() {
44-
return InitMiscDevice("dm-user");
43+
bool BlockDevInitializer::InitDmUser(const std::string& name) {
44+
return InitMiscDevice("dm-user!" + name);
4545
}
4646

4747
bool BlockDevInitializer::InitMiscDevice(const std::string& name) {

init/block_dev_initializer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class BlockDevInitializer final {
2727
BlockDevInitializer();
2828

2929
bool InitDeviceMapper();
30-
bool InitDmUser();
30+
bool InitDmUser(const std::string& name);
3131
bool InitDevices(std::set<std::string> devices);
3232
bool InitDmDevice(const std::string& device);
3333

init/first_stage_mount.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,15 @@ bool FirstStageMount::CreateLogicalPartitions() {
343343
if (!InitRequiredDevices({"userdata"})) {
344344
return false;
345345
}
346+
sm->SetUeventRegenCallback([this](const std::string& device) -> bool {
347+
if (android::base::StartsWith(device, "/dev/block/dm-")) {
348+
return block_dev_init_.InitDmDevice(device);
349+
}
350+
if (android::base::StartsWith(device, "/dev/dm-user/")) {
351+
return block_dev_init_.InitDmUser(android::base::Basename(device));
352+
}
353+
return block_dev_init_.InitDevices({device});
354+
});
346355
return sm->CreateLogicalAndSnapshotPartitions(super_path_);
347356
}
348357
}

0 commit comments

Comments
 (0)