Blame view
fs/reiserfs/xattr_trusted.c
1.72 KB
1da177e4c
|
1 |
#include <linux/reiserfs_fs.h> |
16f7e0fe2
|
2 |
#include <linux/capability.h> |
1da177e4c
|
3 4 5 6 7 8 9 10 11 12 |
#include <linux/errno.h> #include <linux/fs.h> #include <linux/pagemap.h> #include <linux/xattr.h> #include <linux/reiserfs_xattr.h> #include <asm/uaccess.h> #define XATTR_TRUSTED_PREFIX "trusted." static int |
bd4c625c0
|
13 |
trusted_get(struct inode *inode, const char *name, void *buffer, size_t size) |
1da177e4c
|
14 |
{ |
bd4c625c0
|
15 16 |
if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) return -EINVAL; |
1da177e4c
|
17 |
|
bd4c625c0
|
18 19 |
if (!reiserfs_xattrs(inode->i_sb)) return -EOPNOTSUPP; |
1da177e4c
|
20 |
|
bd4c625c0
|
21 22 |
if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode))) return -EPERM; |
1da177e4c
|
23 |
|
bd4c625c0
|
24 |
return reiserfs_xattr_get(inode, name, buffer, size); |
1da177e4c
|
25 26 27 |
} static int |
bd4c625c0
|
28 29 |
trusted_set(struct inode *inode, const char *name, const void *buffer, size_t size, int flags) |
1da177e4c
|
30 |
{ |
bd4c625c0
|
31 32 |
if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) return -EINVAL; |
1da177e4c
|
33 |
|
bd4c625c0
|
34 35 |
if (!reiserfs_xattrs(inode->i_sb)) return -EOPNOTSUPP; |
1da177e4c
|
36 |
|
bd4c625c0
|
37 38 |
if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode))) return -EPERM; |
1da177e4c
|
39 |
|
bd4c625c0
|
40 |
return reiserfs_xattr_set(inode, name, buffer, size, flags); |
1da177e4c
|
41 |
} |
bd4c625c0
|
42 |
static int trusted_del(struct inode *inode, const char *name) |
1da177e4c
|
43 |
{ |
bd4c625c0
|
44 45 |
if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) return -EINVAL; |
1da177e4c
|
46 |
|
bd4c625c0
|
47 48 |
if (!reiserfs_xattrs(inode->i_sb)) return -EOPNOTSUPP; |
1da177e4c
|
49 |
|
bd4c625c0
|
50 51 |
if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode))) return -EPERM; |
1da177e4c
|
52 |
|
bd4c625c0
|
53 |
return 0; |
1da177e4c
|
54 55 56 |
} static int |
bd4c625c0
|
57 |
trusted_list(struct inode *inode, const char *name, int namelen, char *out) |
1da177e4c
|
58 |
{ |
bd4c625c0
|
59 |
int len = namelen; |
1da177e4c
|
60 |
|
bd4c625c0
|
61 62 |
if (!reiserfs_xattrs(inode->i_sb)) return 0; |
1da177e4c
|
63 |
|
bd4c625c0
|
64 65 |
if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode))) return 0; |
1da177e4c
|
66 |
|
bd4c625c0
|
67 68 |
if (out) memcpy(out, name, len); |
1da177e4c
|
69 |
|
bd4c625c0
|
70 |
return len; |
1da177e4c
|
71 |
} |
1da177e4c
|
72 73 74 75 76 77 78 |
struct reiserfs_xattr_handler trusted_handler = { .prefix = XATTR_TRUSTED_PREFIX, .get = trusted_get, .set = trusted_set, .del = trusted_del, .list = trusted_list, }; |