delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2018/10/09/12:22:17

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:references:in-reply-to:from:date
:message-id:subject:to:content-type; q=dns; s=default; b=P97EkV8
bhZNJXwLsuLuutyRQE0j/J7YIfRQ2TOZyLz26VH+d+AFqTzUDe/BGEMNG64IsDs2
6oPLC3tGp+PbJEAFhBiKZTTXSTpwH3lBj9kO4fSYt9zXccpAsjjVFBVsoBXpK85p
HZhAiyAxy2VEKLCHNguFRxiAUMtuEnReK45Q=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:references:in-reply-to:from:date
:message-id:subject:to:content-type; s=default; bh=QjZVmQABqVcWj
fTQH/gqpQ4jJ68=; b=y05XgmQ3LyLyqVbZB7kXRgzRglPMFHipUsBJ3CG5UObd+
YD6NljLcIbFza+0Y+yMetmk3SnXjzqWEB1weN03Uqsnpv7H5bzR7QOojpSBLeIPi
icNnmY6P4MWCET8BEX6uR5FyjyLckfOc9iwX4/oIm4FFXUP6On7yNI19nBvDXo=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-10.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:sk:w14-v6s, fruit, o_binary, O_BINARY
X-HELO: mail-pl1-f193.google.com
MIME-Version: 1.0
References: <CAPF-yObTngOGu_+TSfSQo4bpi_tJ3572r_26cfidLZ5QpcPGYQ AT mail DOT gmail DOT com> <f00936b7-cc2a-1a2c-7862-c79e10bed95d AT gmail DOT com> <02c12d6e-cc18-89af-db83-1813cc8f0c97 AT redhat DOT com>
In-Reply-To: <02c12d6e-cc18-89af-db83-1813cc8f0c97@redhat.com>
From: Dan Kegel <dank AT kegel DOT com>
Date: Tue, 9 Oct 2018 09:21:51 -0700
Message-ID: <CAPF-yObUNPRE_xrnroc_rZHqPHGUGmzMKZXnT5ZrpLm2YCzW-g@mail.gmail.com>
Subject: Re: Fun with cp -R error when both foo and foo.exe exist
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes

On Tue, Oct 9, 2018 at 5:03 AM Eric Blake <eblake AT redhat DOT com> wrote:
> whether someone patches the cygwin dll or cp, it seems like some rather
> hairy code for what is normally a rare corner case, so it probably won't
> happen unless someone actually contributes a patch.

Right.  Here's a completely untested guess patch:

--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -1363,7 +1363,15 @@ open (const char *unix_path, int flags, ...)
          opt |= PC_CTTY;
        }

-      if (!(fh = build_fh_name (unix_path, opt, stat_suffixes)))
+      suffix_info *suffices = stat_suffixes;
+      if ((opt & (O_WRONLY|O_BINARY)) == (O_WRONLY|O_BINARY))
+        {
+         /* Hack so 'cp foo bar' doesn't abort with
+             'cp: cannot create regular file bar: File exists'
+            if bar.exe already exists  */
+       suffices = NULL;
+       }
+      if (!(fh = build_fh_name (unix_path, opt, suffices)))
        __leave;                /* errno already set */
       if ((flags & O_NOFOLLOW) && fh->issymlink ())
        {

Feel free to throw rotten fruit :-)

- Dan

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019