Skip to content

Commit 474b155

Browse files
alberandbrauner
authored andcommitted
fs: make vfs_fileattr_[get|set] return -EOPNOTSUPP
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 converts 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. Signed-off-by: Andrey Albershteyn <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent bd14e46 commit 474b155

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

fs/file_attr.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ int vfs_fileattr_get(struct dentry *dentry, struct fileattr *fa)
8080
int error;
8181

8282
if (!inode->i_op->fileattr_get)
83-
return -ENOIOCTLCMD;
83+
return -EOPNOTSUPP;
8484

8585
error = security_inode_file_getattr(dentry, fa);
8686
if (error)
@@ -230,7 +230,7 @@ int vfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,
230230
int err;
231231

232232
if (!inode->i_op->fileattr_set)
233-
return -ENOIOCTLCMD;
233+
return -EOPNOTSUPP;
234234

235235
if (!inode_owner_or_capable(idmap, inode))
236236
return -EPERM;
@@ -272,6 +272,8 @@ int ioctl_getflags(struct file *file, unsigned int __user *argp)
272272
int err;
273273

274274
err = vfs_fileattr_get(file->f_path.dentry, &fa);
275+
if (err == -EOPNOTSUPP)
276+
err = -ENOIOCTLCMD;
275277
if (!err)
276278
err = put_user(fa.flags, argp);
277279
return err;
@@ -293,6 +295,8 @@ int ioctl_setflags(struct file *file, unsigned int __user *argp)
293295
fileattr_fill_flags(&fa, flags);
294296
err = vfs_fileattr_set(idmap, dentry, &fa);
295297
mnt_drop_write_file(file);
298+
if (err == -EOPNOTSUPP)
299+
err = -ENOIOCTLCMD;
296300
}
297301
}
298302
return err;
@@ -305,6 +309,8 @@ int ioctl_fsgetxattr(struct file *file, void __user *argp)
305309
int err;
306310

307311
err = vfs_fileattr_get(file->f_path.dentry, &fa);
312+
if (err == -EOPNOTSUPP)
313+
err = -ENOIOCTLCMD;
308314
if (!err)
309315
err = copy_fsxattr_to_user(&fa, argp);
310316

@@ -325,6 +331,8 @@ int ioctl_fssetxattr(struct file *file, void __user *argp)
325331
if (!err) {
326332
err = vfs_fileattr_set(idmap, dentry, &fa);
327333
mnt_drop_write_file(file);
334+
if (err == -EOPNOTSUPP)
335+
err = -ENOIOCTLCMD;
328336
}
329337
}
330338
return err;

fs/fuse/ioctl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,8 @@ int fuse_fileattr_get(struct dentry *dentry, struct fileattr *fa)
536536
cleanup:
537537
fuse_priv_ioctl_cleanup(inode, ff);
538538

539+
if (err == -ENOTTY)
540+
err = -EOPNOTSUPP;
539541
return err;
540542
}
541543

@@ -572,5 +574,7 @@ int fuse_fileattr_set(struct mnt_idmap *idmap,
572574
cleanup:
573575
fuse_priv_ioctl_cleanup(inode, ff);
574576

577+
if (err == -ENOTTY)
578+
err = -EOPNOTSUPP;
575579
return err;
576580
}

fs/overlayfs/copy_up.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static int ovl_copy_fileattr(struct inode *inode, const struct path *old,
178178
err = ovl_real_fileattr_get(old, &oldfa);
179179
if (err) {
180180
/* Ntfs-3g returns -EINVAL for "no fileattr support" */
181-
if (err == -ENOTTY || err == -EINVAL)
181+
if (err == -EOPNOTSUPP || err == -EINVAL)
182182
return 0;
183183
pr_warn("failed to retrieve lower fileattr (%pd2, err=%i)\n",
184184
old->dentry, err);

fs/overlayfs/inode.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -720,10 +720,7 @@ int ovl_real_fileattr_get(const struct path *realpath, struct fileattr *fa)
720720
if (err)
721721
return err;
722722

723-
err = vfs_fileattr_get(realpath->dentry, fa);
724-
if (err == -ENOIOCTLCMD)
725-
err = -ENOTTY;
726-
return err;
723+
return vfs_fileattr_get(realpath->dentry, fa);
727724
}
728725

729726
int ovl_fileattr_get(struct dentry *dentry, struct fileattr *fa)

0 commit comments

Comments
 (0)