Skip to content

Commit b279628

Browse files
committed
Merge patch series "Fix to EOPNOTSUPP double conversion in ioctl_setflags()"
Andrey Albershteyn <[email protected]> says: Revert original double conversion patch from ENOIOCTLCMD to EOPNOSUPP for vfs_fileattr_get and vfs_fileattr_set. Instead, convert ENOIOCTLCMD only where necessary. To: [email protected] To: [email protected] To: [email protected] To: [email protected], Cc: "Jan Kara" <[email protected]> Cc: "Jiri Slaby" <[email protected]> Cc: "Christian Brauner" <[email protected]> Cc: "Arnd Bergmann" <[email protected]> * patches from https://lore.kernel.org/[email protected]: fs: return EOPNOTSUPP from file_setattr/file_getattr syscalls Revert "fs: make vfs_fileattr_[get|set] return -EOPNOTSUPP" Signed-off-by: Christian Brauner <[email protected]>
2 parents a779e27 + d90ad28 commit b279628

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

fs/file_attr.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ int vfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
8484
int error;
8585

8686
if (!inode->i_op->fileattr_get)
87-
return -EOPNOTSUPP;
87+
return -ENOIOCTLCMD;
8888

8989
error = security_inode_file_getattr(dentry, fa);
9090
if (error)
@@ -270,7 +270,7 @@ int vfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,
270270
int err;
271271

272272
if (!inode->i_op->fileattr_set)
273-
return -EOPNOTSUPP;
273+
return -ENOIOCTLCMD;
274274

275275
if (!inode_owner_or_capable(idmap, inode))
276276
return -EPERM;
@@ -312,8 +312,6 @@ int ioctl_getflags(struct file *file, unsigned int __user *argp)
312312
int err;
313313

314314
err = vfs_fileattr_get(file->f_path.dentry, &fa);
315-
if (err == -EOPNOTSUPP)
316-
err = -ENOIOCTLCMD;
317315
if (!err)
318316
err = put_user(fa.flags, argp);
319317
return err;
@@ -335,8 +333,6 @@ int ioctl_setflags(struct file *file, unsigned int __user *argp)
335333
fileattr_fill_flags(&fa, flags);
336334
err = vfs_fileattr_set(idmap, dentry, &fa);
337335
mnt_drop_write_file(file);
338-
if (err == -EOPNOTSUPP)
339-
err = -ENOIOCTLCMD;
340336
}
341337
}
342338
return err;
@@ -349,8 +345,6 @@ int ioctl_fsgetxattr(struct file *file, void __user *argp)
349345
int err;
350346

351347
err = vfs_fileattr_get(file->f_path.dentry, &fa);
352-
if (err == -EOPNOTSUPP)
353-
err = -ENOIOCTLCMD;
354348
if (!err)
355349
err = copy_fsxattr_to_user(&fa, argp);
356350

@@ -371,8 +365,6 @@ int ioctl_fssetxattr(struct file *file, void __user *argp)
371365
if (!err) {
372366
err = vfs_fileattr_set(idmap, dentry, &fa);
373367
mnt_drop_write_file(file);
374-
if (err == -EOPNOTSUPP)
375-
err = -ENOIOCTLCMD;
376368
}
377369
}
378370
return err;
@@ -424,6 +416,8 @@ SYSCALL_DEFINE5(file_getattr, int, dfd, const char __user *, filename,
424416
}
425417

426418
error = vfs_fileattr_get(filepath.dentry, &fa);
419+
if (error == -ENOIOCTLCMD || error == -ENOTTY)
420+
error = -EOPNOTSUPP;
427421
if (error)
428422
return error;
429423

@@ -491,6 +485,8 @@ SYSCALL_DEFINE5(file_setattr, int, dfd, const char __user *, filename,
491485
if (!error) {
492486
error = vfs_fileattr_set(mnt_idmap(filepath.mnt),
493487
filepath.dentry, &fa);
488+
if (error == -ENOIOCTLCMD || error == -ENOTTY)
489+
error = -EOPNOTSUPP;
494490
mnt_drop_write(filepath.mnt);
495491
}
496492

fs/fuse/ioctl.c

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

539-
if (err == -ENOTTY)
540-
err = -EOPNOTSUPP;
541539
return err;
542540
}
543541

@@ -574,7 +572,5 @@ int fuse_fileattr_set(struct mnt_idmap *idmap,
574572
cleanup:
575573
fuse_priv_ioctl_cleanup(inode, ff);
576574

577-
if (err == -ENOTTY)
578-
err = -EOPNOTSUPP;
579575
return err;
580576
}

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 == -EOPNOTSUPP || err == -EINVAL)
181+
if (err == -ENOTTY || 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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,10 @@ int ovl_real_fileattr_get(const struct path *realpath, struct file_kattr *fa)
720720
if (err)
721721
return err;
722722

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

726729
int ovl_fileattr_get(struct dentry *dentry, struct file_kattr *fa)

0 commit comments

Comments
 (0)