linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: linux-fsdevel@vger.kernel.org, Christoph Hellwig <hch@lst.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	Seth Forshee <sforshee@kernel.org>,
	"Christian Brauner (Microsoft)" <brauner@kernel.org>
Subject: [PATCH v2 3/8] xattr: add listxattr helper
Date: Mon, 30 Jan 2023 17:41:59 +0100	[thread overview]
Message-ID: <20230125-fs-acl-remove-generic-xattr-handlers-v2-3-214cfb88bb56@kernel.org> (raw)
In-Reply-To: <20230125-fs-acl-remove-generic-xattr-handlers-v2-0-214cfb88bb56@kernel.org>

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.

Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
---
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 --git a/include/linux/xattr.h b/include/linux/xattr.h
index db022d6548fb..91d5b9de933a 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 {

-- 
2.34.1


  parent reply	other threads:[~2023-01-30 16:42 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-30 16:41 [PATCH v2 0/8] acl: remove generic posix acl handlers from all xattr handlers Christian Brauner
2023-01-30 16:41 ` [PATCH v2 1/8] fs: don't use IOP_XATTR for posix acls Christian Brauner
2023-01-30 16:50   ` Christoph Hellwig
2023-01-30 18:09     ` Christian Brauner
2023-01-31 11:36       ` Christian Brauner
2023-01-31 14:55         ` Christian Brauner
2023-01-31 15:18           ` Christoph Hellwig
2023-01-30 16:41 ` [PATCH v2 2/8] xattr: simplify listxattr helpers Christian Brauner
2023-01-30 16:51   ` Christoph Hellwig
2023-01-30 16:41 ` Christian Brauner [this message]
2023-01-30 16:51   ` [PATCH v2 3/8] xattr: add listxattr helper Christoph Hellwig
2023-01-30 16:42 ` [PATCH v2 4/8] xattr: remove unused argument Christian Brauner
2023-01-30 16:42 ` [PATCH v2 5/8] fs: drop unused posix acl handlers Christian Brauner
2023-01-30 16:42 ` [PATCH v2 6/8] fs: simplify ->listxattr() implementation Christian Brauner
2023-01-30 16:52   ` Christoph Hellwig
2023-01-30 16:42 ` [PATCH v2 7/8] reiserfs: rework " Christian Brauner
2023-01-30 16:42 ` [PATCH v2 8/8] fs: rename generic posix acl handlers Christian Brauner
2023-01-30 16:53   ` Christoph Hellwig
2023-04-26 23:07 ` [f2fs-dev] [PATCH v2 0/8] acl: remove generic posix acl handlers from all xattr handlers patchwork-bot+f2fs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230125-fs-acl-remove-generic-xattr-handlers-v2-3-214cfb88bb56@kernel.org \
    --to=brauner@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=sforshee@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).