From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 101243 invoked by alias); 9 Oct 2018 16:22:06 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 100811 invoked by uid 89); 9 Oct 2018 16:22:05 -0000 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 Received: from mail-pl1-f193.google.com (HELO mail-pl1-f193.google.com) (209.85.214.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 09 Oct 2018 16:22:04 +0000 Received: by mail-pl1-f193.google.com with SMTP id w14-v6so1078682plp.6 for ; Tue, 09 Oct 2018 09:22:04 -0700 (PDT) MIME-Version: 1.0 References: <02c12d6e-cc18-89af-db83-1813cc8f0c97@redhat.com> In-Reply-To: <02c12d6e-cc18-89af-db83-1813cc8f0c97@redhat.com> From: Dan Kegel Date: Tue, 09 Oct 2018 16:22:00 -0000 Message-ID: Subject: Re: Fun with cp -R error when both foo and foo.exe exist To: cygwin@cygwin.com Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-10/txt/msg00078.txt.bz2 On Tue, Oct 9, 2018 at 5:03 AM Eric Blake 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