diff options
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_xattr.c')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_xattr.c | 98 |
1 files changed, 34 insertions, 64 deletions
diff --git a/fs/xfs/linux-2.6/xfs_xattr.c b/fs/xfs/linux-2.6/xfs_xattr.c index 497c7fb75cc1..fa01b9daba6b 100644 --- a/fs/xfs/linux-2.6/xfs_xattr.c +++ b/fs/xfs/linux-2.6/xfs_xattr.c | |||
@@ -30,10 +30,10 @@ | |||
30 | 30 | ||
31 | 31 | ||
32 | static int | 32 | static int |
33 | __xfs_xattr_get(struct inode *inode, const char *name, | 33 | xfs_xattr_get(struct dentry *dentry, const char *name, |
34 | void *value, size_t size, int xflags) | 34 | void *value, size_t size, int xflags) |
35 | { | 35 | { |
36 | struct xfs_inode *ip = XFS_I(inode); | 36 | struct xfs_inode *ip = XFS_I(dentry->d_inode); |
37 | int error, asize = size; | 37 | int error, asize = size; |
38 | 38 | ||
39 | if (strcmp(name, "") == 0) | 39 | if (strcmp(name, "") == 0) |
@@ -45,17 +45,17 @@ __xfs_xattr_get(struct inode *inode, const char *name, | |||
45 | value = NULL; | 45 | value = NULL; |
46 | } | 46 | } |
47 | 47 | ||
48 | error = -xfs_attr_get(ip, name, value, &asize, xflags); | 48 | error = -xfs_attr_get(ip, (unsigned char *)name, value, &asize, xflags); |
49 | if (error) | 49 | if (error) |
50 | return error; | 50 | return error; |
51 | return asize; | 51 | return asize; |
52 | } | 52 | } |
53 | 53 | ||
54 | static int | 54 | static int |
55 | __xfs_xattr_set(struct inode *inode, const char *name, const void *value, | 55 | xfs_xattr_set(struct dentry *dentry, const char *name, const void *value, |
56 | size_t size, int flags, int xflags) | 56 | size_t size, int flags, int xflags) |
57 | { | 57 | { |
58 | struct xfs_inode *ip = XFS_I(inode); | 58 | struct xfs_inode *ip = XFS_I(dentry->d_inode); |
59 | 59 | ||
60 | if (strcmp(name, "") == 0) | 60 | if (strcmp(name, "") == 0) |
61 | return -EINVAL; | 61 | return -EINVAL; |
@@ -67,79 +67,39 @@ __xfs_xattr_set(struct inode *inode, const char *name, const void *value, | |||
67 | xflags |= ATTR_REPLACE; | 67 | xflags |= ATTR_REPLACE; |
68 | 68 | ||
69 | if (!value) | 69 | if (!value) |
70 | return -xfs_attr_remove(ip, name, xflags); | 70 | return -xfs_attr_remove(ip, (unsigned char *)name, xflags); |
71 | return -xfs_attr_set(ip, name, (void *)value, size, xflags); | 71 | return -xfs_attr_set(ip, (unsigned char *)name, |
72 | } | 72 | (void *)value, size, xflags); |
73 | |||
74 | static int | ||
75 | xfs_xattr_user_get(struct inode *inode, const char *name, | ||
76 | void *value, size_t size) | ||
77 | { | ||
78 | return __xfs_xattr_get(inode, name, value, size, 0); | ||
79 | } | ||
80 | |||
81 | static int | ||
82 | xfs_xattr_user_set(struct inode *inode, const char *name, | ||
83 | const void *value, size_t size, int flags) | ||
84 | { | ||
85 | return __xfs_xattr_set(inode, name, value, size, flags, 0); | ||
86 | } | 73 | } |
87 | 74 | ||
88 | static struct xattr_handler xfs_xattr_user_handler = { | 75 | static struct xattr_handler xfs_xattr_user_handler = { |
89 | .prefix = XATTR_USER_PREFIX, | 76 | .prefix = XATTR_USER_PREFIX, |
90 | .get = xfs_xattr_user_get, | 77 | .flags = 0, /* no flags implies user namespace */ |
91 | .set = xfs_xattr_user_set, | 78 | .get = xfs_xattr_get, |
79 | .set = xfs_xattr_set, | ||
92 | }; | 80 | }; |
93 | 81 | ||
94 | |||
95 | static int | ||
96 | xfs_xattr_trusted_get(struct inode *inode, const char *name, | ||
97 | void *value, size_t size) | ||
98 | { | ||
99 | return __xfs_xattr_get(inode, name, value, size, ATTR_ROOT); | ||
100 | } | ||
101 | |||
102 | static int | ||
103 | xfs_xattr_trusted_set(struct inode *inode, const char *name, | ||
104 | const void *value, size_t size, int flags) | ||
105 | { | ||
106 | return __xfs_xattr_set(inode, name, value, size, flags, ATTR_ROOT); | ||
107 | } | ||
108 | |||
109 | static struct xattr_handler xfs_xattr_trusted_handler = { | 82 | static struct xattr_handler xfs_xattr_trusted_handler = { |
110 | .prefix = XATTR_TRUSTED_PREFIX, | 83 | .prefix = XATTR_TRUSTED_PREFIX, |
111 | .get = xfs_xattr_trusted_get, | 84 | .flags = ATTR_ROOT, |
112 | .set = xfs_xattr_trusted_set, | 85 | .get = xfs_xattr_get, |
86 | .set = xfs_xattr_set, | ||
113 | }; | 87 | }; |
114 | 88 | ||
115 | |||
116 | static int | ||
117 | xfs_xattr_secure_get(struct inode *inode, const char *name, | ||
118 | void *value, size_t size) | ||
119 | { | ||
120 | return __xfs_xattr_get(inode, name, value, size, ATTR_SECURE); | ||
121 | } | ||
122 | |||
123 | static int | ||
124 | xfs_xattr_secure_set(struct inode *inode, const char *name, | ||
125 | const void *value, size_t size, int flags) | ||
126 | { | ||
127 | return __xfs_xattr_set(inode, name, value, size, flags, ATTR_SECURE); | ||
128 | } | ||
129 | |||
130 | static struct xattr_handler xfs_xattr_security_handler = { | 89 | static struct xattr_handler xfs_xattr_security_handler = { |
131 | .prefix = XATTR_SECURITY_PREFIX, | 90 | .prefix = XATTR_SECURITY_PREFIX, |
132 | .get = xfs_xattr_secure_get, | 91 | .flags = ATTR_SECURE, |
133 | .set = xfs_xattr_secure_set, | 92 | .get = xfs_xattr_get, |
93 | .set = xfs_xattr_set, | ||
134 | }; | 94 | }; |
135 | 95 | ||
136 | |||
137 | struct xattr_handler *xfs_xattr_handlers[] = { | 96 | struct xattr_handler *xfs_xattr_handlers[] = { |
138 | &xfs_xattr_user_handler, | 97 | &xfs_xattr_user_handler, |
139 | &xfs_xattr_trusted_handler, | 98 | &xfs_xattr_trusted_handler, |
140 | &xfs_xattr_security_handler, | 99 | &xfs_xattr_security_handler, |
141 | #ifdef CONFIG_XFS_POSIX_ACL | 100 | #ifdef CONFIG_XFS_POSIX_ACL |
142 | &xfs_xattr_system_handler, | 101 | &xfs_xattr_acl_access_handler, |
102 | &xfs_xattr_acl_default_handler, | ||
143 | #endif | 103 | #endif |
144 | NULL | 104 | NULL |
145 | }; | 105 | }; |
@@ -165,8 +125,13 @@ static const char *xfs_xattr_prefix(int flags) | |||
165 | } | 125 | } |
166 | 126 | ||
167 | static int | 127 | static int |
168 | xfs_xattr_put_listent(struct xfs_attr_list_context *context, int flags, | 128 | xfs_xattr_put_listent( |
169 | char *name, int namelen, int valuelen, char *value) | 129 | struct xfs_attr_list_context *context, |
130 | int flags, | ||
131 | unsigned char *name, | ||
132 | int namelen, | ||
133 | int valuelen, | ||
134 | unsigned char *value) | ||
170 | { | 135 | { |
171 | unsigned int prefix_len = xfs_xattr_prefix_len(flags); | 136 | unsigned int prefix_len = xfs_xattr_prefix_len(flags); |
172 | char *offset; | 137 | char *offset; |
@@ -189,7 +154,7 @@ xfs_xattr_put_listent(struct xfs_attr_list_context *context, int flags, | |||
189 | offset = (char *)context->alist + context->count; | 154 | offset = (char *)context->alist + context->count; |
190 | strncpy(offset, xfs_xattr_prefix(flags), prefix_len); | 155 | strncpy(offset, xfs_xattr_prefix(flags), prefix_len); |
191 | offset += prefix_len; | 156 | offset += prefix_len; |
192 | strncpy(offset, name, namelen); /* real name */ | 157 | strncpy(offset, (char *)name, namelen); /* real name */ |
193 | offset += namelen; | 158 | offset += namelen; |
194 | *offset = '\0'; | 159 | *offset = '\0'; |
195 | context->count += prefix_len + namelen + 1; | 160 | context->count += prefix_len + namelen + 1; |
@@ -197,8 +162,13 @@ xfs_xattr_put_listent(struct xfs_attr_list_context *context, int flags, | |||
197 | } | 162 | } |
198 | 163 | ||
199 | static int | 164 | static int |
200 | xfs_xattr_put_listent_sizes(struct xfs_attr_list_context *context, int flags, | 165 | xfs_xattr_put_listent_sizes( |
201 | char *name, int namelen, int valuelen, char *value) | 166 | struct xfs_attr_list_context *context, |
167 | int flags, | ||
168 | unsigned char *name, | ||
169 | int namelen, | ||
170 | int valuelen, | ||
171 | unsigned char *value) | ||
202 | { | 172 | { |
203 | context->count += xfs_xattr_prefix_len(flags) + namelen + 1; | 173 | context->count += xfs_xattr_prefix_len(flags) + namelen + 1; |
204 | return 0; | 174 | return 0; |