Re: unlink system call on directories - Bug + fix

Aaron M. Ucko (
17 Nov 1996 11:10:03 -0500

"Andrew M. Bishop" <> writes:

> The manual page for unlink() and the actual behaviour do not match
> when the file to be unlinked is a directory.
> The manual page says that unlink() returns EISDIR when the pathname
> refers to a directory. But the kernel returns EPERM for minix and
> derivatives ext,ext2 etc., see the file namei.c in those directories.
> The fix for these is trivial (if I understand correctly how the kernel
> handles the unlink command) and left as an exercise to the reader.

Yes, editing manpages is easy :-). From section of the 1996
edition of the POSIX.1 spec:

[EPERM] The file named by _path_ is a directory, and either the
calling process does not hae appropriate privileges or the
implementation prohibits using unlink() on directories.

Aaron M. Ucko ( | For Geek Code, PGP public key, and other info,
finger | "Kids! Bringing about Armageddon can be dangerous.
Do not attempt it in your home." -- T. Pratchett & N. Gaiman, _Good Omens_