Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6
[pandora-kernel.git] / fs / reiserfs / xattr_user.c
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 static int
10 user_get(struct inode *inode, const char *name, void *buffer, size_t size)
11 {
12
13         if (strlen(name) < sizeof(XATTR_USER_PREFIX))
14                 return -EINVAL;
15         if (!reiserfs_xattrs_user(inode->i_sb))
16                 return -EOPNOTSUPP;
17         return reiserfs_xattr_get(inode, name, buffer, size);
18 }
19
20 static int
21 user_set(struct inode *inode, const char *name, const void *buffer,
22          size_t size, int flags)
23 {
24         if (strlen(name) < sizeof(XATTR_USER_PREFIX))
25                 return -EINVAL;
26
27         if (!reiserfs_xattrs_user(inode->i_sb))
28                 return -EOPNOTSUPP;
29         return reiserfs_xattr_set(inode, name, buffer, size, flags);
30 }
31
32 static size_t user_list(struct inode *inode, 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(inode->i_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 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 };