Permalink
Browse files

Allow mkdir() race to succeed.

When two zygotes are starting, they both may try creating a mount
point after checking lstat().  The second mkdir() will result in
EEXIST, which is okay to ignore.

Bug: 7165469
Change-Id: If4411e2621f773c74cd05247899982fa5ebdd020
  • Loading branch information...
jsharkey committed Sep 25, 2012
1 parent 0b76d02 commit 489609bb44fe8834c76c772f2cff8f03dbb84e08
Showing with 4 additions and 2 deletions.
  1. +4 −2 libcutils/fs.c
View
@@ -55,8 +55,10 @@ int fs_prepare_dir(const char* path, mode_t mode, uid_t uid, gid_t gid) {
create:
if (TEMP_FAILURE_RETRY(mkdir(path, mode)) == -1) {
- ALOGE("Failed to mkdir(%s): %s", path, strerror(errno));
- return -1;
+ if (errno != EEXIST) {
+ ALOGE("Failed to mkdir(%s): %s", path, strerror(errno));
+ return -1;
+ }
}
fixup:

0 comments on commit 489609b

Please sign in to comment.