cfg80211: handle failed skb allocation
[cascardo/linux.git] / fs / reiserfs / xattr_trusted.c
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>
9
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)
13 {
14         if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode))
15                 return -EPERM;
16
17         return reiserfs_xattr_get(inode, xattr_full_name(handler, name),
18                                   buffer, size);
19 }
20
21 static int
22 trusted_set(const struct xattr_handler *handler, struct dentry *dentry,
23             const char *name, const void *buffer, size_t size, int flags)
24 {
25         if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(d_inode(dentry)))
26                 return -EPERM;
27
28         return reiserfs_xattr_set(d_inode(dentry),
29                                   xattr_full_name(handler, name),
30                                   buffer, size, flags);
31 }
32
33 static bool trusted_list(struct dentry *dentry)
34 {
35         return capable(CAP_SYS_ADMIN) && !IS_PRIVATE(d_inode(dentry));
36 }
37
38 const struct xattr_handler reiserfs_xattr_trusted_handler = {
39         .prefix = XATTR_TRUSTED_PREFIX,
40         .get = trusted_get,
41         .set = trusted_set,
42         .list = trusted_list,
43 };