Skip to content

Commit 2db8a94

Browse files
committed
xattr: add listxattr helper
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 <[email protected]> Signed-off-by: Christian Brauner (Microsoft) <[email protected]>
1 parent f2620f1 commit 2db8a94

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

include/linux/xattr.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ struct xattr_handler {
4747
size_t size, int flags);
4848
};
4949

50+
/**
51+
* xattr_handler_can_list - check whether xattr can be listed
52+
* @handler: handler for this type of xattr
53+
* @dentry: dentry whose inode xattr to list
54+
*
55+
* Determine whether the xattr associated with @dentry can be listed given
56+
* @handler.
57+
*
58+
* Return: true if xattr can be listed, false if not.
59+
*/
60+
static inline bool xattr_handler_can_list(const struct xattr_handler *handler,
61+
struct dentry *dentry)
62+
{
63+
return handler && (!handler->list || handler->list(dentry));
64+
}
65+
5066
const char *xattr_full_name(const struct xattr_handler *, const char *);
5167

5268
struct xattr {

0 commit comments

Comments
 (0)