Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #include <linux/reiserfs_fs.h> |
2 | #include <linux/errno.h> | |
3 | #include <linux/fs.h> | |
4 | #include <linux/pagemap.h> | |
5 | #include <linux/xattr.h> | |
6 | #include <linux/reiserfs_xattr.h> | |
7 | #include <asm/uaccess.h> | |
8 | ||
1da177e4 | 9 | static int |
bd4c625c | 10 | security_get(struct inode *inode, const char *name, void *buffer, size_t size) |
1da177e4 | 11 | { |
bd4c625c LT |
12 | if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) |
13 | return -EINVAL; | |
1da177e4 | 14 | |
bd4c625c LT |
15 | if (is_reiserfs_priv_object(inode)) |
16 | return -EPERM; | |
1da177e4 | 17 | |
bd4c625c | 18 | return reiserfs_xattr_get(inode, name, buffer, size); |
1da177e4 LT |
19 | } |
20 | ||
21 | static int | |
bd4c625c LT |
22 | security_set(struct inode *inode, const char *name, const void *buffer, |
23 | size_t size, int flags) | |
1da177e4 | 24 | { |
bd4c625c LT |
25 | if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) |
26 | return -EINVAL; | |
1da177e4 | 27 | |
bd4c625c LT |
28 | if (is_reiserfs_priv_object(inode)) |
29 | return -EPERM; | |
1da177e4 | 30 | |
bd4c625c | 31 | return reiserfs_xattr_set(inode, name, buffer, size, flags); |
1da177e4 LT |
32 | } |
33 | ||
bd4c625c | 34 | static int security_del(struct inode *inode, const char *name) |
1da177e4 | 35 | { |
bd4c625c LT |
36 | if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) |
37 | return -EINVAL; | |
1da177e4 | 38 | |
bd4c625c LT |
39 | if (is_reiserfs_priv_object(inode)) |
40 | return -EPERM; | |
1da177e4 | 41 | |
bd4c625c | 42 | return 0; |
1da177e4 LT |
43 | } |
44 | ||
45 | static int | |
bd4c625c | 46 | security_list(struct inode *inode, const char *name, int namelen, char *out) |
1da177e4 | 47 | { |
bd4c625c | 48 | int len = namelen; |
1da177e4 | 49 | |
bd4c625c LT |
50 | if (is_reiserfs_priv_object(inode)) |
51 | return 0; | |
1da177e4 | 52 | |
bd4c625c LT |
53 | if (out) |
54 | memcpy(out, name, len); | |
1da177e4 | 55 | |
bd4c625c | 56 | return len; |
1da177e4 LT |
57 | } |
58 | ||
1da177e4 LT |
59 | struct reiserfs_xattr_handler security_handler = { |
60 | .prefix = XATTR_SECURITY_PREFIX, | |
61 | .get = security_get, | |
62 | .set = security_set, | |
63 | .del = security_del, | |
64 | .list = security_list, | |
65 | }; |