diff --git a/fs_mgr/libdm/dm.cpp b/fs_mgr/libdm/dm.cpp index 254fbed24..673e145f1 100644 --- a/fs_mgr/libdm/dm.cpp +++ b/fs_mgr/libdm/dm.cpp @@ -120,7 +120,7 @@ bool DeviceMapper::DeleteDevice(const std::string& name, return false; } if (!WaitForFileDeleted(unique_path, timeout_ms)) { - LOG(ERROR) << "Timeout out waiting for " << unique_path << " to be deleted"; + LOG(ERROR) << "Failed waiting for " << unique_path << " to be deleted"; return false; } return true; @@ -161,7 +161,7 @@ bool DeviceMapper::CreateDevice(const std::string& name, const DmTable& table, s return true; } if (!WaitForFile(unique_path, timeout_ms)) { - LOG(ERROR) << "Timed out waiting for device path: " << unique_path; + LOG(ERROR) << "Failed waiting for device path: " << unique_path; DeleteDevice(name); return false; } diff --git a/fs_mgr/libdm/utility.cpp b/fs_mgr/libdm/utility.cpp index f252565fd..0eb59ab49 100644 --- a/fs_mgr/libdm/utility.cpp +++ b/fs_mgr/libdm/utility.cpp @@ -19,6 +19,8 @@ #include +#include + using namespace std::literals; namespace android { @@ -45,7 +47,11 @@ bool WaitForFile(const std::string& path, const std::chrono::milliseconds& timeo // If the file exists but returns EPERM or something, we consider the // condition met. if (access(path.c_str(), F_OK) != 0) { - if (errno == ENOENT) return WaitResult::Wait; + if (errno == ENOENT) { + return WaitResult::Wait; + } + PLOG(ERROR) << "access failed: " << path; + return WaitResult::Fail; } return WaitResult::Done; }; @@ -54,9 +60,13 @@ bool WaitForFile(const std::string& path, const std::chrono::milliseconds& timeo bool WaitForFileDeleted(const std::string& path, const std::chrono::milliseconds& timeout_ms) { auto condition = [&]() -> WaitResult { - if (access(path.c_str(), F_OK) == 0 || errno != ENOENT) { + if (access(path.c_str(), F_OK) == 0) { return WaitResult::Wait; } + if (errno != ENOENT) { + PLOG(ERROR) << "access failed: " << path; + return WaitResult::Fail; + } return WaitResult::Done; }; return WaitForCondition(condition, timeout_ms);