Populate the dm table of the early userdata device.
DM_DEV_CREATE no longer creates sysfs nodes as of Linux kernel 5.15. It
is now necessary to DM_TABLE_LOAD as well.
Bug: 259328366
Test: userdata mounts
Change-Id: I0f88afdf95a97d44eb365e4302bbfdc7c28c0bcb
diff --git a/MetadataCrypt.cpp b/MetadataCrypt.cpp
index 4152e25..df24901 100644
--- a/MetadataCrypt.cpp
+++ b/MetadataCrypt.cpp
@@ -89,9 +89,18 @@
LOG(INFO) << "Not pre-creating userdata encryption device; device already exists";
return;
}
+
+ // On newer Linux kernels (5.15+), there is no uevent until DM_TABLE_LOAD,
+ // so we make sure the device is fully ready.
if (!dm.CreateEmptyDevice(kDmNameUserdata)) {
LOG(ERROR) << "Failed to pre-create userdata metadata encryption device";
}
+
+ DmTable table;
+ table.Emplace<DmTargetError>(0, 1);
+ if (!dm.LoadTable(kDmNameUserdata, table)) {
+ LOG(ERROR) << "Failed to pre-create userdata metadata encryption device";
+ }
}
static bool mount_via_fs_mgr(const char* mount_point, const char* blk_device) {