fs: make vfs_fileattr_[get|set] return -EOPNOSUPP
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v5 5/7 fs: make vfs_fileattr_[get|set] return -EOPNOSUPP
Future patches will add new syscalls which use these functions. As this interface won't be used for ioctls only the EOPNOSUPP is more appropriate return code.
This patch coverts return code from ENOIOCTLCMD to EOPNOSUPP for vfs_fileattr_get and vfs_fileattr_set. To save old behavior translate EOPNOSUPP back for current users - overlayfs, encryptfs and fs/ioctl.c.
--- fs/ecryptfs/inode.c | 8 +++++++- fs/file_attr.c | 12 ++++++++++-- fs/overlayfs/inode.c | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-)
fs/ecryptfs/inode.c +7 -1
@@ -1124,7 +1124,13 @@ static int ecryptfs_removexattr(struct dentry *dentry, struct inode *inode,static int ecryptfs_fileattr_get (struct dentry *dentry,struct fileattr *fa) { -return vfs_fileattr_get (ecryptfs_dentry_to_lower (dentry), fa); +int rc; + + rc =vfs_fileattr_get (ecryptfs_dentry_to_lower (dentry), fa); +if (rc == -EOPNOTSUPP ) + rc = -ENOIOCTLCMD ; + +return rc; } static int ecryptfs_fileattr_set(struct mnt_idmap *idmap,
fs/file_attr.c +10 -2
@@ -79,7 +79,7 @@ int vfs_fileattr_get(struct dentry *dentry, struct fileattr *fa)int error;if (!inode->i_op->fileattr_get) -return -ENOIOCTLCMD ; +return -EOPNOTSUPP ; error =security_inode_file_getattr (dentry, fa);if (error)
@@ -239,7 +239,7 @@ int vfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,int err;if (!inode->i_op->fileattr_set) -return -ENOIOCTLCMD ; +return -EOPNOTSUPP ;if (!inode_owner_or_capable (idmap, inode))return -EPERM ;
@@ -281,6 +281,8 @@ int ioctl_getflags(struct file *file, unsigned int __user *argp)int err; err =vfs_fileattr_get (file->f_path.dentry, &fa); +if (err == -EOPNOTSUPP ) + err = -ENOIOCTLCMD ;if (!err) err =put_user (fa.flags, argp);return err;
@@ -302,6 +304,8 @@ int ioctl_setflags(struct file *file, unsigned int __user *argp)fileattr_fill_flags (&fa, flags); err =vfs_fileattr_set (idmap, dentry, &fa);mnt_drop_write_file (file); +if (err == -EOPNOTSUPP ) + err = -ENOIOCTLCMD ; } }return err;
@@ -314,6 +318,8 @@ int ioctl_fsgetxattr(struct file *file, void __user *argp)int err; err =vfs_fileattr_get (file->f_path.dentry, &fa); +if (err == -EOPNOTSUPP ) + err = -ENOIOCTLCMD ;if (!err) err =copy_fsxattr_to_user (&fa, argp);
@@ -334,6 +340,8 @@ int ioctl_fssetxattr(struct file *file, void __user *argp)if (!err) { err =vfs_fileattr_set (idmap, dentry, &fa);mnt_drop_write_file (file); +if (err == -EOPNOTSUPP ) + err = -ENOIOCTLCMD ; } }return err;
fs/overlayfs/inode.c +1 -1
@@ -721,7 +721,7 @@ int ovl_real_fileattr_get(const struct path *realpath, struct fileattr *fa)return err; err =vfs_fileattr_get (realpath->dentry, fa); -if (err == -ENOIOCTLCMD ) +if (err == -EOPNOTSUPP ) err = -ENOTTY ;return err; }
Signature · 5 lines
2.47.2 -- - Andrey
Quoted 113 lines · Andrey Albershteyn
Future patches will add new syscalls which use these functions. As this interface won't be used for ioctls only the EOPNOSUPP is more appropriate return code.
This patch coverts return code from ENOIOCTLCMD to EOPNOSUPP for
vfs_fileattr_getandvfs_fileattr_set. To save old behavior translate EOPNOSUPP back for current users - overlayfs, encryptfs andfs/ioctl.c.Signed-off-by Andrey Albershteyn <[email protected]>--- fs/ecryptfs/inode.c | 8 +++++++- fs/file_attr.c | 12 ++++++++++-- fs/overlayfs/inode.c | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-)fs/ecryptfs/inode.c +7
-1@@ -1124,7 +1124,13 @@ static int ecryptfs_removexattr(struct dentry *dentry, struct inode *inode,static int ecryptfs_fileattr_get (struct dentry *dentry,struct fileattr *fa) { -return vfs_fileattr_get (ecryptfs_dentry_to_lower (dentry), fa); +int rc; + + rc =vfs_fileattr_get (ecryptfs_dentry_to_lower (dentry), fa); +if (rc == -EOPNOTSUPP ) + rc = -ENOIOCTLCMD ; + +return rc; } static int ecryptfs_fileattr_set(struct mnt_idmap *idmap,fs/file_attr.c +10
-2@@ -79,7 +79,7 @@ int vfs_fileattr_get(struct dentry *dentry, struct fileattr *fa)int error;if (!inode->i_op->fileattr_get) -return -ENOIOCTLCMD ; +return -EOPNOTSUPP ; error =security_inode_file_getattr (dentry, fa);if (error)@@ -239,7 +239,7 @@ int vfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,int err;if (!inode->i_op->fileattr_set) -return -ENOIOCTLCMD ; +return -EOPNOTSUPP ;if (!inode_owner_or_capable (idmap, inode))return -EPERM ;@@ -281,6 +281,8 @@ int ioctl_getflags(struct file *file, unsigned int __user *argp)int err; err =vfs_fileattr_get (file->f_path.dentry, &fa); +if (err == -EOPNOTSUPP ) + err = -ENOIOCTLCMD ;if (!err) err =put_user (fa.flags, argp);return err;@@ -302,6 +304,8 @@ int ioctl_setflags(struct file *file, unsigned int __user *argp)fileattr_fill_flags (&fa, flags); err =vfs_fileattr_set (idmap, dentry, &fa);mnt_drop_write_file (file); +if (err == -EOPNOTSUPP ) + err = -ENOIOCTLCMD ; } }return err;@@ -314,6 +318,8 @@ int ioctl_fsgetxattr(struct file *file, void __user *argp)int err; err =vfs_fileattr_get (file->f_path.dentry, &fa); +if (err == -EOPNOTSUPP ) + err = -ENOIOCTLCMD ;if (!err) err =copy_fsxattr_to_user (&fa, argp);@@ -334,6 +340,8 @@ int ioctl_fssetxattr(struct file *file, void __user *argp)if (!err) { err =vfs_fileattr_set (idmap, dentry, &fa);mnt_drop_write_file (file); +if (err == -EOPNOTSUPP ) + err = -ENOIOCTLCMD ; } }return err;fs/overlayfs/inode.c +1
-1@@ -721,7 +721,7 @@ int ovl_real_fileattr_get(const struct path *realpath, struct fileattr *fa)return err; err =vfs_fileattr_get (realpath->dentry, fa); -if (err == -ENOIOCTLCMD ) +if (err == -EOPNOTSUPP ) err = -ENOTTY ;return err; }Signature · 6 lines
-- 2.47.2 -- - Andrey
Ignore please, sorry, wrong in-reply-to
Signature · 1 line
- Andrey