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:
@@ -756,7 +756,8 @@ find_xattr_handler_prefix(const struct xattr_handler **handlers,
|
||||
return NULL;
|
||||
|
||||
for_each_xattr_handler(handlers, xah) {
|
||||
if (strncmp(xah->prefix, name, strlen(xah->prefix)) == 0)
|
||||
const char *prefix = xattr_prefix(xah);
|
||||
if (strncmp(prefix, name, strlen(prefix)) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -839,19 +840,16 @@ static int listxattr_filler(struct dir_context *ctx, const char *name,
|
||||
|
||||
handler = find_xattr_handler_prefix(b->dentry->d_sb->s_xattr,
|
||||
name);
|
||||
if (!handler) /* Unsupported xattr name */
|
||||
if (!handler /* Unsupported xattr name */ ||
|
||||
(handler->list && !handler->list(b->dentry)))
|
||||
return 0;
|
||||
size = namelen + 1;
|
||||
if (b->buf) {
|
||||
size = handler->list(handler, b->dentry,
|
||||
b->buf + b->pos, b->size, name,
|
||||
namelen);
|
||||
if (size > b->size)
|
||||
return -ERANGE;
|
||||
} else {
|
||||
size = handler->list(handler, b->dentry,
|
||||
NULL, 0, name, namelen);
|
||||
memcpy(b->buf + b->pos, name, namelen);
|
||||
b->buf[b->pos + namelen] = 0;
|
||||
}
|
||||
|
||||
b->pos += size;
|
||||
}
|
||||
return 0;
|
||||
|
@@ -186,10 +186,10 @@ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
|
||||
|
||||
switch (type) {
|
||||
case ACL_TYPE_ACCESS:
|
||||
name = POSIX_ACL_XATTR_ACCESS;
|
||||
name = XATTR_NAME_POSIX_ACL_ACCESS;
|
||||
break;
|
||||
case ACL_TYPE_DEFAULT:
|
||||
name = POSIX_ACL_XATTR_DEFAULT;
|
||||
name = XATTR_NAME_POSIX_ACL_DEFAULT;
|
||||
break;
|
||||
default:
|
||||
BUG();
|
||||
@@ -244,7 +244,7 @@ __reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
|
||||
|
||||
switch (type) {
|
||||
case ACL_TYPE_ACCESS:
|
||||
name = POSIX_ACL_XATTR_ACCESS;
|
||||
name = XATTR_NAME_POSIX_ACL_ACCESS;
|
||||
if (acl) {
|
||||
error = posix_acl_equiv_mode(acl, &inode->i_mode);
|
||||
if (error < 0)
|
||||
@@ -256,7 +256,7 @@ __reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
|
||||
}
|
||||
break;
|
||||
case ACL_TYPE_DEFAULT:
|
||||
name = POSIX_ACL_XATTR_DEFAULT;
|
||||
name = XATTR_NAME_POSIX_ACL_DEFAULT;
|
||||
if (!S_ISDIR(inode->i_mode))
|
||||
return acl ? -EACCES : 0;
|
||||
break;
|
||||
|
@@ -34,21 +34,9 @@ security_set(const struct xattr_handler *handler, struct dentry *dentry,
|
||||
return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags);
|
||||
}
|
||||
|
||||
static size_t security_list(const struct xattr_handler *handler,
|
||||
struct dentry *dentry, char *list, size_t list_len,
|
||||
const char *name, size_t namelen)
|
||||
static bool security_list(struct dentry *dentry)
|
||||
{
|
||||
const size_t len = namelen + 1;
|
||||
|
||||
if (IS_PRIVATE(d_inode(dentry)))
|
||||
return 0;
|
||||
|
||||
if (list && len <= list_len) {
|
||||
memcpy(list, name, namelen);
|
||||
list[namelen] = '\0';
|
||||
}
|
||||
|
||||
return len;
|
||||
return !IS_PRIVATE(d_inode(dentry));
|
||||
}
|
||||
|
||||
/* Initializes the security context for a new inode and returns the number
|
||||
|
@@ -33,20 +33,9 @@ trusted_set(const struct xattr_handler *handler, struct dentry *dentry,
|
||||
return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags);
|
||||
}
|
||||
|
||||
static size_t trusted_list(const struct xattr_handler *handler,
|
||||
struct dentry *dentry, char *list, size_t list_size,
|
||||
const char *name, size_t name_len)
|
||||
static bool trusted_list(struct dentry *dentry)
|
||||
{
|
||||
const size_t len = name_len + 1;
|
||||
|
||||
if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(d_inode(dentry)))
|
||||
return 0;
|
||||
|
||||
if (list && len <= list_size) {
|
||||
memcpy(list, name, name_len);
|
||||
list[name_len] = '\0';
|
||||
}
|
||||
return len;
|
||||
return capable(CAP_SYS_ADMIN) && !IS_PRIVATE(d_inode(dentry));
|
||||
}
|
||||
|
||||
const struct xattr_handler reiserfs_xattr_trusted_handler = {
|
||||
|
@@ -30,19 +30,9 @@ user_set(const struct xattr_handler *handler, struct dentry *dentry,
|
||||
return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags);
|
||||
}
|
||||
|
||||
static size_t user_list(const struct xattr_handler *handler,
|
||||
struct dentry *dentry, char *list, size_t list_size,
|
||||
const char *name, size_t name_len)
|
||||
static bool user_list(struct dentry *dentry)
|
||||
{
|
||||
const size_t len = name_len + 1;
|
||||
|
||||
if (!reiserfs_xattrs_user(dentry->d_sb))
|
||||
return 0;
|
||||
if (list && len <= list_size) {
|
||||
memcpy(list, name, name_len);
|
||||
list[name_len] = '\0';
|
||||
}
|
||||
return len;
|
||||
return reiserfs_xattrs_user(dentry->d_sb);
|
||||
}
|
||||
|
||||
const struct xattr_handler reiserfs_xattr_user_handler = {
|
||||
|
Reference in New Issue
Block a user