diff options
Diffstat (limited to 'toys')
-rw-r--r-- | toys/cp.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -69,8 +69,9 @@ void cp_file(char *src, char *dst, struct stat *srcst) // we created. The closest we can do to closing this is make sure // that what we open _is_ a directory rather than something else. - if (mkdir(dst, srcst->st_mode | 0200) || 0>(fdout=open(dst, 0)) - || fstat(fdout, &st2) || !S_ISDIR(st2.st_mode)) + if ((mkdir(dst, srcst->st_mode | 0200) && errno != EEXIST) + || 0>(fdout=open(dst, 0)) || fstat(fdout, &st2) + || !S_ISDIR(st2.st_mode)) { perror_exit("mkdir '%s'", dst); } |