Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2003-10-08 13:17:08 +0400
committerCorinna Vinschen <corinna@vinschen.de>2003-10-08 13:17:08 +0400
commit99439385c6a340db289d2221b481aee095f225aa (patch)
tree5a6e9cdcd5fc05e99e85f6a421c97c0895c0fc13 /winsup/cygwin
parent56efe3a884128b417ff5ffa1d40a91ba36d45d8b (diff)
* syscalls.cc (unlink): Don't even try DELETE_ON_CLOSE technique on
systems not supporting it.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog5
-rw-r--r--winsup/cygwin/syscalls.cc41
2 files changed, 27 insertions, 19 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 59bd2eb93..3be344dd7 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,8 @@
+2003-10-08 Corinna Vinschen <corinna@vinschen.de>
+
+ * syscalls.cc (unlink): Don't even try DELETE_ON_CLOSE technique on
+ systems not supporting it.
+
2003-10-02 Christopher Faylor <cgf@redhat.com>
* dcrt0.cc (dll_crt0_1): Call newlib __sinit routine to ensure that
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 8c53af20e..3444babcf 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -171,26 +171,29 @@ unlink (const char *ourname)
}
/* Attempt to use "delete on close" semantics to handle removing
a file which may be open. */
- HANDLE h;
- h = CreateFile (win32_name, 0, FILE_SHARE_READ, &sec_none_nih,
- OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, 0);
- if (h != INVALID_HANDLE_VALUE)
- {
- if (wincap.has_hard_links () && setattrs)
- (void) SetFileAttributes (win32_name, (DWORD) win32_name);
- BOOL res = CloseHandle (h);
- syscall_printf ("%d = CloseHandle (%p)", res, h);
- if (GetFileAttributes (win32_name) == INVALID_FILE_ATTRIBUTES
- || !win32_name.isremote ())
- {
- syscall_printf ("CreateFile (FILE_FLAG_DELETE_ON_CLOSE) succeeded");
- goto ok;
- }
- else
+ if (wincap.has_delete_on_close ())
+ {
+ HANDLE h;
+ h = CreateFile (win32_name, 0, FILE_SHARE_READ, &sec_none_nih,
+ OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, 0);
+ if (h != INVALID_HANDLE_VALUE)
{
- syscall_printf ("CreateFile (FILE_FLAG_DELETE_ON_CLOSE) failed");
- if (setattrs)
- SetFileAttributes (win32_name, (DWORD) win32_name & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM));
+ if (wincap.has_hard_links () && setattrs)
+ (void) SetFileAttributes (win32_name, (DWORD) win32_name);
+ BOOL res = CloseHandle (h);
+ syscall_printf ("%d = CloseHandle (%p)", res, h);
+ if (GetFileAttributes (win32_name) == INVALID_FILE_ATTRIBUTES
+ || !win32_name.isremote ())
+ {
+ syscall_printf ("CreateFile (FILE_FLAG_DELETE_ON_CLOSE) succeeded");
+ goto ok;
+ }
+ else
+ {
+ syscall_printf ("CreateFile (FILE_FLAG_DELETE_ON_CLOSE) failed");
+ if (setattrs)
+ SetFileAttributes (win32_name, (DWORD) win32_name & ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM));
+ }
}
}