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>
This commit is contained in:

committed by
Al Viro

parent
1046cb1195
commit
764a5c6b1f
@@ -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
|
||||
|
Reference in New Issue
Block a user