1 #include <linux/reiserfs_fs.h> 2 #include <linux/errno.h> 3 #include <linux/fs.h> 4 #include <linux/pagemap.h> 5 #include <linux/xattr.h> 6 #include <linux/reiserfs_xattr.h> 7 #include <asm/uaccess.h> 8 9 #ifdef CONFIG_REISERFS_FS_POSIX_ACL 10 # include <linux/reiserfs_acl.h> 11 #endif 12 13 #define XATTR_USER_PREFIX "user." 14 15 static int 16 user_get(struct inode *inode, const char *name, void *buffer, size_t size) 17 { 18 19 if (strlen(name) < sizeof(XATTR_USER_PREFIX)) 20 return -EINVAL; 21 if (!reiserfs_xattrs_user(inode->i_sb)) 22 return -EOPNOTSUPP; 23 return reiserfs_xattr_get(inode, name, buffer, size); 24 } 25 26 static int 27 user_set(struct inode *inode, const char *name, const void *buffer, 28 size_t size, int flags) 29 { 30 31 if (strlen(name) < sizeof(XATTR_USER_PREFIX)) 32 return -EINVAL; 33 34 if (!reiserfs_xattrs_user(inode->i_sb)) 35 return -EOPNOTSUPP; 36 return reiserfs_xattr_set(inode, name, buffer, size, flags); 37 } 38 39 static int user_del(struct inode *inode, const char *name) 40 { 41 if (strlen(name) < sizeof(XATTR_USER_PREFIX)) 42 return -EINVAL; 43 44 if (!reiserfs_xattrs_user(inode->i_sb)) 45 return -EOPNOTSUPP; 46 return 0; 47 } 48 49 static int 50 user_list(struct inode *inode, const char *name, int namelen, char *out) 51 { 52 int len = namelen; 53 if (!reiserfs_xattrs_user(inode->i_sb)) 54 return 0; 55 56 if (out) 57 memcpy(out, name, len); 58 59 return len; 60 } 61 62 struct reiserfs_xattr_handler user_handler = { 63 .prefix = XATTR_USER_PREFIX, 64 .get = user_get, 65 .set = user_set, 66 .del = user_del, 67 .list = user_list, 68 }; 69