Staging: hv: mousevsc: Get rid of the struct input_device_context
[zen-stable.git] / fs / reiserfs / xattr_trusted.c
blob9883736ce3ecd0c4685c6fa3d269b4b6d40fdd96
1 #include <linux/reiserfs_fs.h>
2 #include <linux/capability.h>
3 #include <linux/errno.h>
4 #include <linux/fs.h>
5 #include <linux/pagemap.h>
6 #include <linux/xattr.h>
7 #include <linux/reiserfs_xattr.h>
8 #include <asm/uaccess.h>
10 static int
11 trusted_get(struct dentry *dentry, const char *name, void *buffer, size_t size,
12 int handler_flags)
14 if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
15 return -EINVAL;
17 if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(dentry->d_inode))
18 return -EPERM;
20 return reiserfs_xattr_get(dentry->d_inode, name, buffer, size);
23 static int
24 trusted_set(struct dentry *dentry, const char *name, const void *buffer,
25 size_t size, int flags, int handler_flags)
27 if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
28 return -EINVAL;
30 if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(dentry->d_inode))
31 return -EPERM;
33 return reiserfs_xattr_set(dentry->d_inode, name, buffer, size, flags);
36 static size_t trusted_list(struct dentry *dentry, char *list, size_t list_size,
37 const char *name, size_t name_len, int handler_flags)
39 const size_t len = name_len + 1;
41 if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(dentry->d_inode))
42 return 0;
44 if (list && len <= list_size) {
45 memcpy(list, name, name_len);
46 list[name_len] = '\0';
48 return len;
51 const struct xattr_handler reiserfs_xattr_trusted_handler = {
52 .prefix = XATTR_TRUSTED_PREFIX,
53 .get = trusted_get,
54 .set = trusted_set,
55 .list = trusted_list,