]>
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 | ||
9 | #define XATTR_SECURITY_PREFIX "security." | |
10 | ||
11 | static int | |
bd4c625c | 12 | security_get(struct inode *inode, const char *name, void *buffer, size_t size) |
1da177e4 | 13 | { |
bd4c625c LT |
14 | if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) |
15 | return -EINVAL; | |
1da177e4 | 16 | |
bd4c625c LT |
17 | if (is_reiserfs_priv_object(inode)) |
18 | return -EPERM; | |
1da177e4 | 19 | |
bd4c625c | 20 | return reiserfs_xattr_get(inode, name, buffer, size); |
1da177e4 LT |
21 | } |
22 | ||
23 | static int | |
bd4c625c LT |
24 | security_set(struct inode *inode, const char *name, const void *buffer, |
25 | size_t size, int flags) | |
1da177e4 | 26 | { |
bd4c625c LT |
27 | if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) |
28 | return -EINVAL; | |
1da177e4 | 29 | |
bd4c625c LT |
30 | if (is_reiserfs_priv_object(inode)) |
31 | return -EPERM; | |
1da177e4 | 32 | |
bd4c625c | 33 | return reiserfs_xattr_set(inode, name, buffer, size, flags); |
1da177e4 LT |
34 | } |
35 | ||
bd4c625c | 36 | static int security_del(struct inode *inode, const char *name) |
1da177e4 | 37 | { |
bd4c625c LT |
38 | if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) |
39 | return -EINVAL; | |
1da177e4 | 40 | |
bd4c625c LT |
41 | if (is_reiserfs_priv_object(inode)) |
42 | return -EPERM; | |
1da177e4 | 43 | |
bd4c625c | 44 | return 0; |
1da177e4 LT |
45 | } |
46 | ||
47 | static int | |
bd4c625c | 48 | security_list(struct inode *inode, const char *name, int namelen, char *out) |
1da177e4 | 49 | { |
bd4c625c | 50 | int len = namelen; |
1da177e4 | 51 | |
bd4c625c LT |
52 | if (is_reiserfs_priv_object(inode)) |
53 | return 0; | |
1da177e4 | 54 | |
bd4c625c LT |
55 | if (out) |
56 | memcpy(out, name, len); | |
1da177e4 | 57 | |
bd4c625c | 58 | return len; |
1da177e4 LT |
59 | } |
60 | ||
1da177e4 LT |
61 | struct reiserfs_xattr_handler security_handler = { |
62 | .prefix = XATTR_SECURITY_PREFIX, | |
63 | .get = security_get, | |
64 | .set = security_set, | |
65 | .del = security_del, | |
66 | .list = security_list, | |
67 | }; |