Merge "Block and wait for /dev/block/loop<N> to appear in case it was created asynchronously."

am: ee5eb39169

Change-Id: Ib82969daab218360712f1b3bf2c2069c95932ee2
gugelfrei
David Anderson 5 years ago committed by android-build-merger
commit 5973b8cf00

@ -31,16 +31,20 @@
#include <linux/kdev_t.h>
#include <chrono>
#include <android-base/logging.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
#include <fs_mgr/file_wait.h>
#include <utils/Trace.h>
#include "Loop.h"
#include "VoldUtil.h"
#include "sehandle.h"
using namespace std::literals;
using android::base::StringPrintf;
using android::base::unique_fd;
@ -74,6 +78,10 @@ int Loop::create(const std::string& target, std::string& out_device) {
PLOG(ERROR) << "Failed to open " << target;
return -errno;
}
if (!android::fs_mgr::WaitForFile(out_device, 2s)) {
LOG(ERROR) << "Failed to find " << out_device;
return -ENOENT;
}
unique_fd device_fd(open(out_device.c_str(), O_RDWR | O_CLOEXEC));
if (device_fd.get() == -1) {
PLOG(ERROR) << "Failed to open " << out_device;

Loading…
Cancel
Save