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
diff --git a/Utils.cpp b/Utils.cpp
index aa2288b..0a16fc1 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -235,7 +235,7 @@
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 @@
} 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 @@
} 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 @@
}
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;
}