]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - fs/reiserfs/xattr_user.c
Merge branches 'for-4.4/upstream-fixes', 'for-4.5/async-suspend', 'for-4.5/container...
[mirror_ubuntu-artful-kernel.git] / fs / reiserfs / xattr_user.c
CommitLineData
f466c6fd 1#include "reiserfs.h"
1da177e4
LT
2#include <linux/errno.h>
3#include <linux/fs.h>
4#include <linux/pagemap.h>
5#include <linux/xattr.h>
c45ac888 6#include "xattr.h"
17093991 7#include <linux/uaccess.h>
1da177e4 8
1da177e4 9static int
d9a82a04
AG
10user_get(const struct xattr_handler *handler, struct dentry *dentry,
11 const char *name, void *buffer, size_t size)
1da177e4
LT
12{
13
bd4c625c
LT
14 if (strlen(name) < sizeof(XATTR_USER_PREFIX))
15 return -EINVAL;
431547b3 16 if (!reiserfs_xattrs_user(dentry->d_sb))
bd4c625c 17 return -EOPNOTSUPP;
2b0143b5 18 return reiserfs_xattr_get(d_inode(dentry), name, buffer, size);
1da177e4
LT
19}
20
21static int
d9a82a04
AG
22user_set(const struct xattr_handler *handler, struct dentry *dentry,
23 const char *name, const void *buffer, size_t size, int flags)
1da177e4 24{
bd4c625c
LT
25 if (strlen(name) < sizeof(XATTR_USER_PREFIX))
26 return -EINVAL;
1da177e4 27
431547b3 28 if (!reiserfs_xattrs_user(dentry->d_sb))
bd4c625c 29 return -EOPNOTSUPP;
2b0143b5 30 return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags);
1da177e4
LT
31}
32
d9a82a04
AG
33static size_t user_list(const struct xattr_handler *handler,
34 struct dentry *dentry, char *list, size_t list_size,
35 const char *name, size_t name_len)
1da177e4 36{
48b32a35 37 const size_t len = name_len + 1;
1da177e4 38
431547b3 39 if (!reiserfs_xattrs_user(dentry->d_sb))
bd4c625c 40 return 0;
48b32a35
JM
41 if (list && len <= list_size) {
42 memcpy(list, name, name_len);
43 list[name_len] = '\0';
44 }
bd4c625c 45 return len;
1da177e4
LT
46}
47
94d09a98 48const struct xattr_handler reiserfs_xattr_user_handler = {
1da177e4
LT
49 .prefix = XATTR_USER_PREFIX,
50 .get = user_get,
51 .set = user_set,
1da177e4
LT
52 .list = user_list,
53};