Revert^2 "init: Look for super partition only on a boot device"
This reverts commit 8d71220df28851a7dce351f86601958fdbc3e5ae.
Reason for revert: Fix for gcar emulator (basically all QEMU-based emulators) landed at aosp/3315253 and aosp/3160116.
Change-Id: If4eddd3f7e224c31019ad3bd752e2375c7567780
diff --git a/init/devices.cpp b/init/devices.cpp
index f2bb9d2..6a3a64d 100644
--- a/init/devices.cpp
+++ b/init/devices.cpp
@@ -188,6 +188,28 @@
}
}
+bool DeviceHandler::IsBootDevice(const Uevent& uevent) const {
+ std::string device;
+
+ if (FindPlatformDevice(uevent.path, &device)) {
+ // Skip /devices/platform or /devices/ if present
+ static constexpr std::string_view devices_platform_prefix = "/devices/platform/";
+ static constexpr std::string_view devices_prefix = "/devices/";
+
+ if (StartsWith(device, devices_platform_prefix)) {
+ device = device.substr(devices_platform_prefix.length());
+ } else if (StartsWith(device, devices_prefix)) {
+ device = device.substr(devices_prefix.length());
+ }
+ } else if (FindPciDevicePrefix(uevent.path, &device)) {
+ } else if (FindVbdDevicePrefix(uevent.path, &device)) {
+ } else {
+ return false;
+ }
+
+ return boot_devices_.find(device) != boot_devices_.end();
+}
+
std::string DeviceHandler::GetPartitionNameForDevice(const std::string& query_device) {
static const auto partition_map = [] {
std::vector<std::pair<std::string, std::string>> partition_map;