A recursive copy will fail if another process creates one of the
destination directories between the stat(2) call and the the mkdir(2)
call.  The relevant code is in copy.c, copy_internal():

     if (new_dst || !S_ISDIR (dst_sb.st_mode))
       {
         /* Create the new directory writable and searchable, so
            we can create new entries in it.  */

         if (mkdir (dst_name, (src_mode & x->umask_kill) | S_IRWXU) != 0)
           {
             error (0, errno, _("cannot create directory %s"),
                    quote (dst_name));
             goto un_backup;
           }

While this implemention appears to follow the letter of the POSIX
specification, it does not seem to follow the intent and at any rate
causes problems for the end user.

I believe that the correct behavior on EEXIST is to start the function over.


_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to