Deleting files with open handles on subst'd drives

David Macek david.macek.0@gmail.com
Wed Apr 22 23:45:00 GMT 2015


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

Thoughts?

-- 
David Macek

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4234 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://cygwin.com/pipermail/cygwin/attachments/20150422/db46d8f7/attachment.p7s>


More information about the Cygwin mailing list