From 50c8c023358645195585f1503bfb97e2fb92c940 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 26 Mar 2008 00:54:56 -0500 Subject: Another cp -r fix, another test case... --- toys/cp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'toys') diff --git a/toys/cp.c b/toys/cp.c index 13cb9672..d589f0ab 100644 --- a/toys/cp.c +++ b/toys/cp.c @@ -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); } -- cgit v1.2.3