https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=34d9bb709390b14b4ed0b1ea2656bf6bf5a055c3

commit 34d9bb709390b14b4ed0b1ea2656bf6bf5a055c3
Author: Corinna Vinschen <[email protected]>
Date:   Fri Jan 4 11:00:57 2019 +0100

    Cygwin: drop disabled O_TMPFILE POSIX unlink code
    
    The commit message of commit 07e0a9584f9a5b2668c767ede0482a5fba498731
    and the expectation set therein, are wrong.
    
    There's no POSIX semantics allowing to link a file with a link
    count of 0 and making it available in the file system again.
    In fact, the Linux linkat extension AT_EMPTY_PATH explicitely
    disallows to link a file descriptor to a file with a link count
    of 0, except for O_TMPFILE without O_EXCL.
    
    Signed-off-by: Corinna Vinschen <[email protected]>

Diff:
---
 winsup/cygwin/syscalls.cc | 40 ----------------------------------------
 1 file changed, 40 deletions(-)

diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 0d48090..73c15b1 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -1467,46 +1467,6 @@ open (const char *unix_path, int flags, ...)
       if ((fh->is_fs_special () && fh->device_access_denied (flags))
          || !fh->open_with_arch (flags, mode & 07777))
        __leave;                /* errno already set */
-#if 0
-      /* Don't use W10 1709 POSIX unlink semantics here.
-
-        Including W10 1809, NtSetInformationFile(FileLinkInformation) on a
-        HANDLE to a file unlinked with POSIX semantics fails with
-        STATUS_ACCESS_DENIED.  Trying to remove the delete disposition on
-        the file prior to calling link fails with STATUS_FILE_DELETED.
-        This breaks
-
-          fd = open(O_TMPFILE);
-          linkat("/proc/self/fd/<fd>);
-
-         semantics. */
-      if ((flags & O_TMPFILE) && wincap.has_posix_file_info ()
-         && !fh->pc.isremote () && fh->pc.fs_is_ntfs ())
-       {
-         HANDLE del_h;
-         OBJECT_ATTRIBUTES attr;
-         NTSTATUS status;
-         IO_STATUS_BLOCK io;
-         FILE_DISPOSITION_INFORMATION_EX fdie;
-
-         status = NtOpenFile (&del_h, DELETE,
-                      fh->pc.init_reopen_attr (attr, fh->get_handle ()), &io,
-                      FILE_SHARE_VALID_FLAGS, FILE_OPEN_FOR_BACKUP_INTENT);
-         if (!NT_SUCCESS (status))
-           debug_printf ("reopening tmpfile handle failed, status %y", status);
-         else
-           {
-             fdie.Flags = FILE_DISPOSITION_DELETE
-                          | FILE_DISPOSITION_POSIX_SEMANTICS;
-             status = NtSetInformationFile (del_h, &io, &fdie, sizeof fdie,
-                                            FileDispositionInformationEx);
-             if (!NT_SUCCESS (status))
-               debug_printf ("Setting POSIX delete disposition on tmpfile "
-                             "failed, status = %y", status);
-             NtClose (del_h);
-           }
-       }
-#endif
       fd = fh;
       if (fd <= 2)
        set_std_handle (fd);

Reply via email to