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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux