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
9static int
10user_get(const struct xattr_handler *handler, struct dentry *dentry,
11	 const char *name, void *buffer, size_t size)
12{
13
14	if (strlen(name) < sizeof(XATTR_USER_PREFIX))
15		return -EINVAL;
16	if (!reiserfs_xattrs_user(dentry->d_sb))
17		return -EOPNOTSUPP;
18	return reiserfs_xattr_get(d_inode(dentry), name, buffer, size);
19}
20
21static int
22user_set(const struct xattr_handler *handler, struct dentry *dentry,
23	 const char *name, const void *buffer, size_t size, int flags)
24{
25	if (strlen(name) < sizeof(XATTR_USER_PREFIX))
26		return -EINVAL;
27
28	if (!reiserfs_xattrs_user(dentry->d_sb))
29		return -EOPNOTSUPP;
30	return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags);
31}
32
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)
36{
37	const size_t len = name_len + 1;
38
39	if (!reiserfs_xattrs_user(dentry->d_sb))
40		return 0;
41	if (list && len <= list_size) {
42		memcpy(list, name, name_len);
43		list[name_len] = '\0';
44	}
45	return len;
46}
47
48const struct xattr_handler reiserfs_xattr_user_handler = {
49	.prefix = XATTR_USER_PREFIX,
50	.get = user_get,
51	.set = user_set,
52	.list = user_list,
53};
54