linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Gruenbacher <agruenba@redhat.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
	Christoph Hellwig <hch@infradead.org>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Jaegeuk Kim <jaegeuk@kernel.org>,
	Changman Lee <cm224.lee@samsung.com>,
	Chao Yu <chao2.yu@samsung.com>,
	linux-f2fs-devel@lists.sourceforge.net
Subject: [PATCH v2 7/7] f2fs: xattr simplifications
Date: Tue, 22 Sep 2015 14:26:52 +0200	[thread overview]
Message-ID: <1442924812-9384-8-git-send-email-agruenba@redhat.com> (raw)
In-Reply-To: <1442924812-9384-1-git-send-email-agruenba@redhat.com>

Now that the xattr handler is passed to the xattr handler operations, we
have access to the attribute name prefix, so simplify
f2fs_xattr_generic_list.

Also, f2fs_xattr_advise_list is only ever called for
f2fs_xattr_advise_handler; there is no need to double check for that.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
 fs/f2fs/xattr.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
index e643173..862368a 100644
--- a/fs/f2fs/xattr.c
+++ b/fs/f2fs/xattr.c
@@ -30,33 +30,27 @@ static size_t f2fs_xattr_generic_list(const struct xattr_handler *handler,
 		const char *name, size_t len)
 {
 	struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb);
-	int total_len, prefix_len = 0;
-	const char *prefix = NULL;
+	int total_len, prefix_len;
 
 	switch (handler->flags) {
 	case F2FS_XATTR_INDEX_USER:
 		if (!test_opt(sbi, XATTR_USER))
 			return -EOPNOTSUPP;
-		prefix = XATTR_USER_PREFIX;
-		prefix_len = XATTR_USER_PREFIX_LEN;
 		break;
 	case F2FS_XATTR_INDEX_TRUSTED:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
-		prefix = XATTR_TRUSTED_PREFIX;
-		prefix_len = XATTR_TRUSTED_PREFIX_LEN;
 		break;
 	case F2FS_XATTR_INDEX_SECURITY:
-		prefix = XATTR_SECURITY_PREFIX;
-		prefix_len = XATTR_SECURITY_PREFIX_LEN;
 		break;
 	default:
 		return -EINVAL;
 	}
 
+	prefix_len = strlen(handler->prefix);
 	total_len = prefix_len + len + 1;
 	if (list && total_len <= list_size) {
-		memcpy(list, prefix, prefix_len);
+		memcpy(list, handler->prefix, prefix_len);
 		memcpy(list + prefix_len, name, len);
 		list[prefix_len + len] = '\0';
 	}
@@ -123,9 +117,6 @@ static size_t f2fs_xattr_advise_list(const struct xattr_handler *handler,
 	const char *xname = F2FS_SYSTEM_ADVISE_PREFIX;
 	size_t size;
 
-	if (handler->flags != F2FS_XATTR_INDEX_ADVISE)
-		return 0;
-
 	size = strlen(xname) + 1;
 	if (list && size <= list_size)
 		memcpy(list, xname, size);
-- 
2.4.3


      parent reply	other threads:[~2015-09-22 12:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-22 12:26 [PATCH v2 0/7] Pass xattr handler to xattr handler operations Andreas Gruenbacher
2015-09-22 12:26 ` [PATCH v2 1/7] ubifs: Remove unused security xattr handler Andreas Gruenbacher
2015-09-22 12:41   ` Richard Weinberger
2015-09-22 12:47     ` Andreas Gruenbacher
2015-09-22 12:26 ` [PATCH v2 2/7] hfsplus: Remove unused xattr handler list operations Andreas Gruenbacher
2015-10-04  6:24   ` Christoph Hellwig
2015-09-22 12:26 ` [PATCH v2 3/7] jffs2: Add missing capability check for listing trusted xattrs Andreas Gruenbacher
2015-10-04  6:25   ` Christoph Hellwig
2015-09-22 12:26 ` [PATCH v2 4/7] xattr handlers: Pass handler to operations instead of flags Andreas Gruenbacher
2015-10-04  6:25   ` Christoph Hellwig
2015-09-22 12:26 ` [PATCH v2 5/7] 9p: xattr simplifications Andreas Gruenbacher
2015-10-04  6:27   ` Christoph Hellwig
2015-09-22 12:26 ` [PATCH v2 6/7] squashfs: " Andreas Gruenbacher
2015-10-04  6:29   ` Christoph Hellwig
2015-10-04 13:10     ` Andreas Grünbacher
2015-09-22 12:26 ` Andreas Gruenbacher [this message]

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=1442924812-9384-8-git-send-email-agruenba@redhat.com \
    --to=agruenba@redhat.com \
    --cc=chao2.yu@samsung.com \
    --cc=cm224.lee@samsung.com \
    --cc=hch@infradead.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.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).