xattr handlers: Pass handler to operations instead of flags
[deliverable/linux.git] / fs / reiserfs / xattr_trusted.c
CommitLineData
f466c6fd 1#include "reiserfs.h"
16f7e0fe 2#include <linux/capability.h>
1da177e4
LT
3#include <linux/errno.h>
4#include <linux/fs.h>
5#include <linux/pagemap.h>
6#include <linux/xattr.h>
c45ac888 7#include "xattr.h"
17093991 8#include <linux/uaccess.h>
1da177e4 9
1da177e4 10static int
d9a82a04
AG
11trusted_get(const struct xattr_handler *handler, struct dentry *dentry,
12 const char *name, void *buffer, size_t size)
1da177e4 13{
bd4c625c
LT
14 if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
15 return -EINVAL;
1da177e4 16
2b0143b5 17 if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(d_inode(dentry)))
bd4c625c 18 return -EPERM;
1da177e4 19
2b0143b5 20 return reiserfs_xattr_get(d_inode(dentry), name, buffer, size);
1da177e4
LT
21}
22
23static int
d9a82a04
AG
24trusted_set(const struct xattr_handler *handler, struct dentry *dentry,
25 const char *name, const void *buffer, size_t size, int flags)
1da177e4 26{
bd4c625c
LT
27 if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
28 return -EINVAL;
1da177e4 29
2b0143b5 30 if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(d_inode(dentry)))
bd4c625c 31 return -EPERM;
1da177e4 32
2b0143b5 33 return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags);
1da177e4
LT
34}
35
d9a82a04
AG
36static size_t trusted_list(const struct xattr_handler *handler,
37 struct dentry *dentry, char *list, size_t list_size,
38 const char *name, size_t name_len)
1da177e4 39{
48b32a35 40 const size_t len = name_len + 1;
1da177e4 41
2b0143b5 42 if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(d_inode(dentry)))
bd4c625c 43 return 0;
1da177e4 44
48b32a35
JM
45 if (list && len <= list_size) {
46 memcpy(list, name, name_len);
47 list[name_len] = '\0';
48 }
bd4c625c 49 return len;
1da177e4
LT
50}
51
94d09a98 52const struct xattr_handler reiserfs_xattr_trusted_handler = {
1da177e4
LT
53 .prefix = XATTR_TRUSTED_PREFIX,
54 .get = trusted_get,
55 .set = trusted_set,
1da177e4
LT
56 .list = trusted_list,
57};
This page took 0.735966 seconds and 5 git commands to generate.