delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2015/04/23/09:26:01

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:content-type:mime-version
:content-transfer-encoding:message-id:date:subject:from
:in-reply-to:references:to; q=dns; s=default; b=EDGk8bA/sA16V0z4
xqP+mURL+KZgYfPZiFT6xTbe5tQdIaCd68oIcQpIHlG2IE/Pcg2lxbOK+UcZTA2N
VihjGpwFv8keVKuq8yQ5iC+U+M1RmfTOmQwKg7CAUcMzLz2z9QZlFsWoaOxZYQ1F
3hibZGgPtcSBsWJGePqImHxmjPo=
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:content-type:mime-version
:content-transfer-encoding:message-id:date:subject:from
:in-reply-to:references:to; s=default; bh=ahkIdIZq8mQp7f5yEONisI
gLG+E=; b=v+oqLmwTaRdwKT9ygYnuzW1c+bCcEaNaanlCDc6xa/VhrR70VqUVsp
ZsRli94j3W9niI4tlYUqO+HXMd+WW1gq4sI1a9LDBUMS5w0qnZrzMJ+lze0Z4YdP
I0mNUbnY2/ZNM55Me4f1gPMrPd5+zUcP4eQ5p/x+uE2ERtmwG36/A=
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
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=0.8 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2
X-HELO: smtp74.ord1c.emailsrvr.com
X-Sender-Id: nick AT executivecentersuites DOT com
MIME-Version: 1.0
Message-ID: <20150423132552.5992594.25542.336@executivecentersuites.com>
Date: Thu, 23 Apr 2015 09:25:52 -0400
Subject: Re: Deleting files with open handles on subst'd drives
From: Nick Hansen <nick AT executivecentersuites DOT com>
In-Reply-To: <20150423132420.GL3657@calimero.vinschen.de>
References: <55383264 DOT 5020205 AT gmail DOT com> <20150423081515 DOT GF3657 AT calimero DOT vinschen DOT de> <20150423132420 DOT GL3657 AT calimero DOT vinschen DOT de>
To: cygwin2.ares0.7172f5a5b1.cygwin#cygwin DOT com AT ob DOT 0sg DOT net, cygwin AT cygwin DOT com
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id t3NDPxRp009745

Unsubscribe

Sent from my BlackBerry 10 smartphone on the Verizon Wireless 4G LTE network.
  Original Message  
From: Corinna Vinschen - corinna-cygwin AT cygwin DOT com
Sent: Thursday, April 23, 2015 9:25 AM
To: cygwin AT cygwin DOT com
Reply To: cygwin AT cygwin DOT com
Subject: Re: Deleting files with open handles on subst'd drives

On Apr 23 10:15, Corinna Vinschen wrote:
> On Apr 23 01:44, David Macek wrote:
> > Hello everyone.
> > 
> > Some time ago, I encountered a problem in a script when run on Cygwin/MSYS2. To add some drama, I'll mention that the problem caused some data loss (nothing important though). The problem is that some operations on open files seem to fail on subst'd drives (but not on regular ones).
> > 
> > To reproduce the problem, choose some writable directory and run:
> > $ subst X: C:/somesubdir
> > $ cd /cygdrive/x/
> > $ touch foo
> > $ { rm foo; touch foo; } <foo
> > touch: cannot touch 'foo': Permission denied
> > 
> > (Do not subst to just C:/, because that somehow doesn't lead to the error.)
> > 
> > There's also a C program that does essentially the same thing: <https://gist.github.com/elieux/6463521192baed613099>
> > 
> > I compared this with the same operations running on a regular drive,
> > but I couldn't find any difference in how `rm` deletes the file nor in
> > how `touch` creates the file. Just the result of the last NtCreateFile
> > is different (STATUS_SUCCESS vs. STATUS_DELETE_PENDING).
> 
> It's a result of how Cygwin tries to workaround the weird Windows
> behaviour that a deleted, but still opened file is not invisible in the
> filesystem, as desired per POSIX. Cygwin then tries to move the
> file out of the way, on local drives into the recycler. This fails
> on a subst drive pointing to some subdir apparently, so Cygwin just
> falls back to what Windows does.
> 
> I have no simple workaround for that. In theory there should be a
> way to check the drive for being a virtual drive and then using the
> recycler of the drive it's pointing to for the aforementioned operation.

I hacked a bit on that and it seems the solution was easier than I thought.
I uploaded new developer snaphshots to https://cygwin.com/snapshots/
Replacing the Cygwin DLL alone is sufficient for testing. Please give it
a try.


Thanks,
Corinna

-- 
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat

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