From ea5fca4cd06006e99695c8372be0a58302314651 Mon Sep 17 00:00:00 2001 From: Bowgo Tsai Date: Tue, 2 May 2017 18:30:33 +0800 Subject: [PATCH] init: fix first stage mount failure due to /dev/device-mapper not found It has been reported that fs_mgr failed to open /dev/device-mapper during the first stage mount. It's because other uevent (e.g., i2c charger device) happens to be sent at the same time we're triggering the device-mapper uevent to be sent. Current implementation returns COLDBOOT_STOP unconditionally so it will only process the first received uevent, leaving device-mapper uevent unhandled when the race happens. Fix this by only returning COLDBOOT_STOP when the received uevent->path matches that of device mapper. Bug: 37745254 Test: first stage mount /vendor with vboot 2.0 (avb) on bullhead Test: first stage mount /vendor with vboot 1.0 on sailfish Change-Id: I4a77093ec8f90a5ca981a088f34d082d0270533b --- init/init_first_stage.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/init/init_first_stage.cpp b/init/init_first_stage.cpp index 43f1c1504..2fa790d40 100644 --- a/init/init_first_stage.cpp +++ b/init/init_first_stage.cpp @@ -143,8 +143,11 @@ bool FirstStageMount::InitDevices() { if (!GetRequiredDevices(&devices_partition_names, &need_dm_verity)) return false; if (need_dm_verity) { - device_init("/sys/devices/virtual/misc/device-mapper", - [&](uevent* uevent) -> coldboot_action_t { return COLDBOOT_STOP; }); + const std::string dm_path = "/devices/virtual/misc/device-mapper"; + device_init(("/sys" + dm_path).c_str(), [&dm_path](uevent* uevent) -> coldboot_action_t { + if (uevent->path == dm_path) return COLDBOOT_STOP; + return COLDBOOT_CONTINUE; // dm_path not found, continue to find it. + }); } bool success = false;