4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-13 04:29:09 +08:00

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>
This commit is contained in:
Corinna Vinschen 2025-01-21 17:19:24 +01:00
parent 890086ad37
commit b879cd1661

View File

@ -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");