]>
Commit | Line | Data |
---|---|---|
1da177e4 | 1 | #include <linux/reiserfs_fs.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> | |
7 | #include <linux/reiserfs_xattr.h> | |
8 | #include <asm/uaccess.h> | |
9 | ||
1da177e4 | 10 | static int |
bd4c625c | 11 | trusted_get(struct inode *inode, const char *name, void *buffer, size_t size) |
1da177e4 | 12 | { |
bd4c625c LT |
13 | if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) |
14 | return -EINVAL; | |
1da177e4 | 15 | |
48b32a35 | 16 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode)) |
bd4c625c | 17 | return -EPERM; |
1da177e4 | 18 | |
bd4c625c | 19 | return reiserfs_xattr_get(inode, name, buffer, size); |
1da177e4 LT |
20 | } |
21 | ||
22 | static int | |
bd4c625c LT |
23 | trusted_set(struct inode *inode, const char *name, const void *buffer, |
24 | size_t size, int flags) | |
1da177e4 | 25 | { |
bd4c625c LT |
26 | if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) |
27 | return -EINVAL; | |
1da177e4 | 28 | |
48b32a35 | 29 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode)) |
bd4c625c | 30 | return -EPERM; |
1da177e4 | 31 | |
bd4c625c | 32 | return reiserfs_xattr_set(inode, name, buffer, size, flags); |
1da177e4 LT |
33 | } |
34 | ||
48b32a35 JM |
35 | static size_t trusted_list(struct inode *inode, char *list, size_t list_size, |
36 | const char *name, size_t name_len) | |
1da177e4 | 37 | { |
48b32a35 | 38 | const size_t len = name_len + 1; |
1da177e4 | 39 | |
48b32a35 | 40 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode)) |
bd4c625c | 41 | return 0; |
1da177e4 | 42 | |
48b32a35 JM |
43 | if (list && len <= list_size) { |
44 | memcpy(list, name, name_len); | |
45 | list[name_len] = '\0'; | |
46 | } | |
bd4c625c | 47 | return len; |
1da177e4 LT |
48 | } |
49 | ||
48b32a35 | 50 | struct xattr_handler reiserfs_xattr_trusted_handler = { |
1da177e4 LT |
51 | .prefix = XATTR_TRUSTED_PREFIX, |
52 | .get = trusted_get, | |
53 | .set = trusted_set, | |
1da177e4 LT |
54 | .list = trusted_list, |
55 | }; |