diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2025-01-12 22:45:54 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2025-01-12 23:11:18 +0100 |
commit | 264544bf72f6ed85530a1b058e9efdb73ab72e90 (patch) | |
tree | ad77b80e7d1168f28cddb9230154e6b477cf3299 | |
parent | b42ac298bb2ea7c39b0827429779d800ee7f5ac0 (diff) | |
download | newlib-264544bf72f6ed85530a1b058e9efdb73ab72e90.zip newlib-264544bf72f6ed85530a1b058e9efdb73ab72e90.tar.gz newlib-264544bf72f6ed85530a1b058e9efdb73ab72e90.tar.bz2 |
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 <corinna@vinschen.de>
-rw-r--r-- | winsup/cygwin/release/3.5.6 | 3 | ||||
-rw-r--r-- | 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 45281ec..d17a6af 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 5ff0f02..00ad040 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; @@ -2522,9 +2522,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 |