xattr_user.c 1.3 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5
#include <linux/reiserfs_fs.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/pagemap.h>
#include <linux/xattr.h>
6
#include "xattr.h"
L
Linus Torvalds 已提交
7 8 9
#include <asm/uaccess.h>

static int
10 11
user_get(struct dentry *dentry, const char *name, void *buffer, size_t size,
	 int handler_flags)
L
Linus Torvalds 已提交
12 13
{

14 15
	if (strlen(name) < sizeof(XATTR_USER_PREFIX))
		return -EINVAL;
16
	if (!reiserfs_xattrs_user(dentry->d_sb))
17
		return -EOPNOTSUPP;
18
	return reiserfs_xattr_get(dentry->d_inode, name, buffer, size);
L
Linus Torvalds 已提交
19 20 21
}

static int
22 23
user_set(struct dentry *dentry, const char *name, const void *buffer,
	 size_t size, int flags, int handler_flags)
L
Linus Torvalds 已提交
24
{
25 26
	if (strlen(name) < sizeof(XATTR_USER_PREFIX))
		return -EINVAL;
L
Linus Torvalds 已提交
27

28
	if (!reiserfs_xattrs_user(dentry->d_sb))
29
		return -EOPNOTSUPP;
30
	return reiserfs_xattr_set(dentry->d_inode, name, buffer, size, flags);
L
Linus Torvalds 已提交
31 32
}

33 34
static size_t user_list(struct dentry *dentry, char *list, size_t list_size,
			const char *name, size_t name_len, int handler_flags)
L
Linus Torvalds 已提交
35
{
36
	const size_t len = name_len + 1;
L
Linus Torvalds 已提交
37

38
	if (!reiserfs_xattrs_user(dentry->d_sb))
39
		return 0;
40 41 42 43
	if (list && len <= list_size) {
		memcpy(list, name, name_len);
		list[name_len] = '\0';
	}
44
	return len;
L
Linus Torvalds 已提交
45 46
}

47
const struct xattr_handler reiserfs_xattr_user_handler = {
L
Linus Torvalds 已提交
48 49 50 51 52
	.prefix = XATTR_USER_PREFIX,
	.get = user_get,
	.set = user_set,
	.list = user_list,
};