[RFC PATCH v3 2/5] vfs: add fileattr_has_fsx_mask()
From: koraynilay
Date: Sat Oct 31 2026 - 21:58:30 EST
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 <koray.fra@xxxxxxxxx>
---
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 0b93f9609284..16acc61c9af1 100644
--- a/include/linux/fileattr.h
+++ b/include/linux/fileattr.h
@@ -64,6 +64,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
@@ -73,9 +90,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