Commit | Line | Data |
---|---|---|
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 | 10 | static int |
b296821a AV |
11 | trusted_get(const struct xattr_handler *handler, struct dentry *unused, |
12 | struct inode *inode, const char *name, void *buffer, size_t size) | |
1da177e4 | 13 | { |
b296821a | 14 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode)) |
bd4c625c | 15 | return -EPERM; |
1da177e4 | 16 | |
b296821a | 17 | return reiserfs_xattr_get(inode, xattr_full_name(handler, name), |
79a628d1 | 18 | buffer, size); |
1da177e4 LT |
19 | } |
20 | ||
21 | static int | |
d9a82a04 AG |
22 | trusted_set(const struct xattr_handler *handler, struct dentry *dentry, |
23 | const char *name, const void *buffer, size_t size, int flags) | |
1da177e4 | 24 | { |
2b0143b5 | 25 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(d_inode(dentry))) |
bd4c625c | 26 | return -EPERM; |
1da177e4 | 27 | |
79a628d1 AV |
28 | return reiserfs_xattr_set(d_inode(dentry), |
29 | xattr_full_name(handler, name), | |
30 | buffer, size, flags); | |
1da177e4 LT |
31 | } |
32 | ||
764a5c6b | 33 | static bool trusted_list(struct dentry *dentry) |
1da177e4 | 34 | { |
764a5c6b | 35 | return capable(CAP_SYS_ADMIN) && !IS_PRIVATE(d_inode(dentry)); |
1da177e4 LT |
36 | } |
37 | ||
94d09a98 | 38 | const struct xattr_handler reiserfs_xattr_trusted_handler = { |
1da177e4 LT |
39 | .prefix = XATTR_TRUSTED_PREFIX, |
40 | .get = trusted_get, | |
41 | .set = trusted_set, | |
1da177e4 LT |
42 | .list = trusted_list, |
43 | }; |