1 #include "reiserfs.h"
2 #include <linux/errno.h>
3 #include <linux/fs.h>
4 #include <linux/pagemap.h>
5 #include <linux/xattr.h>
6 #include "xattr.h"
7 #include <linux/uaccess.h>
8
9 static int
user_get(const struct xattr_handler * handler,struct dentry * dentry,const char * name,void * buffer,size_t size)10 user_get(const struct xattr_handler *handler, struct dentry *dentry,
11 const char *name, void *buffer, size_t size)
12 {
13 if (!reiserfs_xattrs_user(dentry->d_sb))
14 return -EOPNOTSUPP;
15 return reiserfs_xattr_get(d_inode(dentry),
16 xattr_full_name(handler, name),
17 buffer, size);
18 }
19
20 static int
user_set(const struct xattr_handler * handler,struct dentry * dentry,const char * name,const void * buffer,size_t size,int flags)21 user_set(const struct xattr_handler *handler, struct dentry *dentry,
22 const char *name, const void *buffer, size_t size, int flags)
23 {
24 if (!reiserfs_xattrs_user(dentry->d_sb))
25 return -EOPNOTSUPP;
26 return reiserfs_xattr_set(d_inode(dentry),
27 xattr_full_name(handler, name),
28 buffer, size, flags);
29 }
30
user_list(const struct xattr_handler * handler,struct dentry * dentry,char * list,size_t list_size,const char * name,size_t name_len)31 static size_t user_list(const struct xattr_handler *handler,
32 struct dentry *dentry, char *list, size_t list_size,
33 const char *name, size_t name_len)
34 {
35 const size_t len = name_len + 1;
36
37 if (!reiserfs_xattrs_user(dentry->d_sb))
38 return 0;
39 if (list && len <= list_size) {
40 memcpy(list, name, name_len);
41 list[name_len] = '\0';
42 }
43 return len;
44 }
45
46 const struct xattr_handler reiserfs_xattr_user_handler = {
47 .prefix = XATTR_USER_PREFIX,
48 .get = user_get,
49 .set = user_set,
50 .list = user_list,
51 };
52