From 03897d8dda6706148fb7aae9e86730d4b5840e22 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 16 Apr 2009 12:16:35 +0000 Subject: [PATCH] * ntdll.h (STATUS_LOCK_NOT_GRANTED): Define. * syscalls.cc (unlink_nt): Handle STATUS_LOCK_NOT_GRANTED same as STATUS_SHARING_VIOLATION. Add lengthy comment to explain why. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/ntdll.h | 1 + winsup/cygwin/syscalls.cc | 12 +++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 4bf2a5838..4b2f7d88f 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2009-04-16 Corinna Vinschen + + * ntdll.h (STATUS_LOCK_NOT_GRANTED): Define. + * syscalls.cc (unlink_nt): Handle STATUS_LOCK_NOT_GRANTED same as + STATUS_SHARING_VIOLATION. Add lengthy comment to explain why. + 2009-04-15 Corinna Vinschen * path.cc (path_conv::get_wide_win32_path): Allow relative paths. diff --git a/winsup/cygwin/ntdll.h b/winsup/cygwin/ntdll.h index 3bc2cbef3..bf0062870 100644 --- a/winsup/cygwin/ntdll.h +++ b/winsup/cygwin/ntdll.h @@ -34,6 +34,7 @@ #define STATUS_EA_TOO_LARGE ((NTSTATUS) 0xc0000050) #define STATUS_NONEXISTENT_EA_ENTRY ((NTSTATUS) 0xc0000051) #define STATUS_NO_EAS_ON_FILE ((NTSTATUS) 0xc0000052) +#define STATUS_LOCK_NOT_GRANTED ((NTSTATUS) 0xc0000055) #define STATUS_DELETE_PENDING ((NTSTATUS) 0xc0000056) #define STATUS_DISK_FULL ((NTSTATUS) 0xc000007f) #define STATUS_WORKING_SET_QUOTA ((NTSTATUS) 0xc00000a1) diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 7e684e561..64c25348e 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -470,8 +470,18 @@ unlink_nt (path_conv &pc) we can go straight to setting the delete disposition flag. */ bin_status bin_stat = dont_move; status = NtOpenFile (&fh, access, &attr, &io, FILE_SHARE_DELETE, flags); - if (status == STATUS_SHARING_VIOLATION) + if (status == STATUS_SHARING_VIOLATION || status == STATUS_LOCK_NOT_GRANTED) { + /* STATUS_LOCK_NOT_GRANTED can be generated under not quite clear + circumstances when trying to open a file on NFS with FILE_SHARE_DELETE + only. This has been observed with SFU 3.5 if the NFS share has been + mounted under a drive letter. It's not generated for all files, but + only for some. If it's generated once for a file, it will be + generated all the time. It looks like wrong file state information + is stored within the NFS client, for no apparent reason, which never + times out. Opening the file with FILE_SHARE_VALID_FLAGS will work, + though, and it is then possible to delete the file quite normally. */ + /* Bin is only accessible locally. */ if (!pc.isremote ()) bin_stat = move_to_bin;