[RFC PATCH] vfs: return EINVAL when calling mknod(2) with S_IFDIR mode

From: Mitsuo Hayasaka
Date: Fri Feb 03 2012 - 00:46:18 EST


According to a manual of mknod(2) and mknodat(2), it seems that they
should return EINVAL when called with S_IFDIR mode, although currently
they return EPERM. So, this patch changes it to EINVAL for S_IFDIR.

Signed-off-by: Mitsuo Hayasaka <mitsuo.hayasaka.hu@xxxxxxxxxxx>
Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx>
---

fs/namei.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 208c6aa..5d7ead1 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2483,8 +2483,6 @@ static int may_mknod(umode_t mode)
case S_IFSOCK:
case 0: /* zero mode translates to S_IFREG */
return 0;
- case S_IFDIR:
- return -EPERM;
default:
return -EINVAL;
}
@@ -2498,7 +2496,7 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, umode_t, mode,
int error;

if (S_ISDIR(mode))
- return -EPERM;
+ return -EINVAL;

dentry = user_path_create(dfd, filename, &path, 0);
if (IS_ERR(dentry))

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/