This seems a bit wrong, would not EISDIR be a better value? I know
that root can sometimes unlink() directories, but even so I think
EISDIR is better for non-root users.
Here's an untested patch against 2.0.17 fs/ext2/namei.c to correct it.
--- namei.c Wed Jul 10 12:11:15 1996
+++ /tmp/namei.c Fri Sep 6 00:27:54 1996
@@ -719,8 +719,10 @@
if (inode->i_sb->dq_op)
inode->i_sb->dq_op->initialize (inode, -1);
retval = -EPERM;
- if (S_ISDIR(inode->i_mode))
+ if (S_ISDIR(inode->i_mode)) {
+ retval = -EISDIR;
goto end_unlink;
+ }
if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
goto end_unlink;
if (de->inode != inode->i_ino) {
Perhaps the test should be (S_ISDIR(inode->i_mode) && fsuser()), if
root should be able to unlink directories on linux.
The same problem may affect other file system, I haven't checked.
--Arnt