This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Deleting files with open handles on subst'd drives

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

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


David Macek

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]