Skip to contentSkip to conversation

fuse: return -EOPNOTSUPP from ->fileattr_[gs]et() instead of -ENOTTY

PATCH In review Amir Goldstein 2 participants 3 messages Jul 1, 2025

Subsystems (3)
lore
Share & tools
lore

Amir Goldstein

author maintainer
#0 lore raw

PATCH 1/1 fuse: return -EOPNOTSUPP from ->fileattr_[gs]et() instead of -ENOTTY

As part of changing calling convenstion of ->fileattr_[gs]et() to return -EOPNOTSUPP and fix related overlayfs code.

Fixes 5b0a414d06c3 ("ovl: fix filattr copy-up failure")

---

Miklos,

As part of Andrey's work on the new file_[gs]etattr() syscalls, I noticed that we have this oddity in overlayfs copy up.

I think that overlayfs checks for -ENOTTY from the days that it called vfs_ioctl() and we do not need that anymore, so I'd rather move the conversion into fuse to align with the new vfs calling conventiions.

After the calling convention change, the conversion in ovl_real_fileattr_get() is going to go away, so I've asked Christian to apply this change with the file_[gs]etattr() syscalls series.

WDYT?

Thanks,
Amir.

 fs/fuse/ioctl.c        | 4 ++++
 fs/overlayfs/copy_up.c | 2 +-
 fs/overlayfs/inode.c   | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)
fs/fuse/ioctl.c +4 -0
index 2d9abf48828f..f2692f7d5932 100644
@@ -536,6 +536,8 @@ int fuse_fileattr_get(struct dentry *dentry, struct fileattr *fa)
 cleanup:
 	fuse_priv_ioctl_cleanup(inode, ff);
 
+	if (err == -ENOTTY)
+		err = -EOPNOTSUPP;
 	return err;
 }
 
@@ -572,5 +574,7 @@ int fuse_fileattr_set(struct mnt_idmap *idmap,
 cleanup:
 	fuse_priv_ioctl_cleanup(inode, ff);
 
+	if (err == -ENOTTY)
+		err = -EOPNOTSUPP;
 	return err;
 }
fs/overlayfs/copy_up.c +1 -1
index d7310fcf3888..2c646b7076d0 100644
@@ -178,7 +178,7 @@ static int ovl_copy_fileattr(struct inode *inode, const struct path *old,
 	err = ovl_real_fileattr_get(old, &oldfa);
 	if (err) {
 		/* Ntfs-3g returns -EINVAL for "no fileattr support" */
-		if (err == -ENOTTY || err == -EINVAL)
+		if (err == -EOPNOTSUPP || err == -EINVAL)
 			return 0;
 		pr_warn("failed to retrieve lower fileattr (%pd2, err=%i)\n",
 			old->dentry, err);
fs/overlayfs/inode.c +1 -1
index 6f0e15f86c21..92754749f316 100644
@@ -722,7 +722,7 @@ int ovl_real_fileattr_get(const struct path *realpath, struct fileattr *fa)
 
 	err = vfs_fileattr_get(realpath->dentry, fa);
 	if (err == -ENOIOCTLCMD)
-		err = -ENOTTY;
+		err = -EOPNOTSUPP;
 	return err;
 }
 
Signature · 1 line
2.43.0
maintainer
#1 lore raw

fs/overlayfs/inode.c int ovl_real_fileattr_get(const struct path *realpath, struct fileattr *fa) · line 725

Quoted 9 lines · Amir Goldstein

index 6f0e15f86c21..92754749f316 100644

fs/overlayfs/inode.c +1 -1
@@ -722,7 +722,7 @@ int ovl_real_fileattr_get(const struct path *realpath, struct fileattr *fa)
 
        err = vfs_fileattr_get(realpath->dentry, fa);
        if (err == -ENOIOCTLCMD)
-               err = -ENOTTY;
+               err = -EOPNOTSUPP;

This doesn't make sense, the Andrey's 4/6 patch made vfs_fileattr_get return EOPNOTSUPP instead of ENOIOCTLCMD. So why is it being checked here?

Thanks,
Miklos

author maintainer
#2 lore raw
Quoted 8 lines · Miklos Szeredi
Quoted 5 lines · Amir Goldstein

index 6f0e15f86c21..92754749f316 100644

fs/overlayfs/inode.c +0 -0
@@ -722,7 +722,7 @@ int ovl_real_fileattr_get(const struct path *realpath, struct fileattr *fa)
 
Quoted 8 lines

fs/overlayfs/inode.c int ovl_real_fileattr_get(const struct path *realpath, struct fileattr *fa) · line 725

Quoted 4 lines
fs/overlayfs/inode.c +1 -1
        err = vfs_fileattr_get(realpath->dentry, fa);
        if (err == -ENOIOCTLCMD)
-               err = -ENOTTY;
+               err = -EOPNOTSUPP;

This doesn't make sense, the Andrey's 4/6 patch made vfs_fileattr_get return EOPNOTSUPP instead of ENOIOCTLCMD. So why is it being checked here?

You are right.
I was trying to demonstrate the change in fuse/ovl independent of Ansrey's patch, but don't worry after squashing this patch, there is no remaining conversion in ovl_real_fileattr_get().

I verified that with Christian.

Thanks,
Amir.