sanitize xattr handler prototypes
Subsystems (10)
PATCH 1/2 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/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
Hi,
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 8 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]>Reviewed-by James Morris <[email protected]>Acked-by Joel Becker <[email protected]>
GFS2 bits Acked-by: Steven Whitehouse <[email protected]>
Steve.
Andrew Morton
maintainerQuoted 15 lines · On Tue, 03 Nov 2009 17:11:47 +0000 Steven Whitehouse <[email protected]>…
Hi,
Quoted 12 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.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by James Morris <[email protected]>Acked-by Joel Becker <[email protected]>GFS2 bits Acked-by: Steven Whitehouse <[email protected]>
GFS2 bits Buggered-up-by: Steven Whitehouse <[email protected]>
patching file fs/gfs2/acl.c
Hunk #1 FAILED at 185.
Hunk #2 FAILED at 196.
Hunk #3 FAILED at 205.
Hunk #4 FAILED at 217.
Hunk #5 FAILED at 231.
5 out of 5 hunks FAILED -- saving rejects to file fs/gfs2/acl.c.rej patching file fs/gfs2/inode.c
patching file fs/gfs2/xattr.c
Hunk #1 succeeded at 567 (offset 30 lines).
Hunk #2 succeeded at 1118 (offset 30 lines).
Hunk #3 succeeded at 1129 (offset 30 lines).
Hunk #4 succeeded at 1154 (offset 30 lines).
Hunk #5 succeeded at 1182 (offset 30 lines).
Hunk #6 succeeded at 1222 (offset 30 lines).
Hunk #7 FAILED at 1530.
1 out of 7 hunks FAILED -- saving rejects to file fs/gfs2/xattr.c.rej
linux-next changes have made rather a mess of this patch.
Hi,
Quoted 45 lines · Andrew Morton
Quoted 15 lines · On Tue, 03 Nov 2009 17:11:47 +0000 Steven Whitehouse <[email protected]>…
Hi,
Quoted 12 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.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by James Morris <[email protected]>Acked-by Joel Becker <[email protected]>GFS2 bits Acked-by: Steven Whitehouse <[email protected]>
GFS2 bits Buggered-up-by: Steven Whitehouse <[email protected]>
patching file
fs/gfs2/acl.c
Hunk #1 FAILED at 185.
Hunk #2 FAILED at 196.
Hunk #3 FAILED at 205.
Hunk #4 FAILED at 217.
Hunk #5 FAILED at 231.
5 out of 5 hunks FAILED -- saving rejects to filefs/gfs2/acl.c.rejpatching filefs/gfs2/inode.c
patching filefs/gfs2/xattr.c
Hunk #1 succeeded at 567 (offset 30 lines).
Hunk #2 succeeded at 1118 (offset 30 lines).
Hunk #3 succeeded at 1129 (offset 30 lines).
Hunk #4 succeeded at 1154 (offset 30 lines).
Hunk #5 succeeded at 1182 (offset 30 lines).
Hunk #6 succeeded at 1222 (offset 30 lines).
Hunk #7 FAILED at 1530.
1 out of 7 hunks FAILED -- saving rejects to filefs/gfs2/xattr.c.rej
Quoted 1 line
linux-next changes have made rather a mess of this patch.
The changes required to allow the patch to apply are pretty small, but I'm not really sure about the best path forward at this point :( Updating the patch is easy, but the question is which tree should it go in when its been updated?
Steve.
Quoted 4 lines · Steven Whitehouse
The changes required to allow the patch to apply are pretty small, but I'm not really sure about the best path forward at this point :( Updating the patch is easy, but the question is which tree should it go in when its been updated?
Given that you have a subsystem tree and these patches are in -mm only for now I think you should keep your tree as-is and this patch should be rebased. Given that you figure out how easy that is can you do it for me? That'd avoid having to pull yet another tree onto my far too small SSD :)
Hi,
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Steven Whitehouse
The changes required to allow the patch to apply are pretty small, but I'm not really sure about the best path forward at this point :( Updating the patch is easy, but the question is which tree should it go in when its been updated?
Quoted 6 lines
Given that you have a subsystem tree and these patches are in -mm only for now I think you should keep your tree as-is and this patch should be rebased. Given that you figure out how easy that is can you do it for me? That'd avoid having to pull yet another tree onto my far too small SSD :)
Please find the updated patch below. I've also given it a quick test and all seems to be well.
Steve.
fs/btrfs/acl.c +12 -35
@@ -73,13 +73,13 @@ static struct posix_acl *btrfs_get_acl(struct inode *inode, int type)return acl; } -static int btrfs_xattr_get_acl (struct inode *inode,int type, -void *value,size_t size) +static int btrfs_xattr_acl_get (struct dentry *dentry,const char *name, +void *value,size_t size,int type) {struct posix_acl *acl;int ret =0 ; - acl =btrfs_get_acl (inode, type); + acl =btrfs_get_acl (dentry->d_inode, type);if (IS_ERR (acl))return PTR_ERR (acl);
@@ -151,8 +151,8 @@ out:return ret; } -static int btrfs_xattr_set_acl (struct inode *inode,int type, -const void *value,size_t size) +static int btrfs_xattr_acl_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags,int type) {int ret =0 ;struct posix_acl *acl =NULL ;
@@ -167,38 +167,13 @@ static int btrfs_xattr_set_acl(struct inode *inode, int type, } } - ret =btrfs_set_acl (inode, acl, type); + ret =btrfs_set_acl (dentry->d_inode, acl, type);posix_acl_release (acl);return ret; } - -static int btrfs_xattr_acl_access_get (struct inode *inode,const char *name, -void *value,size_t size) -{ -return btrfs_xattr_get_acl (inode,ACL_TYPE_ACCESS , value, size); -} - -static int btrfs_xattr_acl_access_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) -{ -return btrfs_xattr_set_acl (inode,ACL_TYPE_ACCESS , value, size); -} - -static int btrfs_xattr_acl_default_get (struct inode *inode,const char *name, -void *value,size_t size) -{ -return btrfs_xattr_get_acl (inode,ACL_TYPE_DEFAULT , value, size); -} - -static int btrfs_xattr_acl_default_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) -{ -return btrfs_xattr_set_acl (inode,ACL_TYPE_DEFAULT , value, size); -} -int btrfs_check_acl (struct inode *inode,int mask) {struct posix_acl *acl;
@@ -303,14 +278,16 @@ int btrfs_acl_chmod(struct inode *inode)struct xattr_handler btrfs_xattr_acl_default_handler = { .prefix =POSIX_ACL_XATTR_DEFAULT , - .get = btrfs_xattr_acl_default_get, - .set = btrfs_xattr_acl_default_set, + .flags =ACL_TYPE_DEFAULT , + .get = btrfs_xattr_acl_get, + .set = btrfs_xattr_acl_set, };struct xattr_handler btrfs_xattr_acl_access_handler = { .prefix =POSIX_ACL_XATTR_ACCESS , - .get = btrfs_xattr_acl_access_get, - .set = btrfs_xattr_acl_access_set, + .flags =ACL_TYPE_ACCESS , + .get = btrfs_xattr_acl_get, + .set = btrfs_xattr_acl_set, };#else /* CONFIG_BTRFS_FS_POSIX_ACL */
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, "ext2_xattr_list",ext2_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 *inode, char *list, size_t list_size, }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 *inode, char *list, size_t list_size, }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, char *list, size_t list_size, }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_cache_find(struct inode *, 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 name_index, const char *name, }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 *inode, struct ext3_xattr_entry *entry,ext3_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 *inode, struct ext3_xattr_entry *entry, }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 *inode, char *buffer, size_t buffer_size) 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 *inode, char *buffer, size_t buffer_size) 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, char *buffer, size_t buffer_size) 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 *inode, char *list, size_t list_size, }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 *inode, char *list, size_t list_size, }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, char *list, size_t list_size, }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_cache_find(struct inode *, 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 name_index, const char *name, }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 *inode, struct ext4_xattr_entry *entry,ext4_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 *inode, struct ext4_xattr_entry *entry, }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 *inode, char *buffer, size_t buffer_size) 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 *inode, char *buffer, size_t buffer_size) 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, char *buffer, size_t buffer_size) 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 *inode, char *list, size_t list_size, }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 *inode, char *list, size_t list_size, }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, char *list, size_t list_size, }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 +10 -6
@@ -126,7 +126,7 @@ static int gfs2_acl_set(struct inode *inode, int type, struct posix_acl *acl) error =posix_acl_to_xattr (acl, data, len);if (error <0 ) goto out; - error =gfs2_xattr_set (inode,GFS2_EATYPE_SYS , name, data, len,0 ); + error =__gfs2_xattr_set (inode, name, data, len,0 ,GFS2_EATYPE_SYS );if (!error)set_cached_acl (inode, type, acl); out:
@@ -232,9 +232,10 @@ static int gfs2_acl_type(const char *name)return -EINVAL ; } -static int gfs2_xattr_system_get (struct inode *inode,const char *name, -void *buffer,size_t size) +static int gfs2_xattr_system_get (struct dentry *dentry,const char *name, +void *buffer,size_t size,int xtype) { +struct inode *inode = dentry->d_inode;struct posix_acl *acl;int type;int error;
@@ -255,9 +256,11 @@ static int gfs2_xattr_system_get(struct inode *inode, const char *name,return error; } -static int gfs2_xattr_system_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +static int gfs2_xattr_system_set (struct dentry *dentry,const char *name, +const void *value,size_t size,int flags, +int xtype) { +struct inode *inode = dentry->d_inode;struct gfs2_sbd *sdp =GFS2_SB (inode);struct posix_acl *acl =NULL ;int error =0 , type;
@@ -319,7 +322,7 @@ static int gfs2_xattr_system_set(struct inode *inode, const char *name, } set_acl: - error =gfs2_xattr_set (inode,GFS2_EATYPE_SYS , name, value, size,0 ); + error =__gfs2_xattr_set (inode, name, value, size,0 ,GFS2_EATYPE_SYS );if (!error) {if (acl)set_cached_acl (inode, type, acl);
@@ -334,6 +337,7 @@ out:struct xattr_handler gfs2_xattr_system_handler = { .prefix =XATTR_SYSTEM_PREFIX , + .flags =GFS2_EATYPE_SYS , .get = gfs2_xattr_system_get, .set = gfs2_xattr_system_set, };
fs/gfs2/inode.c +2 -1
@@ -801,7 +801,8 @@ static int gfs2_security_init(struct gfs2_inode *dip, struct gfs2_inode *ip)return 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 +26 -43
137 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 *inode, struct inode *dir) }/* ---- 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 *dentry, char *buffer, size_t size)if (!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, const char *name, const void *value,*/ 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, const char *name, int namelen,if (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 dentry * dentry, char *buffer, size_t size)int 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, const char *name, void *buffer, size_t sssize_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_acl.c +20 -37
80 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 *inode);extern 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 shmem_symlink_inode_operations = {* 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