This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Deleting files with open handles on subst'd drives
- From: Nick Hansen <nick at executivecentersuites dot com>
- To: cygwin2 dot ares0 dot 7172f5a5b1 dot cygwin#cygwin dot com at ob dot 0sg dot net, cygwin at cygwin dot com
- Date: Thu, 23 Apr 2015 09:25:52 -0400
- Subject: Re: Deleting files with open handles on subst'd drives
- Authentication-results: sourceware.org; auth=none
- 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>
Unsubscribe
Sent from my BlackBerry 10 smartphone on the Verizon Wireless 4G LTE network.
Original Message
From: Corinna Vinschen - corinna-cygwin@cygwin.com
Sent: Thursday, April 23, 2015 9:25 AM
To: cygwin@cygwin.com
Reply To: cygwin@cygwin.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