From 6d285cec244a15350fe3761c212300a1f6c63ac6 Mon Sep 17 00:00:00 2001 From: Sudheer Shanka Date: Tue, 19 Feb 2019 14:12:20 -0800 Subject: [PATCH] Ignore EEXIST errors when creating pkg specific dirs. Some of the pkg specific dirs could be created by zygote and vold in parallel, so ignore any EEXIST errors while creating these dirs. Bug: 118185801 Test: manual Change-Id: Ifaa9998131764304867ac027af335414dbfc291c --- Utils.cpp | 2 +- VolumeManager.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Utils.cpp b/Utils.cpp index aa2288b..0a16fc1 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -235,7 +235,7 @@ status_t CreateDir(const std::string& dir, mode_t mode) { PLOG(ERROR) << "Failed to stat " << dir; return -errno; } - if (TEMP_FAILURE_RETRY(mkdir(dir.c_str(), mode)) == -1) { + if (TEMP_FAILURE_RETRY(mkdir(dir.c_str(), mode)) == -1 && errno != EEXIST) { PLOG(ERROR) << "Failed to mkdir " << dir; return -errno; } diff --git a/VolumeManager.cpp b/VolumeManager.cpp index 7b08858..c56380a 100644 --- a/VolumeManager.cpp +++ b/VolumeManager.cpp @@ -680,7 +680,7 @@ int VolumeManager::prepareSandboxTargets(userid_t userId, } else if (errno != ENOENT) { PLOG(ERROR) << "Failed to faccessat " << mntTargetRoot << "/" << package; } - if (TEMP_FAILURE_RETRY(mkdirat(dfd.get(), package.c_str(), 0755)) == -1) { + if (TEMP_FAILURE_RETRY(mkdirat(dfd.get(), package.c_str(), 0755)) == -1 && errno != EEXIST) { PLOG(ERROR) << "Failed to mkdirat " << mntTargetRoot << "/" << package; return -errno; } @@ -718,7 +718,8 @@ int VolumeManager::prepareSandboxTargets(userid_t userId, } else if (errno != ENOENT) { PLOG(ERROR) << "Failed to faccessat " << pkgMountTarget << "/" << volumeLabel; } - if (TEMP_FAILURE_RETRY(mkdirat(packageFd.get(), volumeLabel.c_str(), 0755)) == -1) { + if (TEMP_FAILURE_RETRY(mkdirat(packageFd.get(), volumeLabel.c_str(), 0755)) == -1 && + errno != EEXIST) { PLOG(ERROR) << "Failed to mkdirat " << pkgMountTarget << "/" << volumeLabel; return -errno; } @@ -742,7 +743,8 @@ int VolumeManager::prepareSandboxTargets(userid_t userId, } if (TEMP_FAILURE_RETRY(faccessat(packageFd.get(), "self", F_OK, 0)) == -1) { if (errno == ENOENT) { - if (TEMP_FAILURE_RETRY(mkdirat(packageFd.get(), "self", 0755)) == -1) { + if (TEMP_FAILURE_RETRY(mkdirat(packageFd.get(), "self", 0755)) == -1 && + errno != EEXIST) { PLOG(ERROR) << "Failed to mkdirat " << pkgMountTarget << "/self"; return -errno; }