mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
Merge branch 'work.xattr' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs xattr updates from Al Viro: "Andreas' xattr cleanup series. It's a followup to his xattr work that went in last cycle; -0.5KLoC" * 'work.xattr' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: xattr handlers: Simplify list operation ocfs2: Replace list xattr handler operations nfs: Move call to security_inode_listsecurity into nfs_listxattr xfs: Change how listxattr generates synthetic attributes tmpfs: listxattr should include POSIX ACL xattrs tmpfs: Use xattr handler infrastructure btrfs: Use xattr handler infrastructure vfs: Distinguish between full xattr names and proper prefixes posix acls: Remove duplicate xattr name definitions gfs2: Remove gfs2_xattr_acl_chmod vfs: Remove vfs_xattr_cmp
This commit is contained in:
commit
ddf1d6238d
49 changed files with 516 additions and 1054 deletions
|
|
@ -52,9 +52,6 @@ static int jffs2_security_getxattr(const struct xattr_handler *handler,
|
|||
struct dentry *dentry, const char *name,
|
||||
void *buffer, size_t size)
|
||||
{
|
||||
if (!strcmp(name, ""))
|
||||
return -EINVAL;
|
||||
|
||||
return do_jffs2_getxattr(d_inode(dentry), JFFS2_XPREFIX_SECURITY,
|
||||
name, buffer, size);
|
||||
}
|
||||
|
|
@ -63,31 +60,12 @@ static int jffs2_security_setxattr(const struct xattr_handler *handler,
|
|||
struct dentry *dentry, const char *name,
|
||||
const void *buffer, size_t size, int flags)
|
||||
{
|
||||
if (!strcmp(name, ""))
|
||||
return -EINVAL;
|
||||
|
||||
return do_jffs2_setxattr(d_inode(dentry), JFFS2_XPREFIX_SECURITY,
|
||||
name, buffer, size, flags);
|
||||
}
|
||||
|
||||
static size_t jffs2_security_listxattr(const struct xattr_handler *handler,
|
||||
struct dentry *dentry, char *list,
|
||||
size_t list_size, const char *name,
|
||||
size_t name_len)
|
||||
{
|
||||
size_t retlen = XATTR_SECURITY_PREFIX_LEN + name_len + 1;
|
||||
|
||||
if (list && retlen <= list_size) {
|
||||
strcpy(list, XATTR_SECURITY_PREFIX);
|
||||
strcpy(list + XATTR_SECURITY_PREFIX_LEN, name);
|
||||
}
|
||||
|
||||
return retlen;
|
||||
}
|
||||
|
||||
const struct xattr_handler jffs2_security_xattr_handler = {
|
||||
.prefix = XATTR_SECURITY_PREFIX,
|
||||
.list = jffs2_security_listxattr,
|
||||
.set = jffs2_security_setxattr,
|
||||
.get = jffs2_security_getxattr
|
||||
};
|
||||
|
|
|
|||
|
|
@ -967,7 +967,8 @@ ssize_t jffs2_listxattr(struct dentry *dentry, char *buffer, size_t size)
|
|||
struct jffs2_xattr_ref *ref, **pref;
|
||||
struct jffs2_xattr_datum *xd;
|
||||
const struct xattr_handler *xhandle;
|
||||
ssize_t len, rc;
|
||||
const char *prefix;
|
||||
ssize_t prefix_len, len, rc;
|
||||
int retry = 0;
|
||||
|
||||
rc = check_xattr_ref_inode(c, ic);
|
||||
|
|
@ -998,18 +999,23 @@ ssize_t jffs2_listxattr(struct dentry *dentry, char *buffer, size_t size)
|
|||
}
|
||||
}
|
||||
xhandle = xprefix_to_handler(xd->xprefix);
|
||||
if (!xhandle)
|
||||
if (!xhandle || (xhandle->list && !xhandle->list(dentry)))
|
||||
continue;
|
||||
prefix = xhandle->prefix ?: xhandle->name;
|
||||
prefix_len = strlen(prefix);
|
||||
rc = prefix_len + xd->name_len + 1;
|
||||
|
||||
if (buffer) {
|
||||
rc = xhandle->list(xhandle, dentry, buffer + len,
|
||||
size - len, xd->xname,
|
||||
xd->name_len);
|
||||
} else {
|
||||
rc = xhandle->list(xhandle, dentry, NULL, 0,
|
||||
xd->xname, xd->name_len);
|
||||
if (rc > size - len) {
|
||||
rc = -ERANGE;
|
||||
goto out;
|
||||
}
|
||||
memcpy(buffer, prefix, prefix_len);
|
||||
buffer += prefix_len;
|
||||
memcpy(buffer, xd->xname, xd->name_len);
|
||||
buffer += xd->name_len;
|
||||
*buffer++ = 0;
|
||||
}
|
||||
if (rc < 0)
|
||||
goto out;
|
||||
len += rc;
|
||||
}
|
||||
rc = len;
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ static int jffs2_trusted_getxattr(const struct xattr_handler *handler,
|
|||
struct dentry *dentry, const char *name,
|
||||
void *buffer, size_t size)
|
||||
{
|
||||
if (!strcmp(name, ""))
|
||||
return -EINVAL;
|
||||
return do_jffs2_getxattr(d_inode(dentry), JFFS2_XPREFIX_TRUSTED,
|
||||
name, buffer, size);
|
||||
}
|
||||
|
|
@ -30,28 +28,13 @@ static int jffs2_trusted_setxattr(const struct xattr_handler *handler,
|
|||
struct dentry *dentry, const char *name,
|
||||
const void *buffer, size_t size, int flags)
|
||||
{
|
||||
if (!strcmp(name, ""))
|
||||
return -EINVAL;
|
||||
return do_jffs2_setxattr(d_inode(dentry), JFFS2_XPREFIX_TRUSTED,
|
||||
name, buffer, size, flags);
|
||||
}
|
||||
|
||||
static size_t jffs2_trusted_listxattr(const struct xattr_handler *handler,
|
||||
struct dentry *dentry, char *list,
|
||||
size_t list_size, const char *name,
|
||||
size_t name_len)
|
||||
static bool jffs2_trusted_listxattr(struct dentry *dentry)
|
||||
{
|
||||
size_t retlen = XATTR_TRUSTED_PREFIX_LEN + name_len + 1;
|
||||
|
||||
if (!capable(CAP_SYS_ADMIN))
|
||||
return 0;
|
||||
|
||||
if (list && retlen<=list_size) {
|
||||
strcpy(list, XATTR_TRUSTED_PREFIX);
|
||||
strcpy(list + XATTR_TRUSTED_PREFIX_LEN, name);
|
||||
}
|
||||
|
||||
return retlen;
|
||||
return capable(CAP_SYS_ADMIN);
|
||||
}
|
||||
|
||||
const struct xattr_handler jffs2_trusted_xattr_handler = {
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ static int jffs2_user_getxattr(const struct xattr_handler *handler,
|
|||
struct dentry *dentry, const char *name,
|
||||
void *buffer, size_t size)
|
||||
{
|
||||
if (!strcmp(name, ""))
|
||||
return -EINVAL;
|
||||
return do_jffs2_getxattr(d_inode(dentry), JFFS2_XPREFIX_USER,
|
||||
name, buffer, size);
|
||||
}
|
||||
|
|
@ -30,30 +28,12 @@ static int jffs2_user_setxattr(const struct xattr_handler *handler,
|
|||
struct dentry *dentry, const char *name,
|
||||
const void *buffer, size_t size, int flags)
|
||||
{
|
||||
if (!strcmp(name, ""))
|
||||
return -EINVAL;
|
||||
return do_jffs2_setxattr(d_inode(dentry), JFFS2_XPREFIX_USER,
|
||||
name, buffer, size, flags);
|
||||
}
|
||||
|
||||
static size_t jffs2_user_listxattr(const struct xattr_handler *handler,
|
||||
struct dentry *dentry, char *list,
|
||||
size_t list_size, const char *name,
|
||||
size_t name_len)
|
||||
{
|
||||
size_t retlen = XATTR_USER_PREFIX_LEN + name_len + 1;
|
||||
|
||||
if (list && retlen <= list_size) {
|
||||
strcpy(list, XATTR_USER_PREFIX);
|
||||
strcpy(list + XATTR_USER_PREFIX_LEN, name);
|
||||
}
|
||||
|
||||
return retlen;
|
||||
}
|
||||
|
||||
const struct xattr_handler jffs2_user_xattr_handler = {
|
||||
.prefix = XATTR_USER_PREFIX,
|
||||
.list = jffs2_user_listxattr,
|
||||
.set = jffs2_user_setxattr,
|
||||
.get = jffs2_user_getxattr
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue