Bug in unlink error return

Andries.Brouwer@cwi.nl
Thu, 17 May 2001 13:26:44 +0200 (MET DST)


Someone complained a moment ago about the error return in unlink.
And indeed, it used to be correct but since 2.1.132 we return a
buggy (or at least non-POSIX) error for unlink(directory).

Just changed the man page to say

unlink(2)
...
EPERM The system does not allow unlinking of directories,
or unlinking of directories requires privileges
that the current process doesn't have. (This is
the POSIX prescribed error return.)

EISDIR pathname refers to a directory. (This is the non-
POSIX value returned by Linux since 2.1.132.)
...

Probably this should be fixed again, both in 2.2 and 2.4.
2.0 is still correct (I checked only ext2).

Andries

[The EISDIR is correct for rename(), and the cleanup that
made a nice uniform may_delete() in namei.c introduced this bug.
The very simple but slightly ugly fix is to write (in vfs_unlink)
error = may_delete(dir, dentry, 0);
if (error == -EISDIR)
error = -EPERM;
]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/