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:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=pGeN3kRLTwNYT12z iXdOSEhRSZwMJKP28KiJGCX7cJCpB47Swm6Sy7q/vPdSW75NWsxOLJi0IicRUoKt rUFsFHieaGXvOtgn/N6jF30GVOUKSoyGIShKzDs4I+3+aVXWaN1XmDHCjRkmyFcN +rhQzuGeU7+qS2M9SVprBJtOhCA= 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:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=vFPeDAVqGtEghx+Xw7h5En plTDE=; b=AM7qaV7c6qC2gw2RW3wHMFRUWvkykx95Ka0NbP7Sxl12s0gunlDPcZ dlsnb5sSfwGM85bczHySUWM2yok+PZryFUmf72vjn8KbrbvWdMbCnQVAzu3IawpS 9SRwon1evaJ9wyIsOv6rPWVCgsBnvCAwqlpZF3c9lHr6GWynSJwhQ= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , 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=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Subject: Re: Fun with cp -R error when both foo and foo.exe exist To: cygwin AT cygwin DOT com References: <02c12d6e-cc18-89af-db83-1813cc8f0c97 AT redhat DOT com> From: Eric Blake Message-ID: Date: Tue, 9 Oct 2018 11:52:52 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes On 10/9/18 11:21 AM, Dan Kegel wrote: > 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; suffices is a completely different word; did you mean suffixes? > + if ((opt & (O_WRONLY|O_BINARY)) == (O_WRONLY|O_BINARY)) O_WRONLY need not be a bitmask; it's better to use O_ACCMODE for the bitmask, as in opt & (O_ACCMODE|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))) So, with mistakes corrected, your hack is that cygwin doing auto-suffix probing should be suppressed in the case of opening a file O_WRONLY? Why does O_BINARY have to fit in the equation? > __leave; /* errno already set */ > if ((flags & O_NOFOLLOW) && fh->issymlink ()) > { > > Feel free to throw rotten fruit :-) > -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org -- 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