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