Skip to content

Commit ed67082

Browse files
committed
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 b879cd1)
1 parent 002aad0 commit ed67082

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

winsup/cygwin/syscalls.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,17 +1133,18 @@ unlink (const char *ourname)
11331133
set_errno (EROFS);
11341134
goto done;
11351135
}
1136-
if (!win32_name.isondisk ())
1137-
{
1138-
set_errno (EPERM);
1139-
goto done;
1140-
}
11411136
if (!win32_name.exists ())
11421137
{
11431138
debug_printf ("unlinking a nonexistent file");
11441139
set_errno (ENOENT);
11451140
goto done;
11461141
}
1142+
if (!win32_name.isondisk ())
1143+
{
1144+
debug_printf ("unlinking a virtual file");
1145+
set_errno (EPERM);
1146+
goto done;
1147+
}
11471148
else if (win32_name.isdir ())
11481149
{
11491150
debug_printf ("unlinking a directory");

0 commit comments

Comments
 (0)