Skip to content

Commit 29608d2

Browse files
Andreas GruenbacherAl Viro
Andreas Gruenbacher
authored and
Al Viro
committed
f2fs: xattr simplifications
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> Cc: Jaegeuk Kim <jaegeuk@kernel.org> Cc: Changman Lee <cm224.lee@samsung.com> Cc: Chao Yu <chao2.yu@samsung.com> Cc: linux-f2fs-devel@lists.sourceforge.net Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 0ddaf72 commit 29608d2

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

fs/f2fs/xattr.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,27 @@ static size_t f2fs_xattr_generic_list(const struct xattr_handler *handler,
3030
const char *name, size_t len)
3131
{
3232
struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb);
33-
int total_len, prefix_len = 0;
34-
const char *prefix = NULL;
33+
int total_len, prefix_len;
3534

3635
switch (handler->flags) {
3736
case F2FS_XATTR_INDEX_USER:
3837
if (!test_opt(sbi, XATTR_USER))
3938
return -EOPNOTSUPP;
40-
prefix = XATTR_USER_PREFIX;
41-
prefix_len = XATTR_USER_PREFIX_LEN;
4239
break;
4340
case F2FS_XATTR_INDEX_TRUSTED:
4441
if (!capable(CAP_SYS_ADMIN))
4542
return -EPERM;
46-
prefix = XATTR_TRUSTED_PREFIX;
47-
prefix_len = XATTR_TRUSTED_PREFIX_LEN;
4843
break;
4944
case F2FS_XATTR_INDEX_SECURITY:
50-
prefix = XATTR_SECURITY_PREFIX;
51-
prefix_len = XATTR_SECURITY_PREFIX_LEN;
5245
break;
5346
default:
5447
return -EINVAL;
5548
}
5649

50+
prefix_len = strlen(handler->prefix);
5751
total_len = prefix_len + len + 1;
5852
if (list && total_len <= list_size) {
59-
memcpy(list, prefix, prefix_len);
53+
memcpy(list, handler->prefix, prefix_len);
6054
memcpy(list + prefix_len, name, len);
6155
list[prefix_len + len] = '\0';
6256
}
@@ -123,9 +117,6 @@ static size_t f2fs_xattr_advise_list(const struct xattr_handler *handler,
123117
const char *xname = F2FS_SYSTEM_ADVISE_PREFIX;
124118
size_t size;
125119

126-
if (handler->flags != F2FS_XATTR_INDEX_ADVISE)
127-
return 0;
128-
129120
size = strlen(xname) + 1;
130121
if (list && size <= list_size)
131122
memcpy(list, xname, size);

0 commit comments

Comments
 (0)