https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b1199ab7b0c956280a64590f2b26a9ffde8b8812
commit b1199ab7b0c956280a64590f2b26a9ffde8b8812 Author: Corinna Vinschen <[email protected]> AuthorDate: Sun Jan 12 22:45:54 2025 +0100 Commit: Corinna Vinschen <[email protected]> CommitDate: Sun Jan 12 23:12:19 2025 +0100 Cygwin: unlink/rename: fix skipping deletion with POSIX semantics unlink_nt() and rename2 () both check for the FILE_SUPPORTS_OPEN_BY_FILE_ID flag to use POSIX delete/rename semantics. Both erroneously check the flag against the file attributes using has_attributes(). Given that this flag is a filesystem flag, check using fs_flags() instead. Fixes: fe2545e9faaf ("Cygwin: don't use unlink/rename POSIX semantics on certain NTFS") Signed-off-by: Corinna Vinschen <[email protected]> (cherry picked from commit 264544bf72f6ed85530a1b058e9efdb73ab72e90) Diff: --- winsup/cygwin/release/3.5.6 | 3 +++ winsup/cygwin/syscalls.cc | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/release/3.5.6 b/winsup/cygwin/release/3.5.6 index 45281ec34edb..d17a6af530d2 100644 --- a/winsup/cygwin/release/3.5.6 +++ b/winsup/cygwin/release/3.5.6 @@ -4,3 +4,6 @@ Fixes: - Fix a regression in 3.5.5 when checking for execute permissions in execve(2) and access(2). Addresses: https://cygwin.com/pipermail/cygwin/2024-December/256972.html + +- Fix a regression since 3.5.0 which fails to use POSIX semantics in + unlink/rename on NTFS. diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 11033bca5e6b..290aa50ab647 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -740,7 +740,7 @@ unlink_nt (path_conv &pc, bool shareable) easier and faster. Just try to do it and if it fails, it fails. */ if (wincap.has_posix_unlink_semantics () && !pc.isremote () && pc.fs_is_ntfs () - && pc.has_attribute (FILE_SUPPORTS_OPEN_BY_FILE_ID)) + && (pc.fs_flags () & FILE_SUPPORTS_OPEN_BY_FILE_ID)) { FILE_DISPOSITION_INFORMATION_EX fdie; @@ -2473,9 +2473,9 @@ rename2 (const char *oldpath, const char *newpath, unsigned int at2flags) /* POSIX semantics only on local NTFS drives. For the OPEN_BY_FILE_ID flag, see MINIMAL_WIN_NTFS_FLAGS comment in fs_info::update. */ use_posix_semantics = wincap.has_posix_rename_semantics () - && !oldpc.isremote () - && oldpc.fs_is_ntfs () - && oldpc.has_attribute (FILE_SUPPORTS_OPEN_BY_FILE_ID); + && !oldpc.isremote () + && oldpc.fs_is_ntfs () + && (oldpc.fs_flags () & FILE_SUPPORTS_OPEN_BY_FILE_ID); ignore_posix_semantics_retry: /* Opening the file must be part of the transaction. It's not sufficient
