[newlib-cygwin/main] Cygwin: unlink: fix error checking order
Corinna Vinschen
corinna@sourceware.org
Tue Jan 21 16:32:22 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b879cd1661ad2fb37f603e18f6b1860c91f445ec
commit b879cd1661ad2fb37f603e18f6b1860c91f445ec
Author: Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Tue Jan 21 17:19:24 2025 +0100
Commit: Corinna Vinschen <corinna@vinschen.de>
CommitDate: Tue Jan 21 17:31:21 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>
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 52a5601d2c9a..1cb7821178c5 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -1136,17 +1136,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