reiserfs: use generic xattr handlers
PATCH 6/11 reiserfs: use generic xattr handlers
Christoph Hellwig had asked me quite some time ago to port the reiserfs xattrs to the generic xattr interface.
This patch replaces the reiserfs-specific xattr handling code with the generic struct xattr_handler.
However, since reiserfs doesn't split the prefix and name when accessing xattrs, it can't leverage generic_{set,get,list,remove}xattr without needlessly reconstructing the name on the back end.
fs/reiserfs/super.c | 7 fs/reiserfs/xattr.c | 419 ++++++++++++++--------------------------- fs/reiserfs/xattr_acl.c | 72 ++----- fs/reiserfs/xattr_security.c | 26 -- fs/reiserfs/xattr_trusted.c | 45 +--- fs/reiserfs/xattr_user.c | 30 -- include/linux/reiserfs_acl.h | 16 - include/linux/reiserfs_fs_sb.h | 3 include/linux/reiserfs_xattr.h | 30 -- 9 files changed, 202 insertions(+), 446 deletions(-)
Signed-off-by Jeff Mahoney <[email protected]>
fs/reiserfs/super.c +0 -7
@@ -2261,9 +2261,6 @@ static int __init init_reiserfs_fs(void)return ret; } -if ((ret =reiserfs_xattr_register_handlers ())) - goto failed_reiserfs_xattr_register_handlers; -reiserfs_proc_info_global_init ();reiserfs_proc_register_global ("version" , reiserfs_global_version_in_proc);
@@ -2274,9 +2271,6 @@ static int __init init_reiserfs_fs(void)return 0 ; } -reiserfs_xattr_unregister_handlers (); - - failed_reiserfs_xattr_register_handlers:reiserfs_proc_unregister_global ("version" );reiserfs_proc_info_global_done ();destroy_inodecache ();
@@ -2286,7 +2280,6 @@ static int __init init_reiserfs_fs(void) static void __exit exit_reiserfs_fs(void) { -reiserfs_xattr_unregister_handlers ();reiserfs_proc_unregister_global ("version" );reiserfs_proc_info_global_done ();unregister_filesystem (&reiserfs_fs_type);
fs/reiserfs/xattr_acl.c +22 -50
119 lines not on this page · raw message
fs/reiserfs/xattr.c +146 -273
579 lines not on this page · raw message
fs/reiserfs/xattr_security.c +8 -18
@@ -33,35 +33,25 @@ security_set(struct inode *inode, constreturn reiserfs_xattr_set (inode, name, buffer, size, flags); } -static int security_del (struct inode *inode,const char *name) +static size_t security_list (struct inode *inode,char *list,size_t list_len, +const char *name,size_t namelen) { -if (strlen (name) <sizeof (XATTR_SECURITY_PREFIX )) -return -EINVAL ; - -if (is_reiserfs_priv_object (inode)) -return -EPERM ; - -return 0 ; -} - -static int -security_list (struct inode *inode,const char *name,int namelen,char *out) -{ -int len = namelen; +const size_t len = namelen +1 ;if (is_reiserfs_priv_object (inode))return 0 ; -if (out) -memcpy (out, name, len); +if (list && len <= list_len) { +memcpy (list, name, namelen); + list[namelen] ='\0' ; + }return len; } -struct reiserfs_xattr_handler security_handler = { +struct xattr_handler reiserfs_xattr_security_handler = { .prefix =XATTR_SECURITY_PREFIX , .get = security_get, .set = security_set, - .del = security_del, .list = security_list, };
fs/reiserfs/xattr_trusted.c +11 -34
71 lines not on this page · raw message
fs/reiserfs/xattr_user.c +8 -22
@@ -6,10 +6,6 @@#include <linux/reiserfs_xattr.h> #include <asm/uaccess.h> -#ifdef CONFIG_REISERFS_FS_POSIX_ACL -# include <linux/reiserfs_acl.h> -#endif -#define XATTR_USER_PREFIX "user." static int
@@ -36,33 +32,23 @@ user_set(struct inode *inode, const charreturn reiserfs_xattr_set (inode, name, buffer, size, flags); } -static int user_del (struct inode *inode,const char *name) +static size_t user_list (struct inode *inode,char *list,size_t list_size, +const char *name,size_t name_len) { -if (strlen (name) <sizeof (XATTR_USER_PREFIX )) -return -EINVAL ; +const size_t len = name_len +1 ;if (!reiserfs_xattrs_user (inode->i_sb)) -return -EOPNOTSUPP ; -return 0 ; -} - -static int -user_list (struct inode *inode,const char *name,int namelen,char *out) -{ -int len = namelen; -if (!reiserfs_xattrs_user (inode->i_sb))return 0 ; - -if (out) -memcpy (out, name, len); - +if (list && len <= list_size) { +memcpy (list, name, name_len); + list[name_len] ='\0' ; + }return len; } -struct reiserfs_xattr_handler user_handler = { +struct xattr_handler reiserfs_xattr_user_handler = { .prefix =XATTR_USER_PREFIX , .get = user_get, .set = user_set, - .del = user_del, .list = user_list, };
include/linux/reiserfs_acl.h +2 -14
@@ -52,10 +52,8 @@ int reiserfs_acl_chmod(struct inode *inoint reiserfs_inherit_default_acl (struct inode *dir,struct dentry *dentry,struct inode *inode);int reiserfs_cache_default_acl (struct inode *dir); -extern int reiserfs_xattr_posix_acl_init (void )__init ; -extern int reiserfs_xattr_posix_acl_exit (void ); -extern struct reiserfs_xattr_handler posix_acl_default_handler; -extern struct reiserfs_xattr_handler posix_acl_access_handler; +extern struct xattr_handler reiserfs_posix_acl_default_handler; +extern struct xattr_handler reiserfs_posix_acl_access_handler;#else #define reiserfs_cache_default_acl (inode) 0
@@ -65,16 +63,6 @@ static inline struct posix_acl *reiserfsreturn NULL ; } -static inline int reiserfs_xattr_posix_acl_init (void ) -{ -return 0 ; -} - -static inline int reiserfs_xattr_posix_acl_exit (void ) -{ -return 0 ; -} -static inline int reiserfs_acl_chmod (struct inode *inode) {return 0 ;
include/linux/reiserfs_fs_sb.h +1 -2
@@ -450,7 +450,6 @@ enum reiserfs_mount_options {REISERFS_NO_UNHASHED_RELOCATION ,REISERFS_HASHED_RELOCATION ,REISERFS_ATTRS , -REISERFS_XATTRS ,REISERFS_XATTRS_USER ,REISERFS_POSIXACL , REISERFS_BARRIER_NONE,
@@ -488,7 +487,7 @@ enum reiserfs_mount_options {#define reiserfs_data_log (s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_DATA_LOG))#define reiserfs_data_ordered (s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_DATA_ORDERED))#define reiserfs_data_writeback (s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_DATA_WRITEBACK)) -#define reiserfs_xattrs (s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_XATTRS)) +#define reiserfs_xattrs (s) ((s)->s_xattr != NULL)#define reiserfs_xattrs_user (s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_XATTRS_USER))#define reiserfs_posixacl (s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_POSIXACL))#define reiserfs_xattrs_optional (s) (reiserfs_xattrs_user(s) || reiserfs_posixacl(s))
include/linux/reiserfs_xattr.h +4 -26
@@ -16,20 +16,6 @@ struct reiserfs_xattr_header {#ifdef __KERNEL__ -struct reiserfs_xattr_handler { -char *prefix; -int (*init) (void ); -void (*exit) (void ); -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 (*del) (struct inode * inode,const char *name); -int (*list) (struct inode * inode,const char *name,int namelen, -char *out); -struct list_head handlers; -}; -#ifdef CONFIG_REISERFS_FS_XATTR #define is_reiserfs_priv_object (inode) IS_PRIVATE(inode)#define has_xattr_dir (inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir)
@@ -44,20 +30,15 @@ int reiserfs_chown_xattrs(struct inode *int reiserfs_xattr_init (struct super_block *sb,int mount_flags);int reiserfs_permission (struct inode *inode,int mask,struct nameidata *nd); -int reiserfs_xattr_del (struct inode *,const char *); -int reiserfs_xattr_get (const struct inode *,const char *,void *,size_t ); +int reiserfs_xattr_get (struct inode *,const char *,void *,size_t );int reiserfs_xattr_set (struct inode *,const char *,const void *,size_t ,int ); -extern struct reiserfs_xattr_handler user_handler; -extern struct reiserfs_xattr_handler trusted_handler; +extern struct xattr_handler reiserfs_xattr_user_handler; +extern struct xattr_handler reiserfs_xattr_trusted_handler;#ifdef CONFIG_REISERFS_FS_SECURITY -extern struct reiserfs_xattr_handler security_handler; +extern struct xattr_handler reiserfs_xattr_security_handler;#endif -int reiserfs_xattr_register_handlers (void )__init ; -void reiserfs_xattr_unregister_handlers (void ); - -static inline void reiserfs_mark_inode_private (struct inode *inode) { inode->i_flags |=S_PRIVATE ;
@@ -74,9 +55,6 @@ static inline void reiserfs_mark_inode_p#define reiserfs_permission NULL -#define reiserfs_xattr_register_handlers () 0 -#define reiserfs_xattr_unregister_handlers () -static inline int reiserfs_delete_xattrs (struct inode *inode) {return 0 ;