From: Dan Kegel <dank@kegel.com>
To: cygwin@cygwin.com
Subject: Re: Fun with cp -R error when both foo and foo.exe exist
Date: Tue, 09 Oct 2018 16:22:00 -0000 [thread overview]
Message-ID: <CAPF-yObUNPRE_xrnroc_rZHqPHGUGmzMKZXnT5ZrpLm2YCzW-g@mail.gmail.com> (raw)
In-Reply-To: <02c12d6e-cc18-89af-db83-1813cc8f0c97@redhat.com>
On Tue, Oct 9, 2018 at 5:03 AM Eric Blake <eblake@redhat.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
next prev parent reply other threads:[~2018-10-09 16:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-08 21:25 Dan Kegel
2018-10-09 6:22 ` Marco Atzeri
2018-10-09 12:03 ` Eric Blake
2018-10-09 16:22 ` Dan Kegel [this message]
2018-10-09 16:52 ` Eric Blake
2018-10-09 17:19 ` Dan Kegel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPF-yObUNPRE_xrnroc_rZHqPHGUGmzMKZXnT5ZrpLm2YCzW-g@mail.gmail.com \
--to=dank@kegel.com \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).