delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/06/23/14:38:21

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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 <cgf-no-personal-reply-please AT cygwin DOT com>
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
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019