[PATCH v2 3/4] xfs: allow setting xattrs on special files

Andrey Albershteyn
2024-05-20T16:46:47Z

As XFS didn't have ioctls for special files setting an inode
extended attributes was rejected for them in xfs_fileattr_set().
Same applies for reading.

With XFS's project quota directories this is necessary. When project
is setup, xfs_quota opens and calls FS_IOC_SETFSXATTR on every inode
in the directory. However, special files are skipped due to open()
returning a special inode for them. So, they don't even get to this
check.

The FS_IOC_FS[SET|GET]XATTRAT will call xfs_fileattr_set/get() on a
special file. Therefore, allow them to work on special inodes.

Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
fs/xfs/xfs_ioctl.c | 6 ------
1 file changed, 6 deletions(-)

diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index f0117188f302..adedfcd3fde5 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -459,9 +459,6 @@ xfs_fileattr_get(
{
struct xfs_inode *ip = XFS_I(d_inode(dentry));

- if (d_is_special(dentry))
- return -ENOTTY;
-
xfs_ilock(ip, XFS_ILOCK_SHARED);
xfs_fill_fsxattr(ip, XFS_DATA_FORK, fa);
xfs_iunlock(ip, XFS_ILOCK_SHARED);
@@ -736,9 +733,6 @@ xfs_fileattr_set(

trace_xfs_ioctl_setattr(ip);

- if (d_is_special(dentry))
- return -ENOTTY;
-
if (!fa->fsx_valid) {
if (fa->flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL |
FS_NOATIME_FL | FS_NODUMP_FL |
--
2.42.0