@@ -212,9 +212,7 @@ static bool createDirAt(int dir_fd, const char* path, mode_t mode) {
212212 cumulative += component;
213213
214214 if (mkdirat (dir_fd, cumulative.c_str (), mode) == -1 && errno != EEXIST ) {
215- struct stat st;
216- if (errno != EROFS || fstatat (dir_fd, cumulative.c_str (), &st, 0 ) != 0 ||
217- !S_ISDIR (st.st_mode )) {
215+ if (errno != EROFS || !util::existsAsDirAt (dir_fd, cumulative.c_str ())) {
218216 PLOG_W (" mkdirat(%d, '%s')" , dir_fd, cumulative.c_str ());
219217 return false ;
220218 }
@@ -433,14 +431,16 @@ static bool mountSinglePointAt(mount_t* mpt, int root_fd) {
433431
434432 if (mpt->is_dir ) {
435433 if (strcmp (rel_dst, " ." ) != 0 && mkdirat (root_fd, rel_dst, 0711 ) == -1 &&
436- errno != EEXIST && errno != EROFS ) {
437- PLOG_W (" mkdirat(root_fd, '%s')" , rel_dst);
434+ errno != EEXIST ) {
435+ if (errno != EROFS || !util::existsAsDirAt (root_fd, rel_dst)) {
436+ PLOG_W (" mkdirat(root_fd, '%s')" , rel_dst);
437+ }
438438 }
439439 } else {
440440 int fd = openat (root_fd, rel_dst, O_CREAT | O_RDONLY | O_CLOEXEC , 0644 );
441441 if (fd >= 0 ) {
442442 close (fd);
443- } else if (errno != EROFS ) {
443+ } else if (errno != EROFS || ! util::existsAsRegAt (root_fd, rel_dst) ) {
444444 PLOG_W (" openat(root_fd, '%s', O_CREAT)" , rel_dst);
445445 }
446446 }
0 commit comments