diff toys/cp.c @ 272:a5652aa22f38

Another cp -r fix, another test case...
author Rob Landley <rob@landley.net>
date Wed, 26 Mar 2008 00:54:56 -0500
parents 7d625cbdde25
children a08f1affe016
line wrap: on
line diff
--- a/toys/cp.c	Tue Mar 25 17:09:40 2008 -0500
+++ b/toys/cp.c	Wed Mar 26 00:54:56 2008 -0500
@@ -69,8 +69,9 @@
 		// 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);
 		}