xfs: fix reporting supported extra file attributes for statx()
authorLuis R. Rodriguez <mcgrof@kernel.org>
Fri, 1 Mar 2019 16:14:57 +0000 (08:14 -0800)
committerDarrick J. Wong <darrick.wong@oracle.com>
Fri, 1 Mar 2019 16:57:25 +0000 (08:57 -0800)
statx(2) notes that any attribute that is not indicated as supported by
stx_attributes_mask has no usable value. Commit 5f955f26f3d42d ("xfs: report
crtime and attribute flags to statx") added support for informing userspace
of extra file attributes but forgot to list these flags as supported
making reporting them rather useless for the pedantic userspace author.

$ git describe --contains 5f955f26f3d42d04aba65590a32eb70eedb7f37d
v4.11-rc6~5^2^2~2

Fixes: 5f955f26f3d42d ("xfs: report crtime and attribute flags to statx")
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
[darrick: add a comment reminding people to keep attributes_mask up to date]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
fs/xfs/xfs_iops.c

index 1efef69a7f1c3c97d95d6d8e6af9a65e014b49f8..74047bd0c1aeb44709ceae3ef779921778c4be0e 100644 (file)
@@ -531,6 +531,10 @@ xfs_vn_getattr(
                }
        }
 
                }
        }
 
+       /*
+        * Note: If you add another clause to set an attribute flag, please
+        * update attributes_mask below.
+        */
        if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
                stat->attributes |= STATX_ATTR_IMMUTABLE;
        if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
        if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
                stat->attributes |= STATX_ATTR_IMMUTABLE;
        if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
@@ -538,6 +542,10 @@ xfs_vn_getattr(
        if (ip->i_d.di_flags & XFS_DIFLAG_NODUMP)
                stat->attributes |= STATX_ATTR_NODUMP;
 
        if (ip->i_d.di_flags & XFS_DIFLAG_NODUMP)
                stat->attributes |= STATX_ATTR_NODUMP;
 
+       stat->attributes_mask |= (STATX_ATTR_IMMUTABLE |
+                                 STATX_ATTR_APPEND |
+                                 STATX_ATTR_NODUMP);
+
        switch (inode->i_mode & S_IFMT) {
        case S_IFBLK:
        case S_IFCHR:
        switch (inode->i_mode & S_IFMT) {
        case S_IFBLK:
        case S_IFCHR: