[newlib-cygwin/cygwin-3_5-branch] Cygwin: unlink: fix error checking order
Corinna Vinschen
corinna@sourceware.org
Sat Jan 25 11:55:34 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=ed670825e8cba3a97992558f2199cbc56c6c4a6b
commit ed670825e8cba3a97992558f2199cbc56c6c4a6b
Author: Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Tue Jan 21 17:19:24 2025 +0100
Commit: Corinna Vinschen <corinna@vinschen.de>
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 <corinna@vinschen.de>
(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");
More information about the Cygwin-cvs
mailing list