https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=ed670825e8cba3a97992558f2199cbc56c6c4a6b
commit ed670825e8cba3a97992558f2199cbc56c6c4a6b Author: Corinna Vinschen <[email protected]> AuthorDate: Tue Jan 21 17:19:24 2025 +0100 Commit: Corinna Vinschen <[email protected]> CommitDate: Sat Jan 25 11:45:41 2025 +0100 Cygwin: unlink: fix error checking order Checking EPERM only makes sense if the file exists, so let the EEXIST check change places with the EPERM check. Add a debug statement to the EPERM condition. Signed-off-by: Corinna Vinschen <[email protected]> (cherry picked from commit b879cd1661ad2fb37f603e18f6b1860c91f445ec) Diff: --- winsup/cygwin/syscalls.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 3b8f30e81642..83318d60570f 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1133,17 +1133,18 @@ unlink (const char *ourname) set_errno (EROFS); goto done; } - if (!win32_name.isondisk ()) - { - set_errno (EPERM); - goto done; - } if (!win32_name.exists ()) { debug_printf ("unlinking a nonexistent file"); set_errno (ENOENT); goto done; } + if (!win32_name.isondisk ()) + { + debug_printf ("unlinking a virtual file"); + set_errno (EPERM); + goto done; + } else if (win32_name.isdir ()) { debug_printf ("unlinking a directory");
