ANDROID: Add optional __get xattr method paired to __vfs_getxattr

Add an optional __get xattr method that would be called, if set, only
in __vfs_getxattr instead of the regular get xattr method.

Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Bug: 133515582
Bug: 136124883
Bug: 129319403
Change-Id: If9f6cf3e0d964e77af769244bb1e8f6aee4f4445
This commit is contained in:
Mark Salyzyn 2019-07-15 15:35:13 -07:00
parent aa4d6b3489
commit cf8d732342
2 changed files with 15 additions and 3 deletions

View File

@ -305,6 +305,9 @@ __vfs_getxattr(struct dentry *dentry, struct inode *inode, const char *name,
handler = xattr_resolve_name(inode, &name);
if (IS_ERR(handler))
return PTR_ERR(handler);
if (unlikely(handler->__get))
return handler->__get(handler, dentry, inode, name, value,
size);
if (!handler->get)
return -EOPNOTSUPP;
return handler->get(handler, dentry, inode, name, value, size);
@ -316,6 +319,7 @@ vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
{
struct inode *inode = dentry->d_inode;
int error;
const struct xattr_handler *handler;
error = xattr_permission(inode, name, MAY_READ);
if (error)
@ -338,7 +342,12 @@ vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
return ret;
}
nolsm:
return __vfs_getxattr(dentry, inode, name, value, size);
handler = xattr_resolve_name(inode, &name);
if (IS_ERR(handler))
return PTR_ERR(handler);
if (!handler->get)
return -EOPNOTSUPP;
return handler->get(handler, dentry, inode, name, value, size);
}
EXPORT_SYMBOL_GPL(vfs_getxattr);

View File

@ -30,10 +30,13 @@ struct xattr_handler {
const char *prefix;
int flags; /* fs private flags */
bool (*list)(struct dentry *dentry);
int (*get)(const struct xattr_handler *, struct dentry *dentry,
int (*get)(const struct xattr_handler *handler, struct dentry *dentry,
struct inode *inode, const char *name, void *buffer,
size_t size);
int (*set)(const struct xattr_handler *, struct dentry *dentry,
int (*__get)(const struct xattr_handler *handler, struct dentry *dentry,
struct inode *inode, const char *name, void *buffer,
size_t size);
int (*set)(const struct xattr_handler *handler, struct dentry *dentry,
struct inode *inode, const char *name, const void *buffer,
size_t size, int flags);
};