Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <hch@lst.de>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>

+16
+16
include/linux/xattr.h
··· 47 47 size_t size, int flags); 48 48 }; 49 49 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 + 50 66 const char *xattr_full_name(const struct xattr_handler *, const char *); 51 67 52 68 struct xattr {