diff options
author | Andreas Gruenbacher <agruenba@redhat.com> | 2015-12-02 16:44:43 +0300 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-12-14 03:46:12 +0300 |
commit | 764a5c6b1fa4306dd7573c1d80914254909cd036 (patch) | |
tree | 6e5ceb636c3b53cdc0994cf8c2415656e2b12e82 /fs/ext4/xattr.c | |
parent | 1046cb119521b5e1881f380dc99729fc84c96661 (diff) | |
download | linux-764a5c6b1fa4306dd7573c1d80914254909cd036.tar.xz |
xattr handlers: Simplify list operation
Change the list operation to only return whether or not an attribute
should be listed. Copying the attribute names into the buffer is moved
to the callers.
Since the result only depends on the dentry and not on the attribute
name, we do not pass the attribute name to list operations.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ext4/xattr.c')
-rw-r--r-- | fs/ext4/xattr.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 6b6b3e751f8c..e9b9afdd1d96 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -404,19 +404,24 @@ ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry, const struct xattr_handler *handler = ext4_xattr_handler(entry->e_name_index); - if (handler) { - size_t size = handler->list(handler, dentry, buffer, - rest, entry->e_name, - entry->e_name_len); + if (handler && (!handler->list || handler->list(dentry))) { + const char *prefix = handler->prefix ?: handler->name; + size_t prefix_len = strlen(prefix); + size_t size = prefix_len + entry->e_name_len + 1; + if (buffer) { if (size > rest) return -ERANGE; - buffer += size; + memcpy(buffer, prefix, prefix_len); + buffer += prefix_len; + memcpy(buffer, entry->e_name, entry->e_name_len); + buffer += entry->e_name_len; + *buffer++ = 0; } rest -= size; } } - return buffer_size - rest; + return buffer_size - rest; /* total size */ } static int |