Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm 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 Date: Thu, 23 Jun 2005 14:38:11 -0400 From: Christopher Faylor To: cygwin AT cygwin DOT com Subject: Re: Coreutils (mv) bug Message-ID: <20050623183811.GA10244@trixie.casa.cgf.cx> Reply-To: cygwin AT cygwin DOT com References: <062320051811 DOT 2494 DOT 42BAFB5E000D6ED7000009BE22007510900A050E040D0C079D0A AT comcast DOT net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <062320051811.2494.42BAFB5E000D6ED7000009BE22007510900A050E040D0C079D0A@comcast.net> User-Agent: Mutt/1.5.8i On Thu, Jun 23, 2005 at 06:11:42PM +0000, Eric Blake wrote: >> $ ln -s /bin/sh foo >> $ mv foo bar >> mv: cannot stat `foo.exe': No such file or directory > >I'm not sure if this was the issue that appeared on the list last month, but >it is one of the issues I was already aware of and trying to fix for >coreutils-5.3.0-7. > >The underlying problem is that there is currently NO EFFICIENT WAY in >cygwin to determine if .exe magic is taking place. Most of the coreutils >cygwin patches use access() to see if the short name resolves, then open() >to see if the short name was the correct spelling. Unfortunately, with your >symlink, access(foo) succeeds (so I know there is either a foo or foo.exe), >but the open fails (since your symlink points to plain /bin/sh, rather than >the truly existing /bin/sh.exe, it is technically dangling since open doesn't >perform .exe magic), and the failure is ENOENT. I interpreted ENOENT as >meaning foo doesn't exist, so the access must have succeeded on foo.exe, >which is where I went wrong. (Cygwin is a bit inconsistent here - the >exec() family on this half-dangling symlink recognizes that /bin/sh doesn't >exist, so it exec's /bin/sh.exe instead rather than erroring out with >ENOENT). So there is a problem with the access/open check alone in >deciding if the spelling was correct; perhaps I can solve it by throwing in >a readlink (but as was just pointed out this week, readlink currently fails if >the link points to . or ..). > >It would be really nice if there were a new flag to access() that supressed >.exe expansion, and succeeded only if the exact spelling matched. Then >my test to see if .exe should be appended would be as simple as >access("foo", F_OK) == 0 && access("foo", F_OK | __NO_EXE_MAGIC) == -1. >Furthermore, access() seems like it may be more efficient than open() in >terms of the underlying work that must be done to implement it. Just append a dot to the end of the filename. cgf -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/