From 07e0a9584f9a5b2668c767ede0482a5fba498731 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 26 Dec 2018 21:51:13 +0100 Subject: [PATCH] Cygwin: open(2): Change comment in disabled O_TMPFILE POSIX unlink code - Turns out, the definition of POSIX unlink semantics is half-hearted so far: It's not possible to link an open file HANDLE if it has been deleted with POSIX semantics, nor is it possible to remove the delete disposition. This breaks linkat on an O_TMPFILE. Tested with W10 1809. Signed-off-by: Corinna Vinschen --- winsup/cygwin/syscalls.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index c1a3ed418..0d4809037 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1468,13 +1468,20 @@ open (const char *unix_path, int flags, ...) || !fh->open_with_arch (flags, mode & 07777)) __leave; /* errno already set */ #if 0 - /* W10 1709 POSIX unlink semantics: + /* Don't use W10 1709 POSIX unlink semantics here. - TODO: Works nicely for O_TEMPFILE but using linkat requires that - we first fix /proc/self/fd handling to allow opening by handle - rather than by symlinked filename only. */ + 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/); + + semantics. */ if ((flags & O_TMPFILE) && wincap.has_posix_file_info () - && fh->pc.fs_is_ntfs ()) + && !fh->pc.isremote () && fh->pc.fs_is_ntfs ()) { HANDLE del_h; OBJECT_ATTRIBUTES attr; -- 2.43.5