mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-31 04:01:48 -04:00
sanitize xattr handler prototypes
Add a flags argument to struct xattr_handler and pass it to all xattr handler methods. This allows using the same methods for multiple handlers, e.g. for the ACL methods which perform exactly the same action for the access and default ACLs, just using a different underlying attribute. With a little more groundwork it'll also allow sharing the methods for the regular user/trusted/secure handlers in extN, ocfs2 and jffs2 like it's already done for xfs in this patch. Also change the inode argument to the handlers to a dentry to allow using the handlers mechnism for filesystems that require it later, e.g. cifs. [with GFS2 bits updated by Steven Whitehouse <[email protected]>] Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: James Morris <[email protected]> Acked-by: Joel Becker <[email protected]> Signed-off-by: Al Viro <[email protected]>
This commit is contained in:
parent
ef26ca97e8
commit
431547b3c4
39 changed files with 533 additions and 815 deletions
28
fs/xattr.c
28
fs/xattr.c
|
|
@ -615,12 +615,11 @@ ssize_t
|
|||
generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size)
|
||||
{
|
||||
struct xattr_handler *handler;
|
||||
struct inode *inode = dentry->d_inode;
|
||||
|
||||
handler = xattr_resolve_name(inode->i_sb->s_xattr, &name);
|
||||
handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
|
||||
if (!handler)
|
||||
return -EOPNOTSUPP;
|
||||
return handler->get(inode, name, buffer, size);
|
||||
return handler->get(dentry, name, buffer, size, handler->flags);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -630,18 +629,20 @@ generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t s
|
|||
ssize_t
|
||||
generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
|
||||
{
|
||||
struct inode *inode = dentry->d_inode;
|
||||
struct xattr_handler *handler, **handlers = inode->i_sb->s_xattr;
|
||||
struct xattr_handler *handler, **handlers = dentry->d_sb->s_xattr;
|
||||
unsigned int size = 0;
|
||||
|
||||
if (!buffer) {
|
||||
for_each_xattr_handler(handlers, handler)
|
||||
size += handler->list(inode, NULL, 0, NULL, 0);
|
||||
for_each_xattr_handler(handlers, handler) {
|
||||
size += handler->list(dentry, NULL, 0, NULL, 0,
|
||||
handler->flags);
|
||||
}
|
||||
} else {
|
||||
char *buf = buffer;
|
||||
|
||||
for_each_xattr_handler(handlers, handler) {
|
||||
size = handler->list(inode, buf, buffer_size, NULL, 0);
|
||||
size = handler->list(dentry, buf, buffer_size,
|
||||
NULL, 0, handler->flags);
|
||||
if (size > buffer_size)
|
||||
return -ERANGE;
|
||||
buf += size;
|
||||
|
|
@ -659,14 +660,13 @@ int
|
|||
generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags)
|
||||
{
|
||||
struct xattr_handler *handler;
|
||||
struct inode *inode = dentry->d_inode;
|
||||
|
||||
if (size == 0)
|
||||
value = ""; /* empty EA, do not remove */
|
||||
handler = xattr_resolve_name(inode->i_sb->s_xattr, &name);
|
||||
handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
|
||||
if (!handler)
|
||||
return -EOPNOTSUPP;
|
||||
return handler->set(inode, name, value, size, flags);
|
||||
return handler->set(dentry, name, value, size, 0, handler->flags);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -677,12 +677,12 @@ int
|
|||
generic_removexattr(struct dentry *dentry, const char *name)
|
||||
{
|
||||
struct xattr_handler *handler;
|
||||
struct inode *inode = dentry->d_inode;
|
||||
|
||||
handler = xattr_resolve_name(inode->i_sb->s_xattr, &name);
|
||||
handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
|
||||
if (!handler)
|
||||
return -EOPNOTSUPP;
|
||||
return handler->set(inode, name, NULL, 0, XATTR_REPLACE);
|
||||
return handler->set(dentry, name, NULL, 0,
|
||||
XATTR_REPLACE, handler->flags);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(generic_getxattr);
|
||||
|
|
|
|||
Loading…
Reference in a new issue