Linux 4.8.3
[linux/fpc-iii.git] / fs / reiserfs / xattr_trusted.c
blobf15a5f9e84ce1a83e2052b7852a21bff727f105c
1 #include "reiserfs.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 "xattr.h"
8 #include <linux/uaccess.h>
10 static int
11 trusted_get(const struct xattr_handler *handler, struct dentry *unused,
12 struct inode *inode, const char *name, void *buffer, size_t size)
14 if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode))
15 return -EPERM;
17 return reiserfs_xattr_get(inode, xattr_full_name(handler, name),
18 buffer, size);
21 static int
22 trusted_set(const struct xattr_handler *handler, struct dentry *unused,
23 struct inode *inode, const char *name, const void *buffer,
24 size_t size, int flags)
26 if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode))
27 return -EPERM;
29 return reiserfs_xattr_set(inode,
30 xattr_full_name(handler, name),
31 buffer, size, flags);
34 static bool trusted_list(struct dentry *dentry)
36 return capable(CAP_SYS_ADMIN) && !IS_PRIVATE(d_inode(dentry));
39 const struct xattr_handler reiserfs_xattr_trusted_handler = {
40 .prefix = XATTR_TRUSTED_PREFIX,
41 .get = trusted_get,
42 .set = trusted_set,
43 .list = trusted_list,