diff mbox series

[v3,02/10] xattr: add listxattr helper

Message ID 20230125-fs-acl-remove-generic-xattr-handlers-v3-2-f760cc58967d@kernel.org (mailing list archive)
State New, archived
Headers show
Series acl: drop posix acl handlers from xattr handlers | expand

Commit Message

Christian Brauner Feb. 1, 2023, 1:14 p.m. UTC
Add a tiny helper to determine whether an xattr handler given a specific
dentry supports listing the requested xattr. We will use this helper in
various filesystems in later commits.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
---
Changes in v3:
  - Patch unchanged.

Changes in v2:
- Remove second helper after architectural changes in the series.
- Christoph Hellwig <hch@lst.de>:
  - Renamed helper to xattr_handler_can_list().
---
 include/linux/xattr.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/include/linux/xattr.h b/include/linux/xattr.h
index 74b7770880a7..39c496510a26 100644
--- a/include/linux/xattr.h
+++ b/include/linux/xattr.h
@@ -47,6 +47,22 @@  struct xattr_handler {
 		   size_t size, int flags);
 };
 
+/**
+ * xattr_handler_can_list - check whether xattr can be listed
+ * @handler: handler for this type of xattr
+ * @dentry: dentry whose inode xattr to list
+ *
+ * Determine whether the xattr associated with @dentry can be listed given
+ * @handler.
+ *
+ * Return: true if xattr can be listed, false if not.
+ */
+static inline bool xattr_handler_can_list(const struct xattr_handler *handler,
+					  struct dentry *dentry)
+{
+	return handler && (!handler->list || handler->list(dentry));
+}
+
 const char *xattr_full_name(const struct xattr_handler *, const char *);
 
 struct xattr {