mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-31 04:01:48 -04:00
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 <[email protected]> Signed-off-by: Al Viro <[email protected]>
This commit is contained in:
parent
1046cb1195
commit
764a5c6b1f
22 changed files with 113 additions and 335 deletions
20
fs/xattr.c
20
fs/xattr.c
|
|
@ -723,23 +723,25 @@ generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
|
|||
|
||||
if (!buffer) {
|
||||
for_each_xattr_handler(handlers, handler) {
|
||||
if (!handler->list)
|
||||
if (!handler->name ||
|
||||
(handler->list && !handler->list(dentry)))
|
||||
continue;
|
||||
size += handler->list(handler, dentry, NULL, 0,
|
||||
NULL, 0);
|
||||
size += strlen(handler->name) + 1;
|
||||
}
|
||||
} else {
|
||||
char *buf = buffer;
|
||||
size_t len;
|
||||
|
||||
for_each_xattr_handler(handlers, handler) {
|
||||
if (!handler->list)
|
||||
if (!handler->name ||
|
||||
(handler->list && !handler->list(dentry)))
|
||||
continue;
|
||||
size = handler->list(handler, dentry, buf, buffer_size,
|
||||
NULL, 0);
|
||||
if (size > buffer_size)
|
||||
len = strlen(handler->name);
|
||||
if (len + 1 > buffer_size)
|
||||
return -ERANGE;
|
||||
buf += size;
|
||||
buffer_size -= size;
|
||||
memcpy(buf, handler->name, len + 1);
|
||||
buf += len + 1;
|
||||
buffer_size -= len + 1;
|
||||
}
|
||||
size = buf - buffer;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue