fastbootd: Wait for /dev/block paths when opening logical partitions.
Note that in addition to waiting for the path to appear, we must also
wait for it to be unlinked. Otherwise, we could accidentally access an
older device when opening and closing the same partition twice in a row.
Bug: 114198005
Test: fastboot flashall works
Change-Id: Iddffc34e1ac8aa066c28e7b1a92b09b6dfd7945c
diff --git a/fastboot/device/utility.cpp b/fastboot/device/utility.cpp
index d78c809..261a202 100644
--- a/fastboot/device/utility.cpp
+++ b/fastboot/device/utility.cpp
@@ -28,6 +28,7 @@
#include "fastboot_device.h"
using namespace android::fs_mgr;
+using namespace std::chrono_literals;
using android::base::unique_fd;
using android::hardware::boot::V1_0::Slot;
@@ -48,11 +49,11 @@
}
uint32_t slot_number = SlotNumberForSlotSuffix(slot);
std::string dm_path;
- if (!CreateLogicalPartition(path->c_str(), slot_number, name, true, &dm_path)) {
+ if (!CreateLogicalPartition(path->c_str(), slot_number, name, true, 5s, &dm_path)) {
LOG(ERROR) << "Could not map partition: " << name;
return false;
}
- auto closer = [name]() -> void { DestroyLogicalPartition(name); };
+ auto closer = [name]() -> void { DestroyLogicalPartition(name, 5s); };
*handle = PartitionHandle(dm_path, std::move(closer));
return true;
}