Currently filesystems return -EACCES for missing ->create and -EPERM for missing ->mkdir in vfs_create/vfs_mkdir. Instead of duplicating these dubious and inconsistent error codes to lookup_open(), change all to -EOPNOTSUPP. Signed-off-by: Jori Koolstra --- arch/alpha/include/uapi/asm/errno.h | 2 +- arch/mips/include/uapi/asm/errno.h | 2 +- arch/parisc/include/uapi/asm/errno.h | 2 +- arch/sparc/include/uapi/asm/errno.h | 2 +- fs/namei.c | 14 +++++--------- include/uapi/asm-generic/errno.h | 2 +- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/arch/alpha/include/uapi/asm/errno.h b/arch/alpha/include/uapi/asm/errno.h index 1a99f38813c7..0384f6998974 100644 --- a/arch/alpha/include/uapi/asm/errno.h +++ b/arch/alpha/include/uapi/asm/errno.h @@ -19,7 +19,7 @@ #define ENOPROTOOPT 42 /* Protocol not available */ #define EPROTONOSUPPORT 43 /* Protocol not supported */ #define ESOCKTNOSUPPORT 44 /* Socket type not supported */ -#define EOPNOTSUPP 45 /* Operation not supported on transport endpoint */ +#define EOPNOTSUPP 45 /* Operation not supported */ #define EPFNOSUPPORT 46 /* Protocol family not supported */ #define EAFNOSUPPORT 47 /* Address family not supported by protocol */ #define EADDRINUSE 48 /* Address already in use */ diff --git a/arch/mips/include/uapi/asm/errno.h b/arch/mips/include/uapi/asm/errno.h index 1835a50b69ce..2b6813715d1e 100644 --- a/arch/mips/include/uapi/asm/errno.h +++ b/arch/mips/include/uapi/asm/errno.h @@ -75,7 +75,7 @@ #define ENOPROTOOPT 99 /* Protocol not available */ #define EPROTONOSUPPORT 120 /* Protocol not supported */ #define ESOCKTNOSUPPORT 121 /* Socket type not supported */ -#define EOPNOTSUPP 122 /* Operation not supported on transport endpoint */ +#define EOPNOTSUPP 122 /* Operation not supported */ #define EPFNOSUPPORT 123 /* Protocol family not supported */ #define EAFNOSUPPORT 124 /* Address family not supported by protocol */ #define EADDRINUSE 125 /* Address already in use */ diff --git a/arch/parisc/include/uapi/asm/errno.h b/arch/parisc/include/uapi/asm/errno.h index 93194fbb0a80..74bd65d79145 100644 --- a/arch/parisc/include/uapi/asm/errno.h +++ b/arch/parisc/include/uapi/asm/errno.h @@ -84,7 +84,7 @@ #define ENOPROTOOPT 220 /* Protocol not available */ #define EPROTONOSUPPORT 221 /* Protocol not supported */ #define ESOCKTNOSUPPORT 222 /* Socket type not supported */ -#define EOPNOTSUPP 223 /* Operation not supported on transport endpoint */ +#define EOPNOTSUPP 223 /* Operation not supported */ #define EPFNOSUPPORT 224 /* Protocol family not supported */ #define EAFNOSUPPORT 225 /* Address family not supported by protocol */ #define EADDRINUSE 226 /* Address already in use */ diff --git a/arch/sparc/include/uapi/asm/errno.h b/arch/sparc/include/uapi/asm/errno.h index 71940ec9130b..699f648e1a35 100644 --- a/arch/sparc/include/uapi/asm/errno.h +++ b/arch/sparc/include/uapi/asm/errno.h @@ -16,7 +16,7 @@ #define ENOPROTOOPT 42 /* Protocol not available */ #define EPROTONOSUPPORT 43 /* Protocol not supported */ #define ESOCKTNOSUPPORT 44 /* Socket type not supported */ -#define EOPNOTSUPP 45 /* Op not supported on transport endpoint */ +#define EOPNOTSUPP 45 /* Operation not supported */ #define EPFNOSUPPORT 46 /* Protocol family not supported */ #define EAFNOSUPPORT 47 /* Address family not supported by protocol */ #define EADDRINUSE 48 /* Address already in use */ diff --git a/fs/namei.c b/fs/namei.c index e7d3d28f3fd7..f21cd1028a8a 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -4254,7 +4254,7 @@ int vfs_create(struct mnt_idmap *idmap, struct dentry *dentry, umode_t mode, return error; if (!dir->i_op->create) - return -EACCES; /* shouldn't it be ENOSYS? */ + return -EOPNOTSUPP; mode = vfs_prepare_mode(idmap, dir, mode, S_IALLUGO, S_IFREG); error = security_inode_create(dir, dentry, mode); @@ -4650,13 +4650,9 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file, goto out_dput; } - /* mimic operation missing errnos of vfs_mkdir/vfs_create */ - if (create_dir && !dir_inode->i_op->mkdir) { - error = -EPERM; - goto out_dput; - } - if (!create_dir && !dir_inode->i_op->create) { - error = -EACCES; + if ((create_dir && !dir_inode->i_op->mkdir) + || (!create_dir && !dir_inode->i_op->create)) { + error = -EOPNOTSUPP; goto out_dput; } @@ -5518,7 +5514,7 @@ struct dentry *vfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, if (error) goto err; - error = -EPERM; + error = -EOPNOTSUPP; if (!dir->i_op->mkdir) goto err; diff --git a/include/uapi/asm-generic/errno.h b/include/uapi/asm-generic/errno.h index bd78e69e0a43..c84ebf89c8b6 100644 --- a/include/uapi/asm-generic/errno.h +++ b/include/uapi/asm-generic/errno.h @@ -76,7 +76,7 @@ #define ENOPROTOOPT 92 /* Protocol not available */ #define EPROTONOSUPPORT 93 /* Protocol not supported */ #define ESOCKTNOSUPPORT 94 /* Socket type not supported */ -#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define EOPNOTSUPP 95 /* Operation not supported */ #define EPFNOSUPPORT 96 /* Protocol family not supported */ #define EAFNOSUPPORT 97 /* Address family not supported by protocol */ #define EADDRINUSE 98 /* Address already in use */ -- 2.56.0