Add fileattr_has_fsx_mask() as a helper to let filesystems check for unsupported xflags while allowing supported ones. Can be used in the same way as fileattr_has_fsx(). Also make fileattr_has_fsx() a wrapper around fileattr_has_fsx_mask(). Assisted-by: Gemini:3.8-flash-high antigravity-cli-1.4.7 Signed-off-by: koraynilay --- include/linux/fileattr.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/include/linux/fileattr.h b/include/linux/fileattr.h index 42b92ccdc583..ba7ed3b387d8 100644 --- a/include/linux/fileattr.h +++ b/include/linux/fileattr.h @@ -65,6 +65,23 @@ int copy_fsxattr_to_user(const struct file_kattr *fa, struct fsxattr __user *ufa void fileattr_fill_xflags(struct file_kattr *fa, u32 xflags); void fileattr_fill_flags(struct file_kattr *fa, u32 flags); +/** + * fileattr_has_fsx_mask - check for extended flags/attributes + * @fa: fileattr pointer + * @allowed_xflags_mask: additional xflags permitted + * + * Return: true if any attributes are present that are not represented in + * ->flags or @allowed_xflags_mask. + */ +static inline bool fileattr_has_fsx_mask(const struct file_kattr *fa, + u32 allowed_xflags_mask) +{ + return fa->fsx_valid && + ((fa->fsx_xflags & ~(FS_XFLAG_COMMON | allowed_xflags_mask)) || + fa->fsx_extsize != 0 || fa->fsx_projid != 0 || + fa->fsx_cowextsize != 0); +} + /** * fileattr_has_fsx - check for extended flags/attributes * @fa: fileattr pointer @@ -74,9 +91,7 @@ void fileattr_fill_flags(struct file_kattr *fa, u32 flags); */ static inline bool fileattr_has_fsx(const struct file_kattr *fa) { - return fa->fsx_valid && - ((fa->fsx_xflags & ~FS_XFLAG_COMMON) || fa->fsx_extsize != 0 || - fa->fsx_projid != 0 || fa->fsx_cowextsize != 0); + return fileattr_has_fsx_mask(fa, 0); } int vfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa); -- 2.56.0