sanitize xattr handler prototypes
Subsystems (10)
PATCH 1/1 sanitize xattr handler prototypes
Add a flags argument to strcut 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.
fs/ext2/xattr.c +7 -4
@@ -60,6 +60,7 @@#include <linux/mbcache.h> #include <linux/quotaops.h> #include <linux/rwsem.h> +#include <linux/security.h> #include "ext2.h" #include "xattr.h" #include "acl.h"
@@ -249,8 +250,9 @@ cleanup:* used / required on success. */ static int -ext2_xattr_list (struct inode *inode,char *buffer,size_t buffer_size) +ext2_xattr_list (struct dentry *dentry,char *buffer,size_t buffer_size) { +struct inode *inode = dentry->d_inode;struct buffer_head *bh =NULL ;struct ext2_xattr_entry *entry;char *end;
@@ -300,9 +302,10 @@ bad_block: ext2_error(inode->i_sb, "ext2ext2_xattr_handler (entry->e_name_index);if (handler) { -size_t size = handler->list (inode, buffer, rest, +size_t size = handler->list (dentry, buffer, rest, entry->e_name, - entry->e_name_len); + entry->e_name_len, + handler->flags);if (buffer) {if (size > rest) { error = -ERANGE ;
@@ -330,7 +333,7 @@ cleanup:ssize_t ext2_listxattr (struct dentry *dentry,char *buffer,size_t size) { -return ext2_xattr_list (dentry->d_inode, buffer, size); +return ext2_xattr_list (dentry, buffer, size); }/*
fs/btrfs/acl.c +12 -35
85 lines not on this page · raw message
fs/ext2/acl.c +25 -54
138 lines not on this page · raw message
fs/ext3/acl.c +23 -51
127 lines not on this page · raw message
fs/ext4/acl.c +23 -51
127 lines not on this page · raw message
fs/jffs2/acl.c +22 -43
114 lines not on this page · raw message
fs/ocfs2/acl.c +25 -62
143 lines not on this page · raw message
fs/reiserfs/xattr.c +18 -18
@@ -49,6 +49,7 @@#include <linux/smp_lock.h> #include <linux/stat.h> #include <linux/quotaops.h> +#include <linux/security.h> #define PRIVROOT_NAME ".reiserfs_priv"#define XAROOT_NAME "xattrs"
@@ -727,15 +728,14 @@ ssize_t reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer, size_t size) { - struct inode *inode = dentry->d_inode; struct xattr_handler *handler; - handler =find_xattr_handler_prefix (inode->i_sb->s_xattr, name); + handler =find_xattr_handler_prefix (dentry->d_sb->s_xattr, name); -if (!handler ||get_inode_sd_version (inode) ==STAT_DATA_V1 ) +if (!handler ||get_inode_sd_version (dentry->d_inode) ==STAT_DATA_V1 )return -EOPNOTSUPP ; -return handler->get (inode, name, buffer, size); +return handler->get (dentry, name, buffer, size, handler->flags); }/*
@@ -747,15 +747,14 @@ int reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) { - struct inode *inode = dentry->d_inode; struct xattr_handler *handler; - handler =find_xattr_handler_prefix (inode->i_sb->s_xattr, name); + handler =find_xattr_handler_prefix (dentry->d_sb->s_xattr, name); -if (!handler ||get_inode_sd_version (inode) ==STAT_DATA_V1 ) +if (!handler ||get_inode_sd_version (dentry->d_inode) ==STAT_DATA_V1 )return -EOPNOTSUPP ; -return handler->set (inode, name, value, size, flags); +return handler->set (dentry, name, value, size, flags, handler->flags); }/*
@@ -765,21 +764,20 @@ reiserfs_setxattr(struct dentry *dentry,*/ int reiserfs_removexattr (struct dentry *dentry,const char *name) { -struct inode *inode = dentry->d_inode;struct xattr_handler *handler; - handler =find_xattr_handler_prefix (inode->i_sb->s_xattr, name); + handler =find_xattr_handler_prefix (dentry->d_sb->s_xattr, name); -if (!handler ||get_inode_sd_version (inode) ==STAT_DATA_V1 ) +if (!handler ||get_inode_sd_version (dentry->d_inode) ==STAT_DATA_V1 )return -EOPNOTSUPP ; -return handler->set (inode, name,NULL ,0 ,XATTR_REPLACE ); +return handler->set (dentry, name,NULL ,0 ,XATTR_REPLACE , handler->flags); }struct listxattr_buf {size_t size;size_t pos;char *buf; -struct inode *inode; +struct dentry *dentry; }; static int listxattr_filler(void *buf, const char *name, int namelen,
@@ -790,17 +788,19 @@ static int listxattr_filler(void *buf, cif (name[0 ] !='.' || (namelen !=1 && (name[1 ] !='.' || namelen !=2 ))) {struct xattr_handler *handler; - handler =find_xattr_handler_prefix (b->inode->i_sb->s_xattr, + handler =find_xattr_handler_prefix (b->dentry->d_sb->s_xattr, name);if (!handler)/* Unsupported xattr name */ return 0 ;if (b->buf) { - size = handler->list (b->inode, b->buf + b->pos, - b->size, name, namelen); + size = handler->list (b->dentry, b->buf + b->pos, + b->size, name, namelen, + handler->flags);if (size > b->size)return -ERANGE ; }else { - size = handler->list (b->inode,NULL ,0 , name, namelen); + size = handler->list (b->dentry,NULL ,0 , name, + namelen, handler->flags); } b->pos += size;
@@ -821,7 +821,7 @@ ssize_t reiserfs_listxattr(struct dentryint err =0 ;loff_t pos =0 ;struct listxattr_buf buf = { - .inode = dentry->d_inode, + .dentry = dentry, .buf = buffer, .size = buffer ? size :0 , };
fs/reiserfs/xattr_acl.c +19 -50
114 lines not on this page · raw message
fs/reiserfs/xattr_security.c +11 -10
@@ -8,36 +8,37 @@#include <asm/uaccess.h> static int -security_get (struct inode *inode,const char *name,void *buffer,size_t size) +security_get (struct dentry *dentry,const char *name,void *buffer,size_t size, +int handler_flags) {if (strlen (name) <sizeof (XATTR_SECURITY_PREFIX ))return -EINVAL ; -if (IS_PRIVATE (inode)) +if (IS_PRIVATE (dentry->d_inode))return -EPERM ; -return reiserfs_xattr_get (inode, name, buffer, size); +return reiserfs_xattr_get (dentry->d_inode, name, buffer, size); }static int -security_set (struct inode *inode,const char *name,const void *buffer, -size_t size,int flags) +security_set (struct dentry *dentry,const char *name,const void *buffer, +size_t size,int flags,int handler_flags) {if (strlen (name) <sizeof (XATTR_SECURITY_PREFIX ))return -EINVAL ; -if (IS_PRIVATE (inode)) +if (IS_PRIVATE (dentry->d_inode))return -EPERM ; -return reiserfs_xattr_set (inode, name, buffer, size, flags); +return reiserfs_xattr_set (dentry->d_inode, name, buffer, size, flags); } -static size_t security_list (struct inode *inode,char *list,size_t list_len, -const char *name,size_t namelen) +static size_t security_list (struct dentry *dentry,char *list,size_t list_len, +const char *name,size_t namelen,int handler_flags) {const size_t len = namelen +1 ; -if (IS_PRIVATE (inode)) +if (IS_PRIVATE (dentry->d_inode))return 0 ;if (list && len <= list_len) {
fs/reiserfs/xattr_trusted.c +11 -10
@@ -8,36 +8,37 @@#include <asm/uaccess.h> static int -trusted_get (struct inode *inode,const char *name,void *buffer,size_t size) +trusted_get (struct dentry *dentry,const char *name,void *buffer,size_t size, +int handler_flags) {if (strlen (name) <sizeof (XATTR_TRUSTED_PREFIX ))return -EINVAL ; -if (!capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (inode)) +if (!capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (dentry->d_inode))return -EPERM ; -return reiserfs_xattr_get (inode, name, buffer, size); +return reiserfs_xattr_get (dentry->d_inode, name, buffer, size); }static int -trusted_set (struct inode *inode,const char *name,const void *buffer, -size_t size,int flags) +trusted_set (struct dentry *dentry,const char *name,const void *buffer, +size_t size,int flags,int handler_flags) {if (strlen (name) <sizeof (XATTR_TRUSTED_PREFIX ))return -EINVAL ; -if (!capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (inode)) +if (!capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (dentry->d_inode))return -EPERM ; -return reiserfs_xattr_set (inode, name, buffer, size, flags); +return reiserfs_xattr_set (dentry->d_inode, name, buffer, size, flags); } -static size_t trusted_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +static size_t trusted_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int handler_flags) {const size_t len = name_len +1 ; -if (!capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (inode)) +if (!capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (dentry->d_inode))return 0 ;if (list && len <= list_size) {
fs/reiserfs/xattr_user.c +11 -10
@@ -7,34 +7,35 @@#include <asm/uaccess.h> static int -user_get (struct inode *inode,const char *name,void *buffer,size_t size) +user_get (struct dentry *dentry,const char *name,void *buffer,size_t size, +int handler_flags) {if (strlen (name) <sizeof (XATTR_USER_PREFIX ))return -EINVAL ; -if (!reiserfs_xattrs_user (inode->i_sb)) +if (!reiserfs_xattrs_user (dentry->d_sb))return -EOPNOTSUPP ; -return reiserfs_xattr_get (inode, name, buffer, size); +return reiserfs_xattr_get (dentry->d_inode, name, buffer, size); }static int -user_set (struct inode *inode,const char *name,const void *buffer, -size_t size,int flags) +user_set (struct dentry *dentry,const char *name,const void *buffer, +size_t size,int flags,int handler_flags) {if (strlen (name) <sizeof (XATTR_USER_PREFIX ))return -EINVAL ; -if (!reiserfs_xattrs_user (inode->i_sb)) +if (!reiserfs_xattrs_user (dentry->d_sb))return -EOPNOTSUPP ; -return reiserfs_xattr_set (inode, name, buffer, size, flags); +return reiserfs_xattr_set (dentry->d_inode, name, buffer, size, flags); } -static size_t user_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +static size_t user_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int handler_flags) {const size_t len = name_len +1 ; -if (!reiserfs_xattrs_user (inode->i_sb)) +if (!reiserfs_xattrs_user (dentry->d_sb))return 0 ;if (list && len <= list_size) {memcpy (list, name, name_len);
fs/xattr.c +14 -14
@@ -586,12 +586,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); }/*
@@ -601,18 +600,20 @@ generic_getxattr(struct dentry *dentry,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;
@@ -630,14 +631,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); }/*
@@ -648,12 +648,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);
fs/xfs/linux-2.6/xfs_acl.c +18 -35
78 lines not on this page · raw message
fs/xfs/linux-2.6/xfs_xattr.c +15 -56
110 lines not on this page · raw message
fs/xfs/xfs_acl.h +2 -1
@@ -49,7 +49,8 @@ extern int xfs_acl_chmod(struct inode *iextern int posix_acl_access_exists (struct inode *inode);extern int posix_acl_default_exists (struct inode *inode); -extern struct xattr_handler xfs_xattr_system_handler; +extern struct xattr_handler xfs_xattr_acl_access_handler; +extern struct xattr_handler xfs_xattr_acl_default_handler;#else # define xfs_check_acl NULL# define xfs_get_acl (inode, type) NULL
include/linux/xattr.h +7 -6
@@ -38,12 +38,13 @@ struct dentry;struct xattr_handler {char *prefix; -size_t (*list)(struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len); -int (*get)(struct inode *inode,const char *name,void *buffer, -size_t size); -int (*set)(struct inode *inode,const char *name,const void *buffer, -size_t size,int flags); +int flags;/* fs private flags passed back to the handlers */ +size_t (*list)(struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int handler_flags); +int (*get)(struct dentry *dentry,const char *name,void *buffer, +size_t size,int handler_flags); +int (*set)(struct dentry *dentry,const char *name,const void *buffer, +size_t size,int flags,int handler_flags); };ssize_t xattr_getsecurity (struct inode *,const char *,void *,size_t );
mm/shmem.c +10 -9
@@ -2032,27 +2032,28 @@ static const struct inode_operations shm* filesystem level, though. */ -static size_t shmem_xattr_security_list (struct inode *inode,char *list, +static size_t shmem_xattr_security_list (struct dentry *dentry,char *list,size_t list_len,const char *name, -size_t name_len) +size_t name_len,int handler_flags) { -return security_inode_listsecurity (inode, list, list_len); +return security_inode_listsecurity (dentry->d_inode, list, list_len); } -static int shmem_xattr_security_get (struct inode *inode,const char *name, -void *buffer,size_t size) +static int shmem_xattr_security_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int handler_flags) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return xattr_getsecurity (inode, name, buffer, size); +return xattr_getsecurity (dentry->d_inode, name, buffer, size); } -static int shmem_xattr_security_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +static int shmem_xattr_security_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int handler_flags) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return security_inode_setsecurity (inode, name, value, size, flags); +return security_inode_setsecurity (dentry->d_inode, name, value, + size, flags); }static struct xattr_handler shmem_xattr_security_handler = {
mm/shmem_acl.c +20 -58
106 lines not on this page · raw message
fs/jffs2/security.c +10 -8
@@ -44,26 +44,28 @@ int jffs2_init_security(struct inode *in }/* ---- XATTR Handler for "security.*" ----------------- */ -static int jffs2_security_getxattr (struct inode *inode,const char *name, -void *buffer,size_t size) +static int jffs2_security_getxattr (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (!strcmp (name,"" ))return -EINVAL ; -return do_jffs2_getxattr (inode,JFFS2_XPREFIX_SECURITY , name, buffer, size); +return do_jffs2_getxattr (dentry->d_inode,JFFS2_XPREFIX_SECURITY , + name, buffer, size); } -static int jffs2_security_setxattr (struct inode *inode,const char *name,const void *buffer, -size_t size,int flags) +static int jffs2_security_setxattr (struct dentry *dentry,const char *name, +const void *buffer,size_t size,int flags,int type) {if (!strcmp (name,"" ))return -EINVAL ; -return do_jffs2_setxattr (inode,JFFS2_XPREFIX_SECURITY , name, buffer, size, flags); +return do_jffs2_setxattr (dentry->d_inode,JFFS2_XPREFIX_SECURITY , + name, buffer, size, flags); } -static size_t jffs2_security_listxattr (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +static size_t jffs2_security_listxattr (struct dentry *dentry,char *list, +size_t list_size,const char *name,size_t name_len,int type) {size_t retlen =XATTR_SECURITY_PREFIX_LEN + name_len +1 ;
fs/jffs2/xattr.c +4 -2
@@ -990,9 +990,11 @@ ssize_t jffs2_listxattr(struct dentry *dif (!xhandle)continue ;if (buffer) { - rc = xhandle->list (inode, buffer+len, size-len, xd->xname, xd->name_len); + rc = xhandle->list (dentry, buffer+len, size-len, + xd->xname, xd->name_len, xd->flags); }else { - rc = xhandle->list (inode,NULL ,0 , xd->xname, xd->name_len); + rc = xhandle->list (dentry,NULL ,0 , xd->xname, + xd->name_len, xd->flags); }if (rc <0 ) goto out;
fs/jffs2/xattr_trusted.c +10 -8
@@ -16,24 +16,26 @@#include <linux/mtd/mtd.h> #include "nodelist.h" -static int jffs2_trusted_getxattr (struct inode *inode,const char *name, -void *buffer,size_t size) +static int jffs2_trusted_getxattr (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (!strcmp (name,"" ))return -EINVAL ; -return do_jffs2_getxattr (inode,JFFS2_XPREFIX_TRUSTED , name, buffer, size); +return do_jffs2_getxattr (dentry->d_inode,JFFS2_XPREFIX_TRUSTED , + name, buffer, size); } -static int jffs2_trusted_setxattr (struct inode *inode,const char *name,const void *buffer, -size_t size,int flags) +static int jffs2_trusted_setxattr (struct dentry *dentry,const char *name, +const void *buffer,size_t size,int flags,int type) {if (!strcmp (name,"" ))return -EINVAL ; -return do_jffs2_setxattr (inode,JFFS2_XPREFIX_TRUSTED , name, buffer, size, flags); +return do_jffs2_setxattr (dentry->d_inode,JFFS2_XPREFIX_TRUSTED , + name, buffer, size, flags); } -static size_t jffs2_trusted_listxattr (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +static size_t jffs2_trusted_listxattr (struct dentry *dentry,char *list, +size_t list_size,const char *name,size_t name_len,int type) {size_t retlen =XATTR_TRUSTED_PREFIX_LEN + name_len +1 ;
fs/jffs2/xattr_user.c +10 -8
@@ -16,24 +16,26 @@#include <linux/mtd/mtd.h> #include "nodelist.h" -static int jffs2_user_getxattr (struct inode *inode,const char *name, -void *buffer,size_t size) +static int jffs2_user_getxattr (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (!strcmp (name,"" ))return -EINVAL ; -return do_jffs2_getxattr (inode,JFFS2_XPREFIX_USER , name, buffer, size); +return do_jffs2_getxattr (dentry->d_inode,JFFS2_XPREFIX_USER , + name, buffer, size); } -static int jffs2_user_setxattr (struct inode *inode,const char *name,const void *buffer, -size_t size,int flags) +static int jffs2_user_setxattr (struct dentry *dentry,const char *name, +const void *buffer,size_t size,int flags,int type) {if (!strcmp (name,"" ))return -EINVAL ; -return do_jffs2_setxattr (inode,JFFS2_XPREFIX_USER , name, buffer, size, flags); +return do_jffs2_setxattr (dentry->d_inode,JFFS2_XPREFIX_USER , + name, buffer, size, flags); } -static size_t jffs2_user_listxattr (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +static size_t jffs2_user_listxattr (struct dentry *dentry,char *list, +size_t list_size,const char *name,size_t name_len,int type) {size_t retlen =XATTR_USER_PREFIX_LEN + name_len +1 ;
fs/ocfs2/xattr.c +32 -32
140 lines not on this page · raw message
fs/ext2/xattr_security.c +8 -8
@@ -11,8 +11,8 @@#include "xattr.h" static size_t -ext2_xattr_security_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext2_xattr_security_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const int prefix_len =XATTR_SECURITY_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ;
@@ -26,22 +26,22 @@ ext2_xattr_security_list(struct inode *i }static int -ext2_xattr_security_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext2_xattr_security_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext2_xattr_get (inode,EXT2_XATTR_INDEX_SECURITY , name, +return ext2_xattr_get (dentry->d_inode,EXT2_XATTR_INDEX_SECURITY , name, buffer, size); }static int -ext2_xattr_security_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext2_xattr_security_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext2_xattr_set (inode,EXT2_XATTR_INDEX_SECURITY , name, +return ext2_xattr_set (dentry->d_inode,EXT2_XATTR_INDEX_SECURITY , name, value, size, flags); }
fs/ext2/xattr_trusted.c +8 -8
@@ -13,8 +13,8 @@#include "xattr.h" static size_t -ext2_xattr_trusted_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext2_xattr_trusted_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const int prefix_len =XATTR_TRUSTED_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ;
@@ -31,22 +31,22 @@ ext2_xattr_trusted_list(struct inode *in }static int -ext2_xattr_trusted_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext2_xattr_trusted_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext2_xattr_get (inode,EXT2_XATTR_INDEX_TRUSTED , name, +return ext2_xattr_get (dentry->d_inode,EXT2_XATTR_INDEX_TRUSTED , name, buffer, size); }static int -ext2_xattr_trusted_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext2_xattr_trusted_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext2_xattr_set (inode,EXT2_XATTR_INDEX_TRUSTED , name, +return ext2_xattr_set (dentry->d_inode,EXT2_XATTR_INDEX_TRUSTED , name, value, size, flags); }
fs/ext2/xattr_user.c +13 -12
@@ -12,13 +12,13 @@#include "xattr.h" static size_t -ext2_xattr_user_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext2_xattr_user_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const size_t prefix_len =XATTR_USER_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return 0 ;if (list && total_len <= list_size) {
@@ -30,27 +30,28 @@ ext2_xattr_user_list(struct inode *inode }static int -ext2_xattr_user_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext2_xattr_user_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return -EOPNOTSUPP ; -return ext2_xattr_get (inode,EXT2_XATTR_INDEX_USER , name, buffer, size); +return ext2_xattr_get (dentry->d_inode,EXT2_XATTR_INDEX_USER , + name, buffer, size); }static int -ext2_xattr_user_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext2_xattr_user_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return -EOPNOTSUPP ; -return ext2_xattr_set (inode,EXT2_XATTR_INDEX_USER , name, - value, size, flags); +return ext2_xattr_set (dentry->d_inode,EXT2_XATTR_INDEX_USER , + name, value, size, flags); }struct xattr_handler ext2_xattr_user_handler = {
fs/ext3/xattr.c +17 -14
@@ -99,7 +99,7 @@ static struct buffer_head *ext3_xattr_ca struct mb_cache_entry **);static void ext3_xattr_rehash (struct ext3_xattr_header *,struct ext3_xattr_entry *); -static int ext3_xattr_list (struct inode *inode,char *buffer, +static int ext3_xattr_list (struct dentry *dentry,char *buffer,size_t buffer_size);static struct mb_cache *ext3_xattr_cache;
@@ -147,7 +147,7 @@ ext3_xattr_handler(int name_index)ssize_t ext3_listxattr (struct dentry *dentry,char *buffer,size_t size) { -return ext3_xattr_list (dentry->d_inode, buffer, size); +return ext3_xattr_list (dentry, buffer, size); } static int
@@ -332,7 +332,7 @@ ext3_xattr_get(struct inode *inode, int }static int -ext3_xattr_list_entries (struct inode *inode,struct ext3_xattr_entry *entry, +ext3_xattr_list_entries (struct dentry *dentry,struct ext3_xattr_entry *entry,char *buffer,size_t buffer_size) {size_t rest = buffer_size;
@@ -342,9 +342,10 @@ ext3_xattr_list_entries(struct inode *inext3_xattr_handler (entry->e_name_index);if (handler) { -size_t size = handler->list (inode, buffer, rest, +size_t size = handler->list (dentry, buffer, rest, entry->e_name, - entry->e_name_len); + entry->e_name_len, + handler->flags);if (buffer) {if (size > rest)return -ERANGE ;
@@ -357,8 +358,9 @@ ext3_xattr_list_entries(struct inode *in }static int -ext3_xattr_block_list (struct inode *inode,char *buffer,size_t buffer_size) +ext3_xattr_block_list (struct dentry *dentry,char *buffer,size_t buffer_size) { +struct inode *inode = dentry->d_inode;struct buffer_head *bh =NULL ;int error;
@@ -383,7 +385,7 @@ ext3_xattr_block_list(struct inode *inod goto cleanup; }ext3_xattr_cache_insert (bh); - error =ext3_xattr_list_entries (inode,BFIRST (bh), buffer, buffer_size); + error =ext3_xattr_list_entries (dentry,BFIRST (bh), buffer, buffer_size); cleanup:brelse (bh);
@@ -392,8 +394,9 @@ cleanup: }static int -ext3_xattr_ibody_list (struct inode *inode,char *buffer,size_t buffer_size) +ext3_xattr_ibody_list (struct dentry *dentry,char *buffer,size_t buffer_size) { +struct inode *inode = dentry->d_inode;struct ext3_xattr_ibody_header *header;struct ext3_inode *raw_inode;struct ext3_iloc iloc;
@@ -411,7 +414,7 @@ ext3_xattr_ibody_list(struct inode *inod error =ext3_xattr_check_names (IFIRST (header), end);if (error) goto cleanup; - error =ext3_xattr_list_entries (inode,IFIRST (header), + error =ext3_xattr_list_entries (dentry,IFIRST (header), buffer, buffer_size); cleanup:
@@ -430,12 +433,12 @@ cleanup:* used / required on success. */ static int -ext3_xattr_list (struct inode *inode,char *buffer,size_t buffer_size) +ext3_xattr_list (struct dentry *dentry,char *buffer,size_t buffer_size) {int i_error, b_error; -down_read (&EXT3_I (inode)->xattr_sem); - i_error =ext3_xattr_ibody_list (inode, buffer, buffer_size); +down_read (&EXT3_I (dentry->d_inode)->xattr_sem); + i_error =ext3_xattr_ibody_list (dentry, buffer, buffer_size);if (i_error <0 ) { b_error =0 ; }else {
@@ -443,11 +446,11 @@ ext3_xattr_list(struct inode *inode, cha buffer += i_error; buffer_size -= i_error; } - b_error =ext3_xattr_block_list (inode, buffer, buffer_size); + b_error =ext3_xattr_block_list (dentry, buffer, buffer_size);if (b_error <0 ) i_error =0 ; } -up_read (&EXT3_I (inode)->xattr_sem); +up_read (&EXT3_I (dentry->d_inode)->xattr_sem);return i_error + b_error; }
fs/ext3/xattr_security.c +10 -10
@@ -12,8 +12,8 @@#include "xattr.h" static size_t -ext3_xattr_security_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext3_xattr_security_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const size_t prefix_len =XATTR_SECURITY_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ;
@@ -28,23 +28,23 @@ ext3_xattr_security_list(struct inode *i }static int -ext3_xattr_security_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext3_xattr_security_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext3_xattr_get (inode,EXT3_XATTR_INDEX_SECURITY , name, - buffer, size); +return ext3_xattr_get (dentry->d_inode,EXT3_XATTR_INDEX_SECURITY , + name, buffer, size); }static int -ext3_xattr_security_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext3_xattr_security_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext3_xattr_set (inode,EXT3_XATTR_INDEX_SECURITY , name, - value, size, flags); +return ext3_xattr_set (dentry->d_inode,EXT3_XATTR_INDEX_SECURITY , + name, value, size, flags); }int
fs/ext3/xattr_trusted.c +9 -9
@@ -14,8 +14,8 @@#include "xattr.h" static size_t -ext3_xattr_trusted_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext3_xattr_trusted_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const size_t prefix_len =XATTR_TRUSTED_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ;
@@ -32,22 +32,22 @@ ext3_xattr_trusted_list(struct inode *in }static int -ext3_xattr_trusted_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext3_xattr_trusted_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext3_xattr_get (inode,EXT3_XATTR_INDEX_TRUSTED , name, - buffer, size); +return ext3_xattr_get (dentry->d_inode,EXT3_XATTR_INDEX_TRUSTED , + name, buffer, size); }static int -ext3_xattr_trusted_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext3_xattr_trusted_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext3_xattr_set (inode,EXT3_XATTR_INDEX_TRUSTED , name, +return ext3_xattr_set (dentry->d_inode,EXT3_XATTR_INDEX_TRUSTED , name, value, size, flags); }
fs/ext3/xattr_user.c +13 -12
@@ -13,13 +13,13 @@#include "xattr.h" static size_t -ext3_xattr_user_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext3_xattr_user_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const size_t prefix_len =XATTR_USER_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return 0 ;if (list && total_len <= list_size) {
@@ -31,26 +31,27 @@ ext3_xattr_user_list(struct inode *inode }static int -ext3_xattr_user_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext3_xattr_user_get (struct dentry *dentry,const char *name,void *buffer, +size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return -EOPNOTSUPP ; -return ext3_xattr_get (inode,EXT3_XATTR_INDEX_USER , name, buffer, size); +return ext3_xattr_get (dentry->d_inode,EXT3_XATTR_INDEX_USER , + name, buffer, size); }static int -ext3_xattr_user_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext3_xattr_user_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return -EOPNOTSUPP ; -return ext3_xattr_set (inode,EXT3_XATTR_INDEX_USER , name, - value, size, flags); +return ext3_xattr_set (dentry->d_inode,EXT3_XATTR_INDEX_USER , + name, value, size, flags); }struct xattr_handler ext3_xattr_user_handler = {
fs/ext4/xattr.c +17 -14
@@ -92,7 +92,7 @@ static struct buffer_head *ext4_xattr_ca struct mb_cache_entry **);static void ext4_xattr_rehash (struct ext4_xattr_header *,struct ext4_xattr_entry *); -static int ext4_xattr_list (struct inode *inode,char *buffer, +static int ext4_xattr_list (struct dentry *dentry,char *buffer,size_t buffer_size);static struct mb_cache *ext4_xattr_cache;
@@ -140,7 +140,7 @@ ext4_xattr_handler(int name_index)ssize_t ext4_listxattr (struct dentry *dentry,char *buffer,size_t size) { -return ext4_xattr_list (dentry->d_inode, buffer, size); +return ext4_xattr_list (dentry, buffer, size); } static int
@@ -325,7 +325,7 @@ ext4_xattr_get(struct inode *inode, int }static int -ext4_xattr_list_entries (struct inode *inode,struct ext4_xattr_entry *entry, +ext4_xattr_list_entries (struct dentry *dentry,struct ext4_xattr_entry *entry,char *buffer,size_t buffer_size) {size_t rest = buffer_size;
@@ -335,9 +335,10 @@ ext4_xattr_list_entries(struct inode *inext4_xattr_handler (entry->e_name_index);if (handler) { -size_t size = handler->list (inode, buffer, rest, +size_t size = handler->list (dentry, buffer, rest, entry->e_name, - entry->e_name_len); + entry->e_name_len, + handler->flags);if (buffer) {if (size > rest)return -ERANGE ;
@@ -350,8 +351,9 @@ ext4_xattr_list_entries(struct inode *in }static int -ext4_xattr_block_list (struct inode *inode,char *buffer,size_t buffer_size) +ext4_xattr_block_list (struct dentry *dentry,char *buffer,size_t buffer_size) { +struct inode *inode = dentry->d_inode;struct buffer_head *bh =NULL ;int error;
@@ -376,7 +378,7 @@ ext4_xattr_block_list(struct inode *inod goto cleanup; }ext4_xattr_cache_insert (bh); - error =ext4_xattr_list_entries (inode,BFIRST (bh), buffer, buffer_size); + error =ext4_xattr_list_entries (dentry,BFIRST (bh), buffer, buffer_size); cleanup:brelse (bh);
@@ -385,8 +387,9 @@ cleanup: }static int -ext4_xattr_ibody_list (struct inode *inode,char *buffer,size_t buffer_size) +ext4_xattr_ibody_list (struct dentry *dentry,char *buffer,size_t buffer_size) { +struct inode *inode = dentry->d_inode;struct ext4_xattr_ibody_header *header;struct ext4_inode *raw_inode;struct ext4_iloc iloc;
@@ -404,7 +407,7 @@ ext4_xattr_ibody_list(struct inode *inod error =ext4_xattr_check_names (IFIRST (header), end);if (error) goto cleanup; - error =ext4_xattr_list_entries (inode,IFIRST (header), + error =ext4_xattr_list_entries (dentry,IFIRST (header), buffer, buffer_size); cleanup:
@@ -423,12 +426,12 @@ cleanup:* used / required on success. */ static int -ext4_xattr_list (struct inode *inode,char *buffer,size_t buffer_size) +ext4_xattr_list (struct dentry *dentry,char *buffer,size_t buffer_size) {int i_error, b_error; -down_read (&EXT4_I (inode)->xattr_sem); - i_error =ext4_xattr_ibody_list (inode, buffer, buffer_size); +down_read (&EXT4_I (dentry->d_inode)->xattr_sem); + i_error =ext4_xattr_ibody_list (dentry, buffer, buffer_size);if (i_error <0 ) { b_error =0 ; }else {
@@ -436,11 +439,11 @@ ext4_xattr_list(struct inode *inode, cha buffer += i_error; buffer_size -= i_error; } - b_error =ext4_xattr_block_list (inode, buffer, buffer_size); + b_error =ext4_xattr_block_list (dentry, buffer, buffer_size);if (b_error <0 ) i_error =0 ; } -up_read (&EXT4_I (inode)->xattr_sem); +up_read (&EXT4_I (dentry->d_inode)->xattr_sem);return i_error + b_error; }
fs/ext4/xattr_security.c +10 -10
@@ -12,8 +12,8 @@#include "xattr.h" static size_t -ext4_xattr_security_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext4_xattr_security_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const size_t prefix_len =sizeof (XATTR_SECURITY_PREFIX )-1 ;const size_t total_len = prefix_len + name_len +1 ;
@@ -28,23 +28,23 @@ ext4_xattr_security_list(struct inode *i }static int -ext4_xattr_security_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext4_xattr_security_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext4_xattr_get (inode,EXT4_XATTR_INDEX_SECURITY , name, - buffer, size); +return ext4_xattr_get (dentry->d_inode,EXT4_XATTR_INDEX_SECURITY , + name, buffer, size); }static int -ext4_xattr_security_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext4_xattr_security_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext4_xattr_set (inode,EXT4_XATTR_INDEX_SECURITY , name, - value, size, flags); +return ext4_xattr_set (dentry->d_inode,EXT4_XATTR_INDEX_SECURITY , + name, value, size, flags); }int
fs/ext4/xattr_trusted.c +10 -10
@@ -14,8 +14,8 @@#include "xattr.h" static size_t -ext4_xattr_trusted_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext4_xattr_trusted_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const size_t prefix_len =XATTR_TRUSTED_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ;
@@ -32,23 +32,23 @@ ext4_xattr_trusted_list(struct inode *in }static int -ext4_xattr_trusted_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext4_xattr_trusted_get (struct dentry *dentry,const char *name,void *buffer, +size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext4_xattr_get (inode,EXT4_XATTR_INDEX_TRUSTED , name, - buffer, size); +return ext4_xattr_get (dentry->d_inode,EXT4_XATTR_INDEX_TRUSTED , + name, buffer, size); }static int -ext4_xattr_trusted_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext4_xattr_trusted_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext4_xattr_set (inode,EXT4_XATTR_INDEX_TRUSTED , name, - value, size, flags); +return ext4_xattr_set (dentry->d_inode,EXT4_XATTR_INDEX_TRUSTED , + name, value, size, flags); }struct xattr_handler ext4_xattr_trusted_handler = {
fs/ext4/xattr_user.c +13 -12
@@ -13,13 +13,13 @@#include "xattr.h" static size_t -ext4_xattr_user_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext4_xattr_user_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const size_t prefix_len =XATTR_USER_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return 0 ;if (list && total_len <= list_size) {
@@ -31,26 +31,27 @@ ext4_xattr_user_list(struct inode *inode }static int -ext4_xattr_user_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext4_xattr_user_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return -EOPNOTSUPP ; -return ext4_xattr_get (inode,EXT4_XATTR_INDEX_USER , name, buffer, size); +return ext4_xattr_get (dentry->d_inode,EXT4_XATTR_INDEX_USER , + name, buffer, size); }static int -ext4_xattr_user_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext4_xattr_user_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return -EOPNOTSUPP ; -return ext4_xattr_set (inode,EXT4_XATTR_INDEX_USER , name, - value, size, flags); +return ext4_xattr_set (dentry->d_inode,EXT4_XATTR_INDEX_USER , + name, value, size, flags); }struct xattr_handler ext4_xattr_user_handler = {
Quoted 8 lines · Christoph Hellwig
Add a flags argument to strcut
xattr_handlerand 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.
Quoted 6 lines
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.
Signed-off-by Christoph Hellwig <[email protected]>
Looks like a good cleanup:
5 files changed, 487 insertions(+), 755 deletions(-)
Signature · 2 lines
James Morris <[email protected]>
Quoted 7 lines · Christoph Hellwig
Add a flags argument to strcut
xattr_handlerand 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.
Signature · 10 lines
"The one important thing i have learned over the years is the difference between taking one's work seriously and taking one's self seriously. The first is imperative and the second is disastrous." -Margot Fonteyn Joel Becker Principal Software Developer Oracle E-mail: [email protected] Phone: (650) 506-8127
Quoted 11 lines · Christoph Hellwig
Add a flags argument to strcut
xattr_handlerand 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.
Updated for current mainline which saw gfs2 converted to the xattr handlers infrastructure:
fs/xfs/linux-2.6/xfs_acl.c +20 -37
@@ -353,37 +353,14 @@ xfs_acl_chmod(struct inode *inode)return error; } -/* -* System xattr handlers. -* -* Currently Posix ACLs are the only system namespace extended attribute -* handlers supported by XFS, so we just implement the handlers here. -* If we ever support other system extended attributes this will need -* some refactoring. -*/ - -static int -xfs_decode_acl (const char *name) -{ -if (strcmp (name,"posix_acl_access" ) ==0 ) -return ACL_TYPE_ACCESS ; -else if (strcmp (name,"posix_acl_default" ) ==0 ) -return ACL_TYPE_DEFAULT ; -return -EINVAL ; -} -static int -xfs_xattr_system_get (struct inode *inode,const char *name, -void *value,size_t size) +xfs_xattr_acl_get (struct dentry *dentry,const char *name, +void *value,size_t size,int type) {struct posix_acl *acl; -int type, error; - - type =xfs_decode_acl (name); -if (type <0 ) -return type; +int error; - acl =xfs_get_acl (inode, type); + acl =xfs_get_acl (dentry->d_inode, type);if (IS_ERR (acl))return PTR_ERR (acl);if (acl ==NULL )
@@ -396,15 +373,13 @@ xfs_xattr_system_get(struct inode *inode }static int -xfs_xattr_system_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +xfs_xattr_acl_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) { +struct inode *inode = dentry->d_inode;struct posix_acl *acl =NULL ; -int error =0 , type; +int error =0 ; - type =xfs_decode_acl (name); -if (type <0 ) -return type;if (flags &XATTR_CREATE )return -EINVAL ;if (type ==ACL_TYPE_DEFAULT && !S_ISDIR (inode->i_mode))
@@ -461,8 +436,16 @@ xfs_xattr_system_set(struct inode *inodereturn error; } -struct xattr_handler xfs_xattr_system_handler = { - .prefix =XATTR_SYSTEM_PREFIX , - .get = xfs_xattr_system_get, - .set = xfs_xattr_system_set, +struct xattr_handler xfs_xattr_acl_access_handler = { + .prefix =POSIX_ACL_XATTR_ACCESS , + .flags =ACL_TYPE_ACCESS , + .get = xfs_xattr_acl_get, + .set = xfs_xattr_acl_set, +}; + +struct xattr_handler xfs_xattr_acl_default_handler = { + .prefix =POSIX_ACL_XATTR_DEFAULT , + .flags =ACL_TYPE_DEFAULT , + .get = xfs_xattr_acl_get, + .set = xfs_xattr_acl_set, };
fs/btrfs/acl.c +12 -35
85 lines not on this page · raw message
fs/ext2/acl.c +25 -54
138 lines not on this page · raw message
fs/ext2/xattr.c +7 -4
@@ -60,6 +60,7 @@#include <linux/mbcache.h> #include <linux/quotaops.h> #include <linux/rwsem.h> +#include <linux/security.h> #include "ext2.h" #include "xattr.h" #include "acl.h"
@@ -249,8 +250,9 @@ cleanup:* used / required on success. */ static int -ext2_xattr_list (struct inode *inode,char *buffer,size_t buffer_size) +ext2_xattr_list (struct dentry *dentry,char *buffer,size_t buffer_size) { +struct inode *inode = dentry->d_inode;struct buffer_head *bh =NULL ;struct ext2_xattr_entry *entry;char *end;
@@ -300,9 +302,10 @@ bad_block: ext2_error(inode->i_sb, "ext2ext2_xattr_handler (entry->e_name_index);if (handler) { -size_t size = handler->list (inode, buffer, rest, +size_t size = handler->list (dentry, buffer, rest, entry->e_name, - entry->e_name_len); + entry->e_name_len, + handler->flags);if (buffer) {if (size > rest) { error = -ERANGE ;
@@ -330,7 +333,7 @@ cleanup:ssize_t ext2_listxattr (struct dentry *dentry,char *buffer,size_t size) { -return ext2_xattr_list (dentry->d_inode, buffer, size); +return ext2_xattr_list (dentry, buffer, size); }/*
fs/ext2/xattr_security.c +8 -8
@@ -11,8 +11,8 @@#include "xattr.h" static size_t -ext2_xattr_security_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext2_xattr_security_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const int prefix_len =XATTR_SECURITY_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ;
@@ -26,22 +26,22 @@ ext2_xattr_security_list(struct inode *i }static int -ext2_xattr_security_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext2_xattr_security_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext2_xattr_get (inode,EXT2_XATTR_INDEX_SECURITY , name, +return ext2_xattr_get (dentry->d_inode,EXT2_XATTR_INDEX_SECURITY , name, buffer, size); }static int -ext2_xattr_security_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext2_xattr_security_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext2_xattr_set (inode,EXT2_XATTR_INDEX_SECURITY , name, +return ext2_xattr_set (dentry->d_inode,EXT2_XATTR_INDEX_SECURITY , name, value, size, flags); }
fs/ext2/xattr_trusted.c +8 -8
@@ -13,8 +13,8 @@#include "xattr.h" static size_t -ext2_xattr_trusted_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext2_xattr_trusted_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const int prefix_len =XATTR_TRUSTED_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ;
@@ -31,22 +31,22 @@ ext2_xattr_trusted_list(struct inode *in }static int -ext2_xattr_trusted_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext2_xattr_trusted_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext2_xattr_get (inode,EXT2_XATTR_INDEX_TRUSTED , name, +return ext2_xattr_get (dentry->d_inode,EXT2_XATTR_INDEX_TRUSTED , name, buffer, size); }static int -ext2_xattr_trusted_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext2_xattr_trusted_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext2_xattr_set (inode,EXT2_XATTR_INDEX_TRUSTED , name, +return ext2_xattr_set (dentry->d_inode,EXT2_XATTR_INDEX_TRUSTED , name, value, size, flags); }
fs/ext2/xattr_user.c +13 -12
@@ -12,13 +12,13 @@#include "xattr.h" static size_t -ext2_xattr_user_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext2_xattr_user_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const size_t prefix_len =XATTR_USER_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return 0 ;if (list && total_len <= list_size) {
@@ -30,27 +30,28 @@ ext2_xattr_user_list(struct inode *inode }static int -ext2_xattr_user_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext2_xattr_user_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return -EOPNOTSUPP ; -return ext2_xattr_get (inode,EXT2_XATTR_INDEX_USER , name, buffer, size); +return ext2_xattr_get (dentry->d_inode,EXT2_XATTR_INDEX_USER , + name, buffer, size); }static int -ext2_xattr_user_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext2_xattr_user_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return -EOPNOTSUPP ; -return ext2_xattr_set (inode,EXT2_XATTR_INDEX_USER , name, - value, size, flags); +return ext2_xattr_set (dentry->d_inode,EXT2_XATTR_INDEX_USER , + name, value, size, flags); }struct xattr_handler ext2_xattr_user_handler = {
fs/ext3/acl.c +23 -51
127 lines not on this page · raw message
fs/ext3/xattr.c +17 -14
@@ -99,7 +99,7 @@ static struct buffer_head *ext3_xattr_ca struct mb_cache_entry **);static void ext3_xattr_rehash (struct ext3_xattr_header *,struct ext3_xattr_entry *); -static int ext3_xattr_list (struct inode *inode,char *buffer, +static int ext3_xattr_list (struct dentry *dentry,char *buffer,size_t buffer_size);static struct mb_cache *ext3_xattr_cache;
@@ -147,7 +147,7 @@ ext3_xattr_handler(int name_index)ssize_t ext3_listxattr (struct dentry *dentry,char *buffer,size_t size) { -return ext3_xattr_list (dentry->d_inode, buffer, size); +return ext3_xattr_list (dentry, buffer, size); } static int
@@ -332,7 +332,7 @@ ext3_xattr_get(struct inode *inode, int }static int -ext3_xattr_list_entries (struct inode *inode,struct ext3_xattr_entry *entry, +ext3_xattr_list_entries (struct dentry *dentry,struct ext3_xattr_entry *entry,char *buffer,size_t buffer_size) {size_t rest = buffer_size;
@@ -342,9 +342,10 @@ ext3_xattr_list_entries(struct inode *inext3_xattr_handler (entry->e_name_index);if (handler) { -size_t size = handler->list (inode, buffer, rest, +size_t size = handler->list (dentry, buffer, rest, entry->e_name, - entry->e_name_len); + entry->e_name_len, + handler->flags);if (buffer) {if (size > rest)return -ERANGE ;
@@ -357,8 +358,9 @@ ext3_xattr_list_entries(struct inode *in }static int -ext3_xattr_block_list (struct inode *inode,char *buffer,size_t buffer_size) +ext3_xattr_block_list (struct dentry *dentry,char *buffer,size_t buffer_size) { +struct inode *inode = dentry->d_inode;struct buffer_head *bh =NULL ;int error;
@@ -383,7 +385,7 @@ ext3_xattr_block_list(struct inode *inod goto cleanup; }ext3_xattr_cache_insert (bh); - error =ext3_xattr_list_entries (inode,BFIRST (bh), buffer, buffer_size); + error =ext3_xattr_list_entries (dentry,BFIRST (bh), buffer, buffer_size); cleanup:brelse (bh);
@@ -392,8 +394,9 @@ cleanup: }static int -ext3_xattr_ibody_list (struct inode *inode,char *buffer,size_t buffer_size) +ext3_xattr_ibody_list (struct dentry *dentry,char *buffer,size_t buffer_size) { +struct inode *inode = dentry->d_inode;struct ext3_xattr_ibody_header *header;struct ext3_inode *raw_inode;struct ext3_iloc iloc;
@@ -411,7 +414,7 @@ ext3_xattr_ibody_list(struct inode *inod error =ext3_xattr_check_names (IFIRST (header), end);if (error) goto cleanup; - error =ext3_xattr_list_entries (inode,IFIRST (header), + error =ext3_xattr_list_entries (dentry,IFIRST (header), buffer, buffer_size); cleanup:
@@ -430,12 +433,12 @@ cleanup:* used / required on success. */ static int -ext3_xattr_list (struct inode *inode,char *buffer,size_t buffer_size) +ext3_xattr_list (struct dentry *dentry,char *buffer,size_t buffer_size) {int i_error, b_error; -down_read (&EXT3_I (inode)->xattr_sem); - i_error =ext3_xattr_ibody_list (inode, buffer, buffer_size); +down_read (&EXT3_I (dentry->d_inode)->xattr_sem); + i_error =ext3_xattr_ibody_list (dentry, buffer, buffer_size);if (i_error <0 ) { b_error =0 ; }else {
@@ -443,11 +446,11 @@ ext3_xattr_list(struct inode *inode, cha buffer += i_error; buffer_size -= i_error; } - b_error =ext3_xattr_block_list (inode, buffer, buffer_size); + b_error =ext3_xattr_block_list (dentry, buffer, buffer_size);if (b_error <0 ) i_error =0 ; } -up_read (&EXT3_I (inode)->xattr_sem); +up_read (&EXT3_I (dentry->d_inode)->xattr_sem);return i_error + b_error; }
fs/ext3/xattr_security.c +10 -10
@@ -12,8 +12,8 @@#include "xattr.h" static size_t -ext3_xattr_security_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext3_xattr_security_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const size_t prefix_len =XATTR_SECURITY_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ;
@@ -28,23 +28,23 @@ ext3_xattr_security_list(struct inode *i }static int -ext3_xattr_security_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext3_xattr_security_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext3_xattr_get (inode,EXT3_XATTR_INDEX_SECURITY , name, - buffer, size); +return ext3_xattr_get (dentry->d_inode,EXT3_XATTR_INDEX_SECURITY , + name, buffer, size); }static int -ext3_xattr_security_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext3_xattr_security_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext3_xattr_set (inode,EXT3_XATTR_INDEX_SECURITY , name, - value, size, flags); +return ext3_xattr_set (dentry->d_inode,EXT3_XATTR_INDEX_SECURITY , + name, value, size, flags); }int
fs/ext3/xattr_trusted.c +9 -9
@@ -14,8 +14,8 @@#include "xattr.h" static size_t -ext3_xattr_trusted_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext3_xattr_trusted_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const size_t prefix_len =XATTR_TRUSTED_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ;
@@ -32,22 +32,22 @@ ext3_xattr_trusted_list(struct inode *in }static int -ext3_xattr_trusted_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext3_xattr_trusted_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext3_xattr_get (inode,EXT3_XATTR_INDEX_TRUSTED , name, - buffer, size); +return ext3_xattr_get (dentry->d_inode,EXT3_XATTR_INDEX_TRUSTED , + name, buffer, size); }static int -ext3_xattr_trusted_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext3_xattr_trusted_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext3_xattr_set (inode,EXT3_XATTR_INDEX_TRUSTED , name, +return ext3_xattr_set (dentry->d_inode,EXT3_XATTR_INDEX_TRUSTED , name, value, size, flags); }
fs/ext3/xattr_user.c +13 -12
@@ -13,13 +13,13 @@#include "xattr.h" static size_t -ext3_xattr_user_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext3_xattr_user_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const size_t prefix_len =XATTR_USER_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return 0 ;if (list && total_len <= list_size) {
@@ -31,26 +31,27 @@ ext3_xattr_user_list(struct inode *inode }static int -ext3_xattr_user_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext3_xattr_user_get (struct dentry *dentry,const char *name,void *buffer, +size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return -EOPNOTSUPP ; -return ext3_xattr_get (inode,EXT3_XATTR_INDEX_USER , name, buffer, size); +return ext3_xattr_get (dentry->d_inode,EXT3_XATTR_INDEX_USER , + name, buffer, size); }static int -ext3_xattr_user_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext3_xattr_user_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return -EOPNOTSUPP ; -return ext3_xattr_set (inode,EXT3_XATTR_INDEX_USER , name, - value, size, flags); +return ext3_xattr_set (dentry->d_inode,EXT3_XATTR_INDEX_USER , + name, value, size, flags); }struct xattr_handler ext3_xattr_user_handler = {
fs/ext4/acl.c +23 -51
127 lines not on this page · raw message
fs/ext4/xattr.c +17 -14
@@ -92,7 +92,7 @@ static struct buffer_head *ext4_xattr_ca struct mb_cache_entry **);static void ext4_xattr_rehash (struct ext4_xattr_header *,struct ext4_xattr_entry *); -static int ext4_xattr_list (struct inode *inode,char *buffer, +static int ext4_xattr_list (struct dentry *dentry,char *buffer,size_t buffer_size);static struct mb_cache *ext4_xattr_cache;
@@ -140,7 +140,7 @@ ext4_xattr_handler(int name_index)ssize_t ext4_listxattr (struct dentry *dentry,char *buffer,size_t size) { -return ext4_xattr_list (dentry->d_inode, buffer, size); +return ext4_xattr_list (dentry, buffer, size); } static int
@@ -325,7 +325,7 @@ ext4_xattr_get(struct inode *inode, int }static int -ext4_xattr_list_entries (struct inode *inode,struct ext4_xattr_entry *entry, +ext4_xattr_list_entries (struct dentry *dentry,struct ext4_xattr_entry *entry,char *buffer,size_t buffer_size) {size_t rest = buffer_size;
@@ -335,9 +335,10 @@ ext4_xattr_list_entries(struct inode *inext4_xattr_handler (entry->e_name_index);if (handler) { -size_t size = handler->list (inode, buffer, rest, +size_t size = handler->list (dentry, buffer, rest, entry->e_name, - entry->e_name_len); + entry->e_name_len, + handler->flags);if (buffer) {if (size > rest)return -ERANGE ;
@@ -350,8 +351,9 @@ ext4_xattr_list_entries(struct inode *in }static int -ext4_xattr_block_list (struct inode *inode,char *buffer,size_t buffer_size) +ext4_xattr_block_list (struct dentry *dentry,char *buffer,size_t buffer_size) { +struct inode *inode = dentry->d_inode;struct buffer_head *bh =NULL ;int error;
@@ -376,7 +378,7 @@ ext4_xattr_block_list(struct inode *inod goto cleanup; }ext4_xattr_cache_insert (bh); - error =ext4_xattr_list_entries (inode,BFIRST (bh), buffer, buffer_size); + error =ext4_xattr_list_entries (dentry,BFIRST (bh), buffer, buffer_size); cleanup:brelse (bh);
@@ -385,8 +387,9 @@ cleanup: }static int -ext4_xattr_ibody_list (struct inode *inode,char *buffer,size_t buffer_size) +ext4_xattr_ibody_list (struct dentry *dentry,char *buffer,size_t buffer_size) { +struct inode *inode = dentry->d_inode;struct ext4_xattr_ibody_header *header;struct ext4_inode *raw_inode;struct ext4_iloc iloc;
@@ -404,7 +407,7 @@ ext4_xattr_ibody_list(struct inode *inod error =ext4_xattr_check_names (IFIRST (header), end);if (error) goto cleanup; - error =ext4_xattr_list_entries (inode,IFIRST (header), + error =ext4_xattr_list_entries (dentry,IFIRST (header), buffer, buffer_size); cleanup:
@@ -423,12 +426,12 @@ cleanup:* used / required on success. */ static int -ext4_xattr_list (struct inode *inode,char *buffer,size_t buffer_size) +ext4_xattr_list (struct dentry *dentry,char *buffer,size_t buffer_size) {int i_error, b_error; -down_read (&EXT4_I (inode)->xattr_sem); - i_error =ext4_xattr_ibody_list (inode, buffer, buffer_size); +down_read (&EXT4_I (dentry->d_inode)->xattr_sem); + i_error =ext4_xattr_ibody_list (dentry, buffer, buffer_size);if (i_error <0 ) { b_error =0 ; }else {
@@ -436,11 +439,11 @@ ext4_xattr_list(struct inode *inode, cha buffer += i_error; buffer_size -= i_error; } - b_error =ext4_xattr_block_list (inode, buffer, buffer_size); + b_error =ext4_xattr_block_list (dentry, buffer, buffer_size);if (b_error <0 ) i_error =0 ; } -up_read (&EXT4_I (inode)->xattr_sem); +up_read (&EXT4_I (dentry->d_inode)->xattr_sem);return i_error + b_error; }
fs/ext4/xattr_security.c +10 -10
@@ -12,8 +12,8 @@#include "xattr.h" static size_t -ext4_xattr_security_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext4_xattr_security_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const size_t prefix_len =sizeof (XATTR_SECURITY_PREFIX )-1 ;const size_t total_len = prefix_len + name_len +1 ;
@@ -28,23 +28,23 @@ ext4_xattr_security_list(struct inode *i }static int -ext4_xattr_security_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext4_xattr_security_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext4_xattr_get (inode,EXT4_XATTR_INDEX_SECURITY , name, - buffer, size); +return ext4_xattr_get (dentry->d_inode,EXT4_XATTR_INDEX_SECURITY , + name, buffer, size); }static int -ext4_xattr_security_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext4_xattr_security_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext4_xattr_set (inode,EXT4_XATTR_INDEX_SECURITY , name, - value, size, flags); +return ext4_xattr_set (dentry->d_inode,EXT4_XATTR_INDEX_SECURITY , + name, value, size, flags); }int
fs/ext4/xattr_trusted.c +10 -10
@@ -14,8 +14,8 @@#include "xattr.h" static size_t -ext4_xattr_trusted_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext4_xattr_trusted_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const size_t prefix_len =XATTR_TRUSTED_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ;
@@ -32,23 +32,23 @@ ext4_xattr_trusted_list(struct inode *in }static int -ext4_xattr_trusted_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext4_xattr_trusted_get (struct dentry *dentry,const char *name,void *buffer, +size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext4_xattr_get (inode,EXT4_XATTR_INDEX_TRUSTED , name, - buffer, size); +return ext4_xattr_get (dentry->d_inode,EXT4_XATTR_INDEX_TRUSTED , + name, buffer, size); }static int -ext4_xattr_trusted_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext4_xattr_trusted_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext4_xattr_set (inode,EXT4_XATTR_INDEX_TRUSTED , name, - value, size, flags); +return ext4_xattr_set (dentry->d_inode,EXT4_XATTR_INDEX_TRUSTED , + name, value, size, flags); }struct xattr_handler ext4_xattr_trusted_handler = {
fs/ext4/xattr_user.c +13 -12
@@ -13,13 +13,13 @@#include "xattr.h" static size_t -ext4_xattr_user_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext4_xattr_user_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const size_t prefix_len =XATTR_USER_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return 0 ;if (list && total_len <= list_size) {
@@ -31,26 +31,27 @@ ext4_xattr_user_list(struct inode *inode }static int -ext4_xattr_user_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext4_xattr_user_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return -EOPNOTSUPP ; -return ext4_xattr_get (inode,EXT4_XATTR_INDEX_USER , name, buffer, size); +return ext4_xattr_get (dentry->d_inode,EXT4_XATTR_INDEX_USER , + name, buffer, size); }static int -ext4_xattr_user_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext4_xattr_user_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return -EOPNOTSUPP ; -return ext4_xattr_set (inode,EXT4_XATTR_INDEX_USER , name, - value, size, flags); +return ext4_xattr_set (dentry->d_inode,EXT4_XATTR_INDEX_USER , + name, value, size, flags); }struct xattr_handler ext4_xattr_user_handler = {
fs/gfs2/acl.c +4 -4
@@ -217,8 +217,8 @@ int gfs2_acl_create(struct gfs2_inode *d acl = clone;if (S_ISDIR (ip->i_inode.i_mode)) { - error =gfs2_xattr_set (&ip->i_inode,GFS2_EATYPE_SYS , -GFS2_POSIX_ACL_DEFAULT , data, len,0 ); + error =__gfs2_xattr_set (ip,GFS2_POSIX_ACL_DEFAULT , data, + len,0 ,GFS2_EATYPE_SYS );if (error) goto out; }
@@ -230,8 +230,8 @@ int gfs2_acl_create(struct gfs2_inode *d goto munge;posix_acl_to_xattr (acl, data, len); - error =gfs2_xattr_set (&ip->i_inode,GFS2_EATYPE_SYS , -GFS2_POSIX_ACL_ACCESS , data, len,0 ); + error =__gfs2_xattr_set (ip,GFS2_POSIX_ACL_ACCESS , data, len,0 , +GFS2_EATYPE_SYS );if (error) goto out; munge:
fs/gfs2/inode.c +1 -1
@@ -801,7 +801,7 @@ static int gfs2_security_init(struct gfsreturn err; } - err =gfs2_xattr_set (&ip->i_inode,GFS2_EATYPE_SECURITY , name, value, len,0 ); + err =__gfs2_xattr_set (ip, name, value, len,0 ,GFS2_EATYPE_SECURITY );kfree (value);kfree (name);
fs/gfs2/xattr.c +29 -60
162 lines not on this page · raw message
fs/gfs2/xattr.h +3 -4
@@ -53,10 +53,9 @@ struct gfs2_ea_location {struct gfs2_ea_header *el_prev; }; -extern int gfs2_xattr_get (struct inode *inode,int type,const char *name, -void *buffer,size_t size); -extern int gfs2_xattr_set (struct inode *inode,int type,const char *name, -const void *value,size_t size,int flags); +extern int __gfs2_xattr_set (struct gfs2_inode *ip,const char *name, +const void *value,size_t size, +int flags,int type);extern ssize_t gfs2_listxattr (struct dentry *dentry,char *buffer,size_t size);extern int gfs2_ea_dealloc (struct gfs2_inode *ip);
fs/jffs2/acl.c +22 -43
114 lines not on this page · raw message
fs/jffs2/security.c +10 -8
@@ -44,26 +44,28 @@ int jffs2_init_security(struct inode *in }/* ---- XATTR Handler for "security.*" ----------------- */ -static int jffs2_security_getxattr (struct inode *inode,const char *name, -void *buffer,size_t size) +static int jffs2_security_getxattr (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (!strcmp (name,"" ))return -EINVAL ; -return do_jffs2_getxattr (inode,JFFS2_XPREFIX_SECURITY , name, buffer, size); +return do_jffs2_getxattr (dentry->d_inode,JFFS2_XPREFIX_SECURITY , + name, buffer, size); } -static int jffs2_security_setxattr (struct inode *inode,const char *name,const void *buffer, -size_t size,int flags) +static int jffs2_security_setxattr (struct dentry *dentry,const char *name, +const void *buffer,size_t size,int flags,int type) {if (!strcmp (name,"" ))return -EINVAL ; -return do_jffs2_setxattr (inode,JFFS2_XPREFIX_SECURITY , name, buffer, size, flags); +return do_jffs2_setxattr (dentry->d_inode,JFFS2_XPREFIX_SECURITY , + name, buffer, size, flags); } -static size_t jffs2_security_listxattr (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +static size_t jffs2_security_listxattr (struct dentry *dentry,char *list, +size_t list_size,const char *name,size_t name_len,int type) {size_t retlen =XATTR_SECURITY_PREFIX_LEN + name_len +1 ;
fs/jffs2/xattr.c +4 -2
@@ -990,9 +990,11 @@ ssize_t jffs2_listxattr(struct dentry *dif (!xhandle)continue ;if (buffer) { - rc = xhandle->list (inode, buffer+len, size-len, xd->xname, xd->name_len); + rc = xhandle->list (dentry, buffer+len, size-len, + xd->xname, xd->name_len, xd->flags); }else { - rc = xhandle->list (inode,NULL ,0 , xd->xname, xd->name_len); + rc = xhandle->list (dentry,NULL ,0 , xd->xname, + xd->name_len, xd->flags); }if (rc <0 ) goto out;
fs/jffs2/xattr_trusted.c +10 -8
@@ -16,24 +16,26 @@#include <linux/mtd/mtd.h> #include "nodelist.h" -static int jffs2_trusted_getxattr (struct inode *inode,const char *name, -void *buffer,size_t size) +static int jffs2_trusted_getxattr (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (!strcmp (name,"" ))return -EINVAL ; -return do_jffs2_getxattr (inode,JFFS2_XPREFIX_TRUSTED , name, buffer, size); +return do_jffs2_getxattr (dentry->d_inode,JFFS2_XPREFIX_TRUSTED , + name, buffer, size); } -static int jffs2_trusted_setxattr (struct inode *inode,const char *name,const void *buffer, -size_t size,int flags) +static int jffs2_trusted_setxattr (struct dentry *dentry,const char *name, +const void *buffer,size_t size,int flags,int type) {if (!strcmp (name,"" ))return -EINVAL ; -return do_jffs2_setxattr (inode,JFFS2_XPREFIX_TRUSTED , name, buffer, size, flags); +return do_jffs2_setxattr (dentry->d_inode,JFFS2_XPREFIX_TRUSTED , + name, buffer, size, flags); } -static size_t jffs2_trusted_listxattr (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +static size_t jffs2_trusted_listxattr (struct dentry *dentry,char *list, +size_t list_size,const char *name,size_t name_len,int type) {size_t retlen =XATTR_TRUSTED_PREFIX_LEN + name_len +1 ;
fs/jffs2/xattr_user.c +10 -8
@@ -16,24 +16,26 @@#include <linux/mtd/mtd.h> #include "nodelist.h" -static int jffs2_user_getxattr (struct inode *inode,const char *name, -void *buffer,size_t size) +static int jffs2_user_getxattr (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (!strcmp (name,"" ))return -EINVAL ; -return do_jffs2_getxattr (inode,JFFS2_XPREFIX_USER , name, buffer, size); +return do_jffs2_getxattr (dentry->d_inode,JFFS2_XPREFIX_USER , + name, buffer, size); } -static int jffs2_user_setxattr (struct inode *inode,const char *name,const void *buffer, -size_t size,int flags) +static int jffs2_user_setxattr (struct dentry *dentry,const char *name, +const void *buffer,size_t size,int flags,int type) {if (!strcmp (name,"" ))return -EINVAL ; -return do_jffs2_setxattr (inode,JFFS2_XPREFIX_USER , name, buffer, size, flags); +return do_jffs2_setxattr (dentry->d_inode,JFFS2_XPREFIX_USER , + name, buffer, size, flags); } -static size_t jffs2_user_listxattr (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +static size_t jffs2_user_listxattr (struct dentry *dentry,char *list, +size_t list_size,const char *name,size_t name_len,int type) {size_t retlen =XATTR_USER_PREFIX_LEN + name_len +1 ;
fs/ocfs2/acl.c +25 -62
143 lines not on this page · raw message
fs/ocfs2/xattr.c +32 -32
140 lines not on this page · raw message
fs/reiserfs/xattr.c +18 -18
@@ -48,6 +48,7 @@#include <net/checksum.h> #include <linux/stat.h> #include <linux/quotaops.h> +#include <linux/security.h> #define PRIVROOT_NAME ".reiserfs_priv"#define XAROOT_NAME "xattrs"
@@ -726,15 +727,14 @@ ssize_t reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer, size_t size) { - struct inode *inode = dentry->d_inode; struct xattr_handler *handler; - handler =find_xattr_handler_prefix (inode->i_sb->s_xattr, name); + handler =find_xattr_handler_prefix (dentry->d_sb->s_xattr, name); -if (!handler ||get_inode_sd_version (inode) ==STAT_DATA_V1 ) +if (!handler ||get_inode_sd_version (dentry->d_inode) ==STAT_DATA_V1 )return -EOPNOTSUPP ; -return handler->get (inode, name, buffer, size); +return handler->get (dentry, name, buffer, size, handler->flags); }/*
@@ -746,15 +746,14 @@ int reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) { - struct inode *inode = dentry->d_inode; struct xattr_handler *handler; - handler =find_xattr_handler_prefix (inode->i_sb->s_xattr, name); + handler =find_xattr_handler_prefix (dentry->d_sb->s_xattr, name); -if (!handler ||get_inode_sd_version (inode) ==STAT_DATA_V1 ) +if (!handler ||get_inode_sd_version (dentry->d_inode) ==STAT_DATA_V1 )return -EOPNOTSUPP ; -return handler->set (inode, name, value, size, flags); +return handler->set (dentry, name, value, size, flags, handler->flags); }/*
@@ -764,21 +763,20 @@ reiserfs_setxattr(struct dentry *dentry,*/ int reiserfs_removexattr (struct dentry *dentry,const char *name) { -struct inode *inode = dentry->d_inode;struct xattr_handler *handler; - handler =find_xattr_handler_prefix (inode->i_sb->s_xattr, name); + handler =find_xattr_handler_prefix (dentry->d_sb->s_xattr, name); -if (!handler ||get_inode_sd_version (inode) ==STAT_DATA_V1 ) +if (!handler ||get_inode_sd_version (dentry->d_inode) ==STAT_DATA_V1 )return -EOPNOTSUPP ; -return handler->set (inode, name,NULL ,0 ,XATTR_REPLACE ); +return handler->set (dentry, name,NULL ,0 ,XATTR_REPLACE , handler->flags); }struct listxattr_buf {size_t size;size_t pos;char *buf; -struct inode *inode; +struct dentry *dentry; }; static int listxattr_filler(void *buf, const char *name, int namelen,
@@ -789,17 +787,19 @@ static int listxattr_filler(void *buf, cif (name[0 ] !='.' || (namelen !=1 && (name[1 ] !='.' || namelen !=2 ))) {struct xattr_handler *handler; - handler =find_xattr_handler_prefix (b->inode->i_sb->s_xattr, + handler =find_xattr_handler_prefix (b->dentry->d_sb->s_xattr, name);if (!handler)/* Unsupported xattr name */ return 0 ;if (b->buf) { - size = handler->list (b->inode, b->buf + b->pos, - b->size, name, namelen); + size = handler->list (b->dentry, b->buf + b->pos, + b->size, name, namelen, + handler->flags);if (size > b->size)return -ERANGE ; }else { - size = handler->list (b->inode,NULL ,0 , name, namelen); + size = handler->list (b->dentry,NULL ,0 , name, + namelen, handler->flags); } b->pos += size;
@@ -820,7 +820,7 @@ ssize_t reiserfs_listxattr(struct dentryint err =0 ;loff_t pos =0 ;struct listxattr_buf buf = { - .inode = dentry->d_inode, + .dentry = dentry, .buf = buffer, .size = buffer ? size :0 , };
fs/reiserfs/xattr_acl.c +19 -50
114 lines not on this page · raw message
fs/reiserfs/xattr_security.c +11 -10
@@ -8,36 +8,37 @@#include <asm/uaccess.h> static int -security_get (struct inode *inode,const char *name,void *buffer,size_t size) +security_get (struct dentry *dentry,const char *name,void *buffer,size_t size, +int handler_flags) {if (strlen (name) <sizeof (XATTR_SECURITY_PREFIX ))return -EINVAL ; -if (IS_PRIVATE (inode)) +if (IS_PRIVATE (dentry->d_inode))return -EPERM ; -return reiserfs_xattr_get (inode, name, buffer, size); +return reiserfs_xattr_get (dentry->d_inode, name, buffer, size); }static int -security_set (struct inode *inode,const char *name,const void *buffer, -size_t size,int flags) +security_set (struct dentry *dentry,const char *name,const void *buffer, +size_t size,int flags,int handler_flags) {if (strlen (name) <sizeof (XATTR_SECURITY_PREFIX ))return -EINVAL ; -if (IS_PRIVATE (inode)) +if (IS_PRIVATE (dentry->d_inode))return -EPERM ; -return reiserfs_xattr_set (inode, name, buffer, size, flags); +return reiserfs_xattr_set (dentry->d_inode, name, buffer, size, flags); } -static size_t security_list (struct inode *inode,char *list,size_t list_len, -const char *name,size_t namelen) +static size_t security_list (struct dentry *dentry,char *list,size_t list_len, +const char *name,size_t namelen,int handler_flags) {const size_t len = namelen +1 ; -if (IS_PRIVATE (inode)) +if (IS_PRIVATE (dentry->d_inode))return 0 ;if (list && len <= list_len) {
fs/reiserfs/xattr_trusted.c +11 -10
@@ -8,36 +8,37 @@#include <asm/uaccess.h> static int -trusted_get (struct inode *inode,const char *name,void *buffer,size_t size) +trusted_get (struct dentry *dentry,const char *name,void *buffer,size_t size, +int handler_flags) {if (strlen (name) <sizeof (XATTR_TRUSTED_PREFIX ))return -EINVAL ; -if (!capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (inode)) +if (!capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (dentry->d_inode))return -EPERM ; -return reiserfs_xattr_get (inode, name, buffer, size); +return reiserfs_xattr_get (dentry->d_inode, name, buffer, size); }static int -trusted_set (struct inode *inode,const char *name,const void *buffer, -size_t size,int flags) +trusted_set (struct dentry *dentry,const char *name,const void *buffer, +size_t size,int flags,int handler_flags) {if (strlen (name) <sizeof (XATTR_TRUSTED_PREFIX ))return -EINVAL ; -if (!capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (inode)) +if (!capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (dentry->d_inode))return -EPERM ; -return reiserfs_xattr_set (inode, name, buffer, size, flags); +return reiserfs_xattr_set (dentry->d_inode, name, buffer, size, flags); } -static size_t trusted_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +static size_t trusted_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int handler_flags) {const size_t len = name_len +1 ; -if (!capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (inode)) +if (!capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (dentry->d_inode))return 0 ;if (list && len <= list_size) {
fs/reiserfs/xattr_user.c +11 -10
@@ -7,34 +7,35 @@#include <asm/uaccess.h> static int -user_get (struct inode *inode,const char *name,void *buffer,size_t size) +user_get (struct dentry *dentry,const char *name,void *buffer,size_t size, +int handler_flags) {if (strlen (name) <sizeof (XATTR_USER_PREFIX ))return -EINVAL ; -if (!reiserfs_xattrs_user (inode->i_sb)) +if (!reiserfs_xattrs_user (dentry->d_sb))return -EOPNOTSUPP ; -return reiserfs_xattr_get (inode, name, buffer, size); +return reiserfs_xattr_get (dentry->d_inode, name, buffer, size); }static int -user_set (struct inode *inode,const char *name,const void *buffer, -size_t size,int flags) +user_set (struct dentry *dentry,const char *name,const void *buffer, +size_t size,int flags,int handler_flags) {if (strlen (name) <sizeof (XATTR_USER_PREFIX ))return -EINVAL ; -if (!reiserfs_xattrs_user (inode->i_sb)) +if (!reiserfs_xattrs_user (dentry->d_sb))return -EOPNOTSUPP ; -return reiserfs_xattr_set (inode, name, buffer, size, flags); +return reiserfs_xattr_set (dentry->d_inode, name, buffer, size, flags); } -static size_t user_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +static size_t user_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int handler_flags) {const size_t len = name_len +1 ; -if (!reiserfs_xattrs_user (inode->i_sb)) +if (!reiserfs_xattrs_user (dentry->d_sb))return 0 ;if (list && len <= list_size) {memcpy (list, name, name_len);
fs/xattr.c +14 -14
@@ -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,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);
fs/xfs/linux-2.6/xfs_xattr.c +15 -56
110 lines not on this page · raw message
fs/xfs/xfs_acl.h +2 -1
@@ -49,7 +49,8 @@ extern int xfs_acl_chmod(struct inode *iextern int posix_acl_access_exists (struct inode *inode);extern int posix_acl_default_exists (struct inode *inode); -extern struct xattr_handler xfs_xattr_system_handler; +extern struct xattr_handler xfs_xattr_acl_access_handler; +extern struct xattr_handler xfs_xattr_acl_default_handler;#else # define xfs_check_acl NULL# define xfs_get_acl (inode, type) NULL
include/linux/xattr.h +7 -6
@@ -38,12 +38,13 @@ struct dentry;struct xattr_handler {char *prefix; -size_t (*list)(struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len); -int (*get)(struct inode *inode,const char *name,void *buffer, -size_t size); -int (*set)(struct inode *inode,const char *name,const void *buffer, -size_t size,int flags); +int flags;/* fs private flags passed back to the handlers */ +size_t (*list)(struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int handler_flags); +int (*get)(struct dentry *dentry,const char *name,void *buffer, +size_t size,int handler_flags); +int (*set)(struct dentry *dentry,const char *name,const void *buffer, +size_t size,int flags,int handler_flags); };ssize_t xattr_getsecurity (struct inode *,const char *,void *,size_t );
mm/shmem.c +10 -9
@@ -2035,27 +2035,28 @@ static const struct inode_operations shm* filesystem level, though. */ -static size_t shmem_xattr_security_list (struct inode *inode,char *list, +static size_t shmem_xattr_security_list (struct dentry *dentry,char *list,size_t list_len,const char *name, -size_t name_len) +size_t name_len,int handler_flags) { -return security_inode_listsecurity (inode, list, list_len); +return security_inode_listsecurity (dentry->d_inode, list, list_len); } -static int shmem_xattr_security_get (struct inode *inode,const char *name, -void *buffer,size_t size) +static int shmem_xattr_security_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int handler_flags) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return xattr_getsecurity (inode, name, buffer, size); +return xattr_getsecurity (dentry->d_inode, name, buffer, size); } -static int shmem_xattr_security_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +static int shmem_xattr_security_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int handler_flags) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return security_inode_setsecurity (inode, name, value, size, flags); +return security_inode_setsecurity (dentry->d_inode, name, value, + size, flags); }static struct xattr_handler shmem_xattr_security_handler = {
mm/shmem_acl.c +20 -58
106 lines not on this page · raw message
Steven Whitehouse
Acked-byHi,
Quoted 9 lines · Christoph Hellwig
Quoted 8 lines · Christoph Hellwig
Add a flags argument to strcut
xattr_handlerand 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.
Quoted 7 lines
Quoted 3 lines
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.
Updated for current mainline which saw gfs2 converted to the xattr handlers infrastructure:
Wrt the GFS2 bits, they look good, but with one query:
Quoted 110 lines
Index:
linux-2.6/fs/gfs2/acl.c
===================================================================fs/gfs2/acl.c +4
-4@@ -217,8 +217,8 @@ int gfs2_acl_create(struct gfs2_inode *d acl = clone;if (S_ISDIR (ip->i_inode.i_mode)) { - error =gfs2_xattr_set (&ip->i_inode,GFS2_EATYPE_SYS , -GFS2_POSIX_ACL_DEFAULT , data, len,0 ); + error =__gfs2_xattr_set (ip,GFS2_POSIX_ACL_DEFAULT , data, + len,0 ,GFS2_EATYPE_SYS );if (error) goto out; }@@ -230,8 +230,8 @@ int gfs2_acl_create(struct gfs2_inode *d goto munge;posix_acl_to_xattr (acl, data, len); - error =gfs2_xattr_set (&ip->i_inode,GFS2_EATYPE_SYS , -GFS2_POSIX_ACL_ACCESS , data, len,0 ); + error =__gfs2_xattr_set (ip,GFS2_POSIX_ACL_ACCESS , data, len,0 , +GFS2_EATYPE_SYS );if (error) goto out; munge:Index:
linux-2.6/fs/gfs2/inode.c
===================================================================fs/gfs2/inode.c +1
-1@@ -801,7 +801,7 @@ static int gfs2_security_init(struct gfsreturn err; } - err =gfs2_xattr_set (&ip->i_inode,GFS2_EATYPE_SECURITY , name, value, len,0 ); + err =__gfs2_xattr_set (ip, name, value, len,0 ,GFS2_EATYPE_SECURITY );kfree (value);kfree (name);Index:
linux-2.6/fs/gfs2/xattr.c
===================================================================fs/gfs2/xattr.c +11
-13@@ -537,18 +537,17 @@ int gfs2_ea_get_copy(struct gfs2_inode */** * gfs2_xattr_get - Get a GFS2 extended attribute * @inode: The inode -* @type: The type of extended attribute * @name: The name of the extended attribute * @buffer: The buffer to write the result into * @size: The size of the buffer +* @type: The type of extended attribute * * Returns: actual size of data on success, -errno on error */ - -int gfs2_xattr_get (struct inode *inode,int type,const char *name, -void *buffer,size_t size) +static int gfs2_xattr_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) { -struct gfs2_inode *ip =GFS2_I (inode); +struct gfs2_inode *ip =GFS2_I (dentry->d_inode);struct gfs2_ea_location el;int error;@@ -1089,7 +1088,7 @@ static int ea_remove_stuffed(struct gfs2/** * gfs2_xattr_remove - Remove a GFS2 extended attribute -* @inode: The inode +* @ip: The inode * @type: The type of the extended attribute * @name: The name of the extended attribute * @@ -1100,9 +1099,8 @@ static int ea_remove_stuffed(struct gfs2* Returns: 0, or errno on failure */ -static int gfs2_xattr_remove (struct inode *inode,int type,const char *name) +static int gfs2_xattr_remove (struct gfs2_inode *ip,int type,const char *name) { -struct gfs2_inode *ip =GFS2_I (inode);struct gfs2_ea_location el;int error;@@ -1126,35 +1124,32 @@ static int gfs2_xattr_remove(struct inod }/** -* gfs2_xattr_set - Set (or remove) a GFS2 extended attribute -* @inode: The inode -* @type: The type of the extended attribute +* __gfs2_xattr_set - Set (or remove) a GFS2 extended attribute +* @ip: The inode * @name: The name of the extended attribute * @value: The value of the extended attribute (NULL for remove) * @size: The size of the @value argument * @flags: Create or Replace +* @type: The type of the extended attribute * * See gfs2_xattr_remove() for details of the removal of xattrs. * * Returns: 0 or errno on failure */ -int gfs2_xattr_set (struct inode *inode,int type,const char *name, -const void *value,size_t size,int flags) +int __gfs2_xattr_set (struct gfs2_inode *ip,const char *name, +const void *value,size_t size,int flags,int type)
fs/gfs2/xattr.c static int gfs2_xattr_remove(struct inod · line 1152
Quoted 10 lines
fs/gfs2/xattr.c +1
-4{ -struct gfs2_sbd *sdp =GFS2_SB (inode); -struct gfs2_inode *ip =GFS2_I (inode); +struct gfs2_sbd *sdp =GFS2_SB (&ip->i_inode);struct gfs2_ea_location el;unsigned int namel =strlen (name);int error; -if (IS_IMMUTABLE (inode) ||IS_APPEND (inode)) -return -EPERM ;
We need to leave these checks here because the checks made in the VFS are done before the glock is held, so they might yield the wrong answers. I think we should check again here just to be on the safe side. Otherwise:
Steve.
Quoted 5 lines · Steven Whitehouse
We need to leave these checks here because the checks made in the VFS are done before the glock is held, so they might yield the wrong answers. I think we should check again here just to be on the safe side. Otherwise:
Ok, new version below with those put back and some minor changes due to ocfs2 updates in mainline:
fs/xfs/linux-2.6/xfs_acl.c +20 -37
@@ -353,37 +353,14 @@ xfs_acl_chmod(struct inode *inode)return error; } -/* -* System xattr handlers. -* -* Currently Posix ACLs are the only system namespace extended attribute -* handlers supported by XFS, so we just implement the handlers here. -* If we ever support other system extended attributes this will need -* some refactoring. -*/ - -static int -xfs_decode_acl (const char *name) -{ -if (strcmp (name,"posix_acl_access" ) ==0 ) -return ACL_TYPE_ACCESS ; -else if (strcmp (name,"posix_acl_default" ) ==0 ) -return ACL_TYPE_DEFAULT ; -return -EINVAL ; -} -static int -xfs_xattr_system_get (struct inode *inode,const char *name, -void *value,size_t size) +xfs_xattr_acl_get (struct dentry *dentry,const char *name, +void *value,size_t size,int type) {struct posix_acl *acl; -int type, error; - - type =xfs_decode_acl (name); -if (type <0 ) -return type; +int error; - acl =xfs_get_acl (inode, type); + acl =xfs_get_acl (dentry->d_inode, type);if (IS_ERR (acl))return PTR_ERR (acl);if (acl ==NULL )
@@ -396,15 +373,13 @@ xfs_xattr_system_get(struct inode *inode }static int -xfs_xattr_system_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +xfs_xattr_acl_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) { +struct inode *inode = dentry->d_inode;struct posix_acl *acl =NULL ; -int error =0 , type; +int error =0 ; - type =xfs_decode_acl (name); -if (type <0 ) -return type;if (flags &XATTR_CREATE )return -EINVAL ;if (type ==ACL_TYPE_DEFAULT && !S_ISDIR (inode->i_mode))
@@ -461,8 +436,16 @@ xfs_xattr_system_set(struct inode *inodereturn error; } -struct xattr_handler xfs_xattr_system_handler = { - .prefix =XATTR_SYSTEM_PREFIX , - .get = xfs_xattr_system_get, - .set = xfs_xattr_system_set, +struct xattr_handler xfs_xattr_acl_access_handler = { + .prefix =POSIX_ACL_XATTR_ACCESS , + .flags =ACL_TYPE_ACCESS , + .get = xfs_xattr_acl_get, + .set = xfs_xattr_acl_set, +}; + +struct xattr_handler xfs_xattr_acl_default_handler = { + .prefix =POSIX_ACL_XATTR_DEFAULT , + .flags =ACL_TYPE_DEFAULT , + .get = xfs_xattr_acl_get, + .set = xfs_xattr_acl_set, };
fs/btrfs/acl.c +12 -35
85 lines not on this page · raw message
fs/ext2/acl.c +25 -54
138 lines not on this page · raw message
fs/ext2/xattr.c +7 -4
@@ -60,6 +60,7 @@#include <linux/mbcache.h> #include <linux/quotaops.h> #include <linux/rwsem.h> +#include <linux/security.h> #include "ext2.h" #include "xattr.h" #include "acl.h"
@@ -249,8 +250,9 @@ cleanup:* used / required on success. */ static int -ext2_xattr_list (struct inode *inode,char *buffer,size_t buffer_size) +ext2_xattr_list (struct dentry *dentry,char *buffer,size_t buffer_size) { +struct inode *inode = dentry->d_inode;struct buffer_head *bh =NULL ;struct ext2_xattr_entry *entry;char *end;
@@ -300,9 +302,10 @@ bad_block: ext2_error(inode->i_sb, "ext2ext2_xattr_handler (entry->e_name_index);if (handler) { -size_t size = handler->list (inode, buffer, rest, +size_t size = handler->list (dentry, buffer, rest, entry->e_name, - entry->e_name_len); + entry->e_name_len, + handler->flags);if (buffer) {if (size > rest) { error = -ERANGE ;
@@ -330,7 +333,7 @@ cleanup:ssize_t ext2_listxattr (struct dentry *dentry,char *buffer,size_t size) { -return ext2_xattr_list (dentry->d_inode, buffer, size); +return ext2_xattr_list (dentry, buffer, size); }/*
fs/ext2/xattr_security.c +8 -8
@@ -11,8 +11,8 @@#include "xattr.h" static size_t -ext2_xattr_security_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext2_xattr_security_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const int prefix_len =XATTR_SECURITY_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ;
@@ -26,22 +26,22 @@ ext2_xattr_security_list(struct inode *i }static int -ext2_xattr_security_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext2_xattr_security_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext2_xattr_get (inode,EXT2_XATTR_INDEX_SECURITY , name, +return ext2_xattr_get (dentry->d_inode,EXT2_XATTR_INDEX_SECURITY , name, buffer, size); }static int -ext2_xattr_security_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext2_xattr_security_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext2_xattr_set (inode,EXT2_XATTR_INDEX_SECURITY , name, +return ext2_xattr_set (dentry->d_inode,EXT2_XATTR_INDEX_SECURITY , name, value, size, flags); }
fs/ext2/xattr_trusted.c +8 -8
@@ -13,8 +13,8 @@#include "xattr.h" static size_t -ext2_xattr_trusted_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext2_xattr_trusted_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const int prefix_len =XATTR_TRUSTED_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ;
@@ -31,22 +31,22 @@ ext2_xattr_trusted_list(struct inode *in }static int -ext2_xattr_trusted_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext2_xattr_trusted_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext2_xattr_get (inode,EXT2_XATTR_INDEX_TRUSTED , name, +return ext2_xattr_get (dentry->d_inode,EXT2_XATTR_INDEX_TRUSTED , name, buffer, size); }static int -ext2_xattr_trusted_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext2_xattr_trusted_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext2_xattr_set (inode,EXT2_XATTR_INDEX_TRUSTED , name, +return ext2_xattr_set (dentry->d_inode,EXT2_XATTR_INDEX_TRUSTED , name, value, size, flags); }
fs/ext2/xattr_user.c +13 -12
@@ -12,13 +12,13 @@#include "xattr.h" static size_t -ext2_xattr_user_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext2_xattr_user_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const size_t prefix_len =XATTR_USER_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return 0 ;if (list && total_len <= list_size) {
@@ -30,27 +30,28 @@ ext2_xattr_user_list(struct inode *inode }static int -ext2_xattr_user_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext2_xattr_user_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return -EOPNOTSUPP ; -return ext2_xattr_get (inode,EXT2_XATTR_INDEX_USER , name, buffer, size); +return ext2_xattr_get (dentry->d_inode,EXT2_XATTR_INDEX_USER , + name, buffer, size); }static int -ext2_xattr_user_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext2_xattr_user_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return -EOPNOTSUPP ; -return ext2_xattr_set (inode,EXT2_XATTR_INDEX_USER , name, - value, size, flags); +return ext2_xattr_set (dentry->d_inode,EXT2_XATTR_INDEX_USER , + name, value, size, flags); }struct xattr_handler ext2_xattr_user_handler = {
fs/ext3/acl.c +23 -51
127 lines not on this page · raw message
fs/ext3/xattr.c +17 -14
@@ -99,7 +99,7 @@ static struct buffer_head *ext3_xattr_ca struct mb_cache_entry **);static void ext3_xattr_rehash (struct ext3_xattr_header *,struct ext3_xattr_entry *); -static int ext3_xattr_list (struct inode *inode,char *buffer, +static int ext3_xattr_list (struct dentry *dentry,char *buffer,size_t buffer_size);static struct mb_cache *ext3_xattr_cache;
@@ -147,7 +147,7 @@ ext3_xattr_handler(int name_index)ssize_t ext3_listxattr (struct dentry *dentry,char *buffer,size_t size) { -return ext3_xattr_list (dentry->d_inode, buffer, size); +return ext3_xattr_list (dentry, buffer, size); } static int
@@ -332,7 +332,7 @@ ext3_xattr_get(struct inode *inode, int }static int -ext3_xattr_list_entries (struct inode *inode,struct ext3_xattr_entry *entry, +ext3_xattr_list_entries (struct dentry *dentry,struct ext3_xattr_entry *entry,char *buffer,size_t buffer_size) {size_t rest = buffer_size;
@@ -342,9 +342,10 @@ ext3_xattr_list_entries(struct inode *inext3_xattr_handler (entry->e_name_index);if (handler) { -size_t size = handler->list (inode, buffer, rest, +size_t size = handler->list (dentry, buffer, rest, entry->e_name, - entry->e_name_len); + entry->e_name_len, + handler->flags);if (buffer) {if (size > rest)return -ERANGE ;
@@ -357,8 +358,9 @@ ext3_xattr_list_entries(struct inode *in }static int -ext3_xattr_block_list (struct inode *inode,char *buffer,size_t buffer_size) +ext3_xattr_block_list (struct dentry *dentry,char *buffer,size_t buffer_size) { +struct inode *inode = dentry->d_inode;struct buffer_head *bh =NULL ;int error;
@@ -383,7 +385,7 @@ ext3_xattr_block_list(struct inode *inod goto cleanup; }ext3_xattr_cache_insert (bh); - error =ext3_xattr_list_entries (inode,BFIRST (bh), buffer, buffer_size); + error =ext3_xattr_list_entries (dentry,BFIRST (bh), buffer, buffer_size); cleanup:brelse (bh);
@@ -392,8 +394,9 @@ cleanup: }static int -ext3_xattr_ibody_list (struct inode *inode,char *buffer,size_t buffer_size) +ext3_xattr_ibody_list (struct dentry *dentry,char *buffer,size_t buffer_size) { +struct inode *inode = dentry->d_inode;struct ext3_xattr_ibody_header *header;struct ext3_inode *raw_inode;struct ext3_iloc iloc;
@@ -411,7 +414,7 @@ ext3_xattr_ibody_list(struct inode *inod error =ext3_xattr_check_names (IFIRST (header), end);if (error) goto cleanup; - error =ext3_xattr_list_entries (inode,IFIRST (header), + error =ext3_xattr_list_entries (dentry,IFIRST (header), buffer, buffer_size); cleanup:
@@ -430,12 +433,12 @@ cleanup:* used / required on success. */ static int -ext3_xattr_list (struct inode *inode,char *buffer,size_t buffer_size) +ext3_xattr_list (struct dentry *dentry,char *buffer,size_t buffer_size) {int i_error, b_error; -down_read (&EXT3_I (inode)->xattr_sem); - i_error =ext3_xattr_ibody_list (inode, buffer, buffer_size); +down_read (&EXT3_I (dentry->d_inode)->xattr_sem); + i_error =ext3_xattr_ibody_list (dentry, buffer, buffer_size);if (i_error <0 ) { b_error =0 ; }else {
@@ -443,11 +446,11 @@ ext3_xattr_list(struct inode *inode, cha buffer += i_error; buffer_size -= i_error; } - b_error =ext3_xattr_block_list (inode, buffer, buffer_size); + b_error =ext3_xattr_block_list (dentry, buffer, buffer_size);if (b_error <0 ) i_error =0 ; } -up_read (&EXT3_I (inode)->xattr_sem); +up_read (&EXT3_I (dentry->d_inode)->xattr_sem);return i_error + b_error; }
fs/ext3/xattr_security.c +10 -10
@@ -12,8 +12,8 @@#include "xattr.h" static size_t -ext3_xattr_security_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext3_xattr_security_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const size_t prefix_len =XATTR_SECURITY_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ;
@@ -28,23 +28,23 @@ ext3_xattr_security_list(struct inode *i }static int -ext3_xattr_security_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext3_xattr_security_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext3_xattr_get (inode,EXT3_XATTR_INDEX_SECURITY , name, - buffer, size); +return ext3_xattr_get (dentry->d_inode,EXT3_XATTR_INDEX_SECURITY , + name, buffer, size); }static int -ext3_xattr_security_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext3_xattr_security_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext3_xattr_set (inode,EXT3_XATTR_INDEX_SECURITY , name, - value, size, flags); +return ext3_xattr_set (dentry->d_inode,EXT3_XATTR_INDEX_SECURITY , + name, value, size, flags); }int
fs/ext3/xattr_trusted.c +9 -9
@@ -14,8 +14,8 @@#include "xattr.h" static size_t -ext3_xattr_trusted_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext3_xattr_trusted_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const size_t prefix_len =XATTR_TRUSTED_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ;
@@ -32,22 +32,22 @@ ext3_xattr_trusted_list(struct inode *in }static int -ext3_xattr_trusted_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext3_xattr_trusted_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext3_xattr_get (inode,EXT3_XATTR_INDEX_TRUSTED , name, - buffer, size); +return ext3_xattr_get (dentry->d_inode,EXT3_XATTR_INDEX_TRUSTED , + name, buffer, size); }static int -ext3_xattr_trusted_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext3_xattr_trusted_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext3_xattr_set (inode,EXT3_XATTR_INDEX_TRUSTED , name, +return ext3_xattr_set (dentry->d_inode,EXT3_XATTR_INDEX_TRUSTED , name, value, size, flags); }
fs/ext3/xattr_user.c +13 -12
@@ -13,13 +13,13 @@#include "xattr.h" static size_t -ext3_xattr_user_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext3_xattr_user_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const size_t prefix_len =XATTR_USER_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return 0 ;if (list && total_len <= list_size) {
@@ -31,26 +31,27 @@ ext3_xattr_user_list(struct inode *inode }static int -ext3_xattr_user_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext3_xattr_user_get (struct dentry *dentry,const char *name,void *buffer, +size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return -EOPNOTSUPP ; -return ext3_xattr_get (inode,EXT3_XATTR_INDEX_USER , name, buffer, size); +return ext3_xattr_get (dentry->d_inode,EXT3_XATTR_INDEX_USER , + name, buffer, size); }static int -ext3_xattr_user_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext3_xattr_user_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return -EOPNOTSUPP ; -return ext3_xattr_set (inode,EXT3_XATTR_INDEX_USER , name, - value, size, flags); +return ext3_xattr_set (dentry->d_inode,EXT3_XATTR_INDEX_USER , + name, value, size, flags); }struct xattr_handler ext3_xattr_user_handler = {
fs/ext4/acl.c +23 -51
127 lines not on this page · raw message
fs/ext4/xattr.c +17 -14
@@ -92,7 +92,7 @@ static struct buffer_head *ext4_xattr_ca struct mb_cache_entry **);static void ext4_xattr_rehash (struct ext4_xattr_header *,struct ext4_xattr_entry *); -static int ext4_xattr_list (struct inode *inode,char *buffer, +static int ext4_xattr_list (struct dentry *dentry,char *buffer,size_t buffer_size);static struct mb_cache *ext4_xattr_cache;
@@ -140,7 +140,7 @@ ext4_xattr_handler(int name_index)ssize_t ext4_listxattr (struct dentry *dentry,char *buffer,size_t size) { -return ext4_xattr_list (dentry->d_inode, buffer, size); +return ext4_xattr_list (dentry, buffer, size); } static int
@@ -325,7 +325,7 @@ ext4_xattr_get(struct inode *inode, int }static int -ext4_xattr_list_entries (struct inode *inode,struct ext4_xattr_entry *entry, +ext4_xattr_list_entries (struct dentry *dentry,struct ext4_xattr_entry *entry,char *buffer,size_t buffer_size) {size_t rest = buffer_size;
@@ -335,9 +335,10 @@ ext4_xattr_list_entries(struct inode *inext4_xattr_handler (entry->e_name_index);if (handler) { -size_t size = handler->list (inode, buffer, rest, +size_t size = handler->list (dentry, buffer, rest, entry->e_name, - entry->e_name_len); + entry->e_name_len, + handler->flags);if (buffer) {if (size > rest)return -ERANGE ;
@@ -350,8 +351,9 @@ ext4_xattr_list_entries(struct inode *in }static int -ext4_xattr_block_list (struct inode *inode,char *buffer,size_t buffer_size) +ext4_xattr_block_list (struct dentry *dentry,char *buffer,size_t buffer_size) { +struct inode *inode = dentry->d_inode;struct buffer_head *bh =NULL ;int error;
@@ -376,7 +378,7 @@ ext4_xattr_block_list(struct inode *inod goto cleanup; }ext4_xattr_cache_insert (bh); - error =ext4_xattr_list_entries (inode,BFIRST (bh), buffer, buffer_size); + error =ext4_xattr_list_entries (dentry,BFIRST (bh), buffer, buffer_size); cleanup:brelse (bh);
@@ -385,8 +387,9 @@ cleanup: }static int -ext4_xattr_ibody_list (struct inode *inode,char *buffer,size_t buffer_size) +ext4_xattr_ibody_list (struct dentry *dentry,char *buffer,size_t buffer_size) { +struct inode *inode = dentry->d_inode;struct ext4_xattr_ibody_header *header;struct ext4_inode *raw_inode;struct ext4_iloc iloc;
@@ -404,7 +407,7 @@ ext4_xattr_ibody_list(struct inode *inod error =ext4_xattr_check_names (IFIRST (header), end);if (error) goto cleanup; - error =ext4_xattr_list_entries (inode,IFIRST (header), + error =ext4_xattr_list_entries (dentry,IFIRST (header), buffer, buffer_size); cleanup:
@@ -423,12 +426,12 @@ cleanup:* used / required on success. */ static int -ext4_xattr_list (struct inode *inode,char *buffer,size_t buffer_size) +ext4_xattr_list (struct dentry *dentry,char *buffer,size_t buffer_size) {int i_error, b_error; -down_read (&EXT4_I (inode)->xattr_sem); - i_error =ext4_xattr_ibody_list (inode, buffer, buffer_size); +down_read (&EXT4_I (dentry->d_inode)->xattr_sem); + i_error =ext4_xattr_ibody_list (dentry, buffer, buffer_size);if (i_error <0 ) { b_error =0 ; }else {
@@ -436,11 +439,11 @@ ext4_xattr_list(struct inode *inode, cha buffer += i_error; buffer_size -= i_error; } - b_error =ext4_xattr_block_list (inode, buffer, buffer_size); + b_error =ext4_xattr_block_list (dentry, buffer, buffer_size);if (b_error <0 ) i_error =0 ; } -up_read (&EXT4_I (inode)->xattr_sem); +up_read (&EXT4_I (dentry->d_inode)->xattr_sem);return i_error + b_error; }
fs/ext4/xattr_security.c +10 -10
@@ -12,8 +12,8 @@#include "xattr.h" static size_t -ext4_xattr_security_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext4_xattr_security_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const size_t prefix_len =sizeof (XATTR_SECURITY_PREFIX )-1 ;const size_t total_len = prefix_len + name_len +1 ;
@@ -28,23 +28,23 @@ ext4_xattr_security_list(struct inode *i }static int -ext4_xattr_security_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext4_xattr_security_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext4_xattr_get (inode,EXT4_XATTR_INDEX_SECURITY , name, - buffer, size); +return ext4_xattr_get (dentry->d_inode,EXT4_XATTR_INDEX_SECURITY , + name, buffer, size); }static int -ext4_xattr_security_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext4_xattr_security_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext4_xattr_set (inode,EXT4_XATTR_INDEX_SECURITY , name, - value, size, flags); +return ext4_xattr_set (dentry->d_inode,EXT4_XATTR_INDEX_SECURITY , + name, value, size, flags); }int
fs/ext4/xattr_trusted.c +10 -10
@@ -14,8 +14,8 @@#include "xattr.h" static size_t -ext4_xattr_trusted_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext4_xattr_trusted_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const size_t prefix_len =XATTR_TRUSTED_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ;
@@ -32,23 +32,23 @@ ext4_xattr_trusted_list(struct inode *in }static int -ext4_xattr_trusted_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext4_xattr_trusted_get (struct dentry *dentry,const char *name,void *buffer, +size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext4_xattr_get (inode,EXT4_XATTR_INDEX_TRUSTED , name, - buffer, size); +return ext4_xattr_get (dentry->d_inode,EXT4_XATTR_INDEX_TRUSTED , + name, buffer, size); }static int -ext4_xattr_trusted_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext4_xattr_trusted_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return ext4_xattr_set (inode,EXT4_XATTR_INDEX_TRUSTED , name, - value, size, flags); +return ext4_xattr_set (dentry->d_inode,EXT4_XATTR_INDEX_TRUSTED , + name, value, size, flags); }struct xattr_handler ext4_xattr_trusted_handler = {
fs/ext4/xattr_user.c +13 -12
@@ -13,13 +13,13 @@#include "xattr.h" static size_t -ext4_xattr_user_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +ext4_xattr_user_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int type) {const size_t prefix_len =XATTR_USER_PREFIX_LEN ;const size_t total_len = prefix_len + name_len +1 ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return 0 ;if (list && total_len <= list_size) {
@@ -31,26 +31,27 @@ ext4_xattr_user_list(struct inode *inode }static int -ext4_xattr_user_get (struct inode *inode,const char *name, -void *buffer,size_t size) +ext4_xattr_user_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return -EOPNOTSUPP ; -return ext4_xattr_get (inode,EXT4_XATTR_INDEX_USER , name, buffer, size); +return ext4_xattr_get (dentry->d_inode,EXT4_XATTR_INDEX_USER , + name, buffer, size); }static int -ext4_xattr_user_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +ext4_xattr_user_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -if (!test_opt (inode->i_sb,XATTR_USER )) +if (!test_opt (dentry->d_sb,XATTR_USER ))return -EOPNOTSUPP ; -return ext4_xattr_set (inode,EXT4_XATTR_INDEX_USER , name, - value, size, flags); +return ext4_xattr_set (dentry->d_inode,EXT4_XATTR_INDEX_USER , + name, value, size, flags); }struct xattr_handler ext4_xattr_user_handler = {
fs/gfs2/acl.c +8 -7
@@ -185,6 +185,7 @@ static int munge_mode(struct gfs2_inodeint gfs2_acl_create (struct gfs2_inode *dip,struct gfs2_inode *ip) { +struct inode *inode = &ip->i_inode;struct gfs2_ea_location el;struct gfs2_sbd *sdp =GFS2_SB (&dip->i_inode);struct posix_acl *acl =NULL , *clone;
@@ -195,7 +196,7 @@ int gfs2_acl_create(struct gfs2_inode *dif (!sdp->sd_args.ar_posix_acl)return 0 ; -if (S_ISLNK (ip->i_inode.i_mode)) +if (S_ISLNK (inode->i_mode))return 0 ; error =acl_get (dip,GFS2_POSIX_ACL_DEFAULT , &acl, &el, &data, &len);
@@ -204,7 +205,7 @@ int gfs2_acl_create(struct gfs2_inode *dreturn error;if (!acl) { mode &= ~current_umask (); -if (mode != ip->i_inode.i_mode) +if (mode != inode->i_mode) error =munge_mode (ip, mode);return error; }
@@ -216,9 +217,9 @@ int gfs2_acl_create(struct gfs2_inode *dposix_acl_release (acl); acl = clone; -if (S_ISDIR (ip->i_inode.i_mode)) { - error =gfs2_xattr_set (&ip->i_inode,GFS2_EATYPE_SYS , -GFS2_POSIX_ACL_DEFAULT , data, len,0 ); +if (S_ISDIR (inode->i_mode)) { + error =__gfs2_xattr_set (inode,GFS2_POSIX_ACL_DEFAULT , data, + len,0 ,GFS2_EATYPE_SYS );if (error) goto out; }
@@ -230,8 +231,8 @@ int gfs2_acl_create(struct gfs2_inode *d goto munge;posix_acl_to_xattr (acl, data, len); - error =gfs2_xattr_set (&ip->i_inode,GFS2_EATYPE_SYS , -GFS2_POSIX_ACL_ACCESS , data, len,0 ); + error =__gfs2_xattr_set (inode,GFS2_POSIX_ACL_ACCESS , data, len,0 , +GFS2_EATYPE_SYS );if (error) goto out; munge:
fs/gfs2/inode.c +2 -1
@@ -801,7 +801,8 @@ static int gfs2_security_init(struct gfsreturn err; } - err =gfs2_xattr_set (&ip->i_inode,GFS2_EATYPE_SECURITY , name, value, len,0 ); + err =__gfs2_xattr_set (&ip->i_inode, name, value, len,0 , +GFS2_EATYPE_SECURITY );kfree (value);kfree (name);
fs/gfs2/xattr.c +29 -57
158 lines not on this page · raw message
fs/gfs2/xattr.h +3 -4
@@ -53,10 +53,9 @@ struct gfs2_ea_location {struct gfs2_ea_header *el_prev; }; -extern int gfs2_xattr_get (struct inode *inode,int type,const char *name, -void *buffer,size_t size); -extern int gfs2_xattr_set (struct inode *inode,int type,const char *name, -const void *value,size_t size,int flags); +extern int __gfs2_xattr_set (struct inode *inode,const char *name, +const void *value,size_t size, +int flags,int type);extern ssize_t gfs2_listxattr (struct dentry *dentry,char *buffer,size_t size);extern int gfs2_ea_dealloc (struct gfs2_inode *ip);
fs/jffs2/acl.c +22 -43
114 lines not on this page · raw message
fs/jffs2/security.c +10 -8
@@ -44,26 +44,28 @@ int jffs2_init_security(struct inode *in }/* ---- XATTR Handler for "security.*" ----------------- */ -static int jffs2_security_getxattr (struct inode *inode,const char *name, -void *buffer,size_t size) +static int jffs2_security_getxattr (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (!strcmp (name,"" ))return -EINVAL ; -return do_jffs2_getxattr (inode,JFFS2_XPREFIX_SECURITY , name, buffer, size); +return do_jffs2_getxattr (dentry->d_inode,JFFS2_XPREFIX_SECURITY , + name, buffer, size); } -static int jffs2_security_setxattr (struct inode *inode,const char *name,const void *buffer, -size_t size,int flags) +static int jffs2_security_setxattr (struct dentry *dentry,const char *name, +const void *buffer,size_t size,int flags,int type) {if (!strcmp (name,"" ))return -EINVAL ; -return do_jffs2_setxattr (inode,JFFS2_XPREFIX_SECURITY , name, buffer, size, flags); +return do_jffs2_setxattr (dentry->d_inode,JFFS2_XPREFIX_SECURITY , + name, buffer, size, flags); } -static size_t jffs2_security_listxattr (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +static size_t jffs2_security_listxattr (struct dentry *dentry,char *list, +size_t list_size,const char *name,size_t name_len,int type) {size_t retlen =XATTR_SECURITY_PREFIX_LEN + name_len +1 ;
fs/jffs2/xattr.c +4 -2
@@ -990,9 +990,11 @@ ssize_t jffs2_listxattr(struct dentry *dif (!xhandle)continue ;if (buffer) { - rc = xhandle->list (inode, buffer+len, size-len, xd->xname, xd->name_len); + rc = xhandle->list (dentry, buffer+len, size-len, + xd->xname, xd->name_len, xd->flags); }else { - rc = xhandle->list (inode,NULL ,0 , xd->xname, xd->name_len); + rc = xhandle->list (dentry,NULL ,0 , xd->xname, + xd->name_len, xd->flags); }if (rc <0 ) goto out;
fs/jffs2/xattr_trusted.c +10 -8
@@ -16,24 +16,26 @@#include <linux/mtd/mtd.h> #include "nodelist.h" -static int jffs2_trusted_getxattr (struct inode *inode,const char *name, -void *buffer,size_t size) +static int jffs2_trusted_getxattr (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (!strcmp (name,"" ))return -EINVAL ; -return do_jffs2_getxattr (inode,JFFS2_XPREFIX_TRUSTED , name, buffer, size); +return do_jffs2_getxattr (dentry->d_inode,JFFS2_XPREFIX_TRUSTED , + name, buffer, size); } -static int jffs2_trusted_setxattr (struct inode *inode,const char *name,const void *buffer, -size_t size,int flags) +static int jffs2_trusted_setxattr (struct dentry *dentry,const char *name, +const void *buffer,size_t size,int flags,int type) {if (!strcmp (name,"" ))return -EINVAL ; -return do_jffs2_setxattr (inode,JFFS2_XPREFIX_TRUSTED , name, buffer, size, flags); +return do_jffs2_setxattr (dentry->d_inode,JFFS2_XPREFIX_TRUSTED , + name, buffer, size, flags); } -static size_t jffs2_trusted_listxattr (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +static size_t jffs2_trusted_listxattr (struct dentry *dentry,char *list, +size_t list_size,const char *name,size_t name_len,int type) {size_t retlen =XATTR_TRUSTED_PREFIX_LEN + name_len +1 ;
fs/jffs2/xattr_user.c +10 -8
@@ -16,24 +16,26 @@#include <linux/mtd/mtd.h> #include "nodelist.h" -static int jffs2_user_getxattr (struct inode *inode,const char *name, -void *buffer,size_t size) +static int jffs2_user_getxattr (struct dentry *dentry,const char *name, +void *buffer,size_t size,int type) {if (!strcmp (name,"" ))return -EINVAL ; -return do_jffs2_getxattr (inode,JFFS2_XPREFIX_USER , name, buffer, size); +return do_jffs2_getxattr (dentry->d_inode,JFFS2_XPREFIX_USER , + name, buffer, size); } -static int jffs2_user_setxattr (struct inode *inode,const char *name,const void *buffer, -size_t size,int flags) +static int jffs2_user_setxattr (struct dentry *dentry,const char *name, +const void *buffer,size_t size,int flags,int type) {if (!strcmp (name,"" ))return -EINVAL ; -return do_jffs2_setxattr (inode,JFFS2_XPREFIX_USER , name, buffer, size, flags); +return do_jffs2_setxattr (dentry->d_inode,JFFS2_XPREFIX_USER , + name, buffer, size, flags); } -static size_t jffs2_user_listxattr (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +static size_t jffs2_user_listxattr (struct dentry *dentry,char *list, +size_t list_size,const char *name,size_t name_len,int type) {size_t retlen =XATTR_USER_PREFIX_LEN + name_len +1 ;
fs/ocfs2/acl.c +25 -62
143 lines not on this page · raw message
fs/ocfs2/xattr.c +35 -37
160 lines not on this page · raw message
fs/reiserfs/xattr.c +18 -18
@@ -48,6 +48,7 @@#include <net/checksum.h> #include <linux/stat.h> #include <linux/quotaops.h> +#include <linux/security.h> #define PRIVROOT_NAME ".reiserfs_priv"#define XAROOT_NAME "xattrs"
@@ -726,15 +727,14 @@ ssize_t reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer, size_t size) { - struct inode *inode = dentry->d_inode; struct xattr_handler *handler; - handler =find_xattr_handler_prefix (inode->i_sb->s_xattr, name); + handler =find_xattr_handler_prefix (dentry->d_sb->s_xattr, name); -if (!handler ||get_inode_sd_version (inode) ==STAT_DATA_V1 ) +if (!handler ||get_inode_sd_version (dentry->d_inode) ==STAT_DATA_V1 )return -EOPNOTSUPP ; -return handler->get (inode, name, buffer, size); +return handler->get (dentry, name, buffer, size, handler->flags); }/*
@@ -746,15 +746,14 @@ int reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) { - struct inode *inode = dentry->d_inode; struct xattr_handler *handler; - handler =find_xattr_handler_prefix (inode->i_sb->s_xattr, name); + handler =find_xattr_handler_prefix (dentry->d_sb->s_xattr, name); -if (!handler ||get_inode_sd_version (inode) ==STAT_DATA_V1 ) +if (!handler ||get_inode_sd_version (dentry->d_inode) ==STAT_DATA_V1 )return -EOPNOTSUPP ; -return handler->set (inode, name, value, size, flags); +return handler->set (dentry, name, value, size, flags, handler->flags); }/*
@@ -764,21 +763,20 @@ reiserfs_setxattr(struct dentry *dentry,*/ int reiserfs_removexattr (struct dentry *dentry,const char *name) { -struct inode *inode = dentry->d_inode;struct xattr_handler *handler; - handler =find_xattr_handler_prefix (inode->i_sb->s_xattr, name); + handler =find_xattr_handler_prefix (dentry->d_sb->s_xattr, name); -if (!handler ||get_inode_sd_version (inode) ==STAT_DATA_V1 ) +if (!handler ||get_inode_sd_version (dentry->d_inode) ==STAT_DATA_V1 )return -EOPNOTSUPP ; -return handler->set (inode, name,NULL ,0 ,XATTR_REPLACE ); +return handler->set (dentry, name,NULL ,0 ,XATTR_REPLACE , handler->flags); }struct listxattr_buf {size_t size;size_t pos;char *buf; -struct inode *inode; +struct dentry *dentry; }; static int listxattr_filler(void *buf, const char *name, int namelen,
@@ -789,17 +787,19 @@ static int listxattr_filler(void *buf, cif (name[0 ] !='.' || (namelen !=1 && (name[1 ] !='.' || namelen !=2 ))) {struct xattr_handler *handler; - handler =find_xattr_handler_prefix (b->inode->i_sb->s_xattr, + handler =find_xattr_handler_prefix (b->dentry->d_sb->s_xattr, name);if (!handler)/* Unsupported xattr name */ return 0 ;if (b->buf) { - size = handler->list (b->inode, b->buf + b->pos, - b->size, name, namelen); + size = handler->list (b->dentry, b->buf + b->pos, + b->size, name, namelen, + handler->flags);if (size > b->size)return -ERANGE ; }else { - size = handler->list (b->inode,NULL ,0 , name, namelen); + size = handler->list (b->dentry,NULL ,0 , name, + namelen, handler->flags); } b->pos += size;
@@ -820,7 +820,7 @@ ssize_t reiserfs_listxattr(struct dentryint err =0 ;loff_t pos =0 ;struct listxattr_buf buf = { - .inode = dentry->d_inode, + .dentry = dentry, .buf = buffer, .size = buffer ? size :0 , };
fs/reiserfs/xattr_acl.c +19 -50
114 lines not on this page · raw message
fs/reiserfs/xattr_security.c +11 -10
@@ -8,36 +8,37 @@#include <asm/uaccess.h> static int -security_get (struct inode *inode,const char *name,void *buffer,size_t size) +security_get (struct dentry *dentry,const char *name,void *buffer,size_t size, +int handler_flags) {if (strlen (name) <sizeof (XATTR_SECURITY_PREFIX ))return -EINVAL ; -if (IS_PRIVATE (inode)) +if (IS_PRIVATE (dentry->d_inode))return -EPERM ; -return reiserfs_xattr_get (inode, name, buffer, size); +return reiserfs_xattr_get (dentry->d_inode, name, buffer, size); }static int -security_set (struct inode *inode,const char *name,const void *buffer, -size_t size,int flags) +security_set (struct dentry *dentry,const char *name,const void *buffer, +size_t size,int flags,int handler_flags) {if (strlen (name) <sizeof (XATTR_SECURITY_PREFIX ))return -EINVAL ; -if (IS_PRIVATE (inode)) +if (IS_PRIVATE (dentry->d_inode))return -EPERM ; -return reiserfs_xattr_set (inode, name, buffer, size, flags); +return reiserfs_xattr_set (dentry->d_inode, name, buffer, size, flags); } -static size_t security_list (struct inode *inode,char *list,size_t list_len, -const char *name,size_t namelen) +static size_t security_list (struct dentry *dentry,char *list,size_t list_len, +const char *name,size_t namelen,int handler_flags) {const size_t len = namelen +1 ; -if (IS_PRIVATE (inode)) +if (IS_PRIVATE (dentry->d_inode))return 0 ;if (list && len <= list_len) {
fs/reiserfs/xattr_trusted.c +11 -10
@@ -8,36 +8,37 @@#include <asm/uaccess.h> static int -trusted_get (struct inode *inode,const char *name,void *buffer,size_t size) +trusted_get (struct dentry *dentry,const char *name,void *buffer,size_t size, +int handler_flags) {if (strlen (name) <sizeof (XATTR_TRUSTED_PREFIX ))return -EINVAL ; -if (!capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (inode)) +if (!capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (dentry->d_inode))return -EPERM ; -return reiserfs_xattr_get (inode, name, buffer, size); +return reiserfs_xattr_get (dentry->d_inode, name, buffer, size); }static int -trusted_set (struct inode *inode,const char *name,const void *buffer, -size_t size,int flags) +trusted_set (struct dentry *dentry,const char *name,const void *buffer, +size_t size,int flags,int handler_flags) {if (strlen (name) <sizeof (XATTR_TRUSTED_PREFIX ))return -EINVAL ; -if (!capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (inode)) +if (!capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (dentry->d_inode))return -EPERM ; -return reiserfs_xattr_set (inode, name, buffer, size, flags); +return reiserfs_xattr_set (dentry->d_inode, name, buffer, size, flags); } -static size_t trusted_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +static size_t trusted_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int handler_flags) {const size_t len = name_len +1 ; -if (!capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (inode)) +if (!capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (dentry->d_inode))return 0 ;if (list && len <= list_size) {
fs/reiserfs/xattr_user.c +11 -10
@@ -7,34 +7,35 @@#include <asm/uaccess.h> static int -user_get (struct inode *inode,const char *name,void *buffer,size_t size) +user_get (struct dentry *dentry,const char *name,void *buffer,size_t size, +int handler_flags) {if (strlen (name) <sizeof (XATTR_USER_PREFIX ))return -EINVAL ; -if (!reiserfs_xattrs_user (inode->i_sb)) +if (!reiserfs_xattrs_user (dentry->d_sb))return -EOPNOTSUPP ; -return reiserfs_xattr_get (inode, name, buffer, size); +return reiserfs_xattr_get (dentry->d_inode, name, buffer, size); }static int -user_set (struct inode *inode,const char *name,const void *buffer, -size_t size,int flags) +user_set (struct dentry *dentry,const char *name,const void *buffer, +size_t size,int flags,int handler_flags) {if (strlen (name) <sizeof (XATTR_USER_PREFIX ))return -EINVAL ; -if (!reiserfs_xattrs_user (inode->i_sb)) +if (!reiserfs_xattrs_user (dentry->d_sb))return -EOPNOTSUPP ; -return reiserfs_xattr_set (inode, name, buffer, size, flags); +return reiserfs_xattr_set (dentry->d_inode, name, buffer, size, flags); } -static size_t user_list (struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len) +static size_t user_list (struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int handler_flags) {const size_t len = name_len +1 ; -if (!reiserfs_xattrs_user (inode->i_sb)) +if (!reiserfs_xattrs_user (dentry->d_sb))return 0 ;if (list && len <= list_size) {memcpy (list, name, name_len);
fs/xattr.c +14 -14
@@ -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,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);
fs/xfs/linux-2.6/xfs_xattr.c +15 -56
110 lines not on this page · raw message
fs/xfs/xfs_acl.h +2 -1
@@ -49,7 +49,8 @@ extern int xfs_acl_chmod(struct inode *iextern int posix_acl_access_exists (struct inode *inode);extern int posix_acl_default_exists (struct inode *inode); -extern struct xattr_handler xfs_xattr_system_handler; +extern struct xattr_handler xfs_xattr_acl_access_handler; +extern struct xattr_handler xfs_xattr_acl_default_handler;#else # define xfs_check_acl NULL# define xfs_get_acl (inode, type) NULL
include/linux/xattr.h +7 -6
@@ -38,12 +38,13 @@ struct dentry;struct xattr_handler {char *prefix; -size_t (*list)(struct inode *inode,char *list,size_t list_size, -const char *name,size_t name_len); -int (*get)(struct inode *inode,const char *name,void *buffer, -size_t size); -int (*set)(struct inode *inode,const char *name,const void *buffer, -size_t size,int flags); +int flags;/* fs private flags passed back to the handlers */ +size_t (*list)(struct dentry *dentry,char *list,size_t list_size, +const char *name,size_t name_len,int handler_flags); +int (*get)(struct dentry *dentry,const char *name,void *buffer, +size_t size,int handler_flags); +int (*set)(struct dentry *dentry,const char *name,const void *buffer, +size_t size,int flags,int handler_flags); };ssize_t xattr_getsecurity (struct inode *,const char *,void *,size_t );
mm/shmem.c +10 -9
@@ -2036,27 +2036,28 @@ static const struct inode_operations shm* filesystem level, though. */ -static size_t shmem_xattr_security_list (struct inode *inode,char *list, +static size_t shmem_xattr_security_list (struct dentry *dentry,char *list,size_t list_len,const char *name, -size_t name_len) +size_t name_len,int handler_flags) { -return security_inode_listsecurity (inode, list, list_len); +return security_inode_listsecurity (dentry->d_inode, list, list_len); } -static int shmem_xattr_security_get (struct inode *inode,const char *name, -void *buffer,size_t size) +static int shmem_xattr_security_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int handler_flags) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return xattr_getsecurity (inode, name, buffer, size); +return xattr_getsecurity (dentry->d_inode, name, buffer, size); } -static int shmem_xattr_security_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +static int shmem_xattr_security_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int handler_flags) {if (strcmp (name,"" ) ==0 )return -EINVAL ; -return security_inode_setsecurity (inode, name, value, size, flags); +return security_inode_setsecurity (dentry->d_inode, name, value, + size, flags); }static struct xattr_handler shmem_xattr_security_handler = {
mm/shmem_acl.c +20 -58
106 lines not on this page · raw message