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/