Currently sysdeps/posix/remove.c reads this: #v+ int remove (file) const char *file; { /* First try to unlink since this is more frequently the necessary action. */ if (__unlink (file) != 0 /* If it is indeed a directory... */ && (errno != EISDIR /* ...try to remove it. */ || __rmdir (file) != 0)) /* Cannot remove the object for whatever reason. */ return -1; return 0; } #v- However, POSIX says unlink(2) returns `EPERM' when PATH is a directory. `EISDIR' is Linux-specific and the "Rationale" section at http://www.opengroup.org/onlinepubs/9699919799/functions/unlink.html says that "[a]pplications written for portability to both POSIX.1-2008 and the LSB should be prepared to handle either error code." Currently remove(3) fails on GNU/Hurd [0] and GNU/kFreeBSD [1] because of this. Thus it should be changed to handle both `EPERM' and `EISDIR'. [0] https://savannah.gnu.org/bugs/?28859 [1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=557248
Changed in git.