delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/08/10/11:24:46

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-498158.1 required=5.0 tests=AWL,BAYES_00
X-Spam-Check-By: sourceware.org
X-MDAV-Processed: mail1.multiplay.co.uk, Mon, 10 Aug 2009 16:24:28 +0100
X-Spam-Processed: mail1.multiplay.co.uk, Mon, 10 Aug 2009 16:24:27 +0100 (not processed: message from trusted or authenticated source)
X-MDRemoteIP: 85.236.127.235
X-Return-Path: prvs=147312a164=killing AT multiplay DOT co DOT uk
X-Envelope-From: killing AT multiplay DOT co DOT uk
X-MDaemon-Deliver-To: cygwin AT cygwin DOT com
Message-ID: <77114E9D8D2443489640638F57F712B9@multiplay.co.uk>
From: "Steven Hartland" <killing AT multiplay DOT co DOT uk>
To: <cygwin AT cygwin DOT com>
References: <88A93D0EBE3347F781BD7E3C6774C53F AT multiplay DOT co DOT uk> <20090810131136 DOT GO3204 AT calimero DOT vinschen DOT de>
Subject: Re: tar deletes .exe files on extraction
Date: Mon, 10 Aug 2009 16:24:25 +0100
MIME-Version: 1.0
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
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

----- Original Message ----- 
From: "Corinna Vinschen"
> On Aug  8 03:16, Steven Hartland wrote:
>> If you extract a tar.gz file with an executable file and
>> an excitable file of the same name but with the .exe extension
>> on extract the .exe file is inexplicably deleted.
>>
>> e.g.
>> tar -xvzf test.tar.gz
>> mydir/myexe.exe
>> mydir/myexe
>>
>> ls myddir
>> myexe
> 
> Yeah, that's to be expected.
> 
> Cygwin always handled the .exe suffix transparently in terms of stat(2)
> calls, but Cygwin 1.7 also handles them transparently in terms of
> open(2) and any other call.  Therefore, if a file foo.exe exists, and an
> application calls stat("foo"), it will get told that, yes, "foo" exists.
> That's a basic component of being able to call foo.exe from bash by just
> typing foo<enter>.  POSIX systems just don't have the .exe suffix for
> executables.
> 
> AFAICS from the strace, tar unpacks mydir/myexe.exe, then it goes ahead
> to unpack mydir/myexe.  It tries to open the file with O_CREAT | O_EXCL
> flags.  Since the file exists from Cygwin's POV, open(2) returns -1 with
> errno set to EEXIST.  If that happens tar calls unlink("mydir/myexe")
> and the unlink() call succeeds, since, as mentioned above, the .exe
> suffix is transparent to every filesystem call.  Therefore,
> unlink("mydir/myexe") actually deletes "mydir/myexe.exe".  Then tar
> proceeds to unpack "mydir/myexe".
> 
> Keep in mind that myexe and myexe.exe are for all practical purposes the
> same file from Cygwin's point of view.  On a POSIX system you just don't
> have a "normal" file called myexe in the same directory as an executable
> "myexe", since that is the same file anyway, and the .exe suffix is just
> an annoying Windowism.  On Cygwin, you should avoid having a file "foo"
> and a file "foo.exe" in the same directory at all cost to avoid
> puzzeling POSIX borderline behaviour like this.  What you do is
> essentially in the "not supported" class of problems.
> 
> Fortunately for you there's a workaround.  If the order of the files in
> the tar archive is reversed, both files are unpacked.  Or, unpack
> mydir/myexe.exe explicitely afterwards.  The reason that this works is
> that Cygwin does not check for a file "foo", if the name of the file is
> explicitely given as "foo.exe".

Thanks for the confirmation there Corinna however I do think this is quite
an issue and it likely catch people out.

In this example the result was nothing worked as the myexe is a none native
binary only myexe.exe is a windows exe, but I wouldnt be surprised if there
are cases where you have and exe and a data file with the name the same
just the app with the .exe with the extension.

It might be a silly idea but would it potentially be an option to alter
this behaviour based on an cygwin environment variable, so that the past
behaviour is restored for wider compatibility.

    Regards
    Steve


--
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

- Raw text -


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