diff options
author | Andreas Gruenbacher <agruenba@redhat.com> | 2015-12-02 14:44:43 +0100 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-12-13 19:46:12 -0500 |
commit | 764a5c6b1fa4306dd7573c1d80914254909cd036 (patch) | |
tree | 6e5ceb636c3b53cdc0994cf8c2415656e2b12e82 /fs/xattr.c | |
parent | 1046cb119521b5e1881f380dc99729fc84c96661 (diff) | |
download | linux-764a5c6b1fa4306dd7573c1d80914254909cd036.tar.gz linux-764a5c6b1fa4306dd7573c1d80914254909cd036.tar.bz2 linux-764a5c6b1fa4306dd7573c1d80914254909cd036.zip |
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/xattr.c')
-rw-r--r-- | fs/xattr.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/fs/xattr.c b/fs/xattr.c index 2c7776403aba..d7f5037a17b5 100644 --- a/fs/xattr.c +++ b/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; } |