]>
Commit | Line | Data |
---|---|---|
2cb7cef9 BS |
1 | From: Mark Fasheh <mfasheh@suse.com> |
2 | Subject: ocfs2: Move trusted and user attribute support into xattr.c | |
3 | Patch-mainline: 2.6.28 | |
4 | ||
5 | Per Christoph Hellwig's suggestion - don't split these up. It's not like we | |
6 | gained much by having the two tiny files around. | |
7 | ||
8 | Signed-off-by: Mark Fasheh <mfasheh@suse.com> | |
9 | --- | |
10 | fs/ocfs2/Makefile | 4 +- | |
11 | fs/ocfs2/xattr.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++ | |
12 | fs/ocfs2/xattr_trusted.c | 82 ---------------------------------- | |
13 | fs/ocfs2/xattr_user.c | 94 --------------------------------------- | |
14 | 4 files changed, 111 insertions(+), 179 deletions(-) | |
15 | delete mode 100644 fs/ocfs2/xattr_trusted.c | |
16 | delete mode 100644 fs/ocfs2/xattr_user.c | |
17 | ||
18 | Index: linux-2.6.27/fs/ocfs2/Makefile | |
19 | =================================================================== | |
20 | --- linux-2.6.27.orig/fs/ocfs2/Makefile | |
21 | +++ linux-2.6.27/fs/ocfs2/Makefile | |
22 | @@ -35,9 +35,7 @@ ocfs2-objs := \ | |
23 | sysfile.o \ | |
24 | uptodate.o \ | |
25 | ver.o \ | |
26 | - xattr.o \ | |
27 | - xattr_user.o \ | |
28 | - xattr_trusted.o | |
29 | + xattr.o | |
30 | ||
31 | ocfs2_stackglue-objs := stackglue.o | |
32 | ocfs2_stack_o2cb-objs := stack_o2cb.o | |
33 | Index: linux-2.6.27/fs/ocfs2/xattr.c | |
34 | =================================================================== | |
35 | --- linux-2.6.27.orig/fs/ocfs2/xattr.c | |
36 | +++ linux-2.6.27/fs/ocfs2/xattr.c | |
37 | @@ -37,6 +37,9 @@ | |
38 | #include <linux/writeback.h> | |
39 | #include <linux/falloc.h> | |
40 | #include <linux/sort.h> | |
41 | +#include <linux/init.h> | |
42 | +#include <linux/module.h> | |
43 | +#include <linux/string.h> | |
44 | ||
45 | #define MLOG_MASK_PREFIX ML_XATTR | |
46 | #include <cluster/masklog.h> | |
47 | @@ -4756,3 +4759,110 @@ static int ocfs2_delete_xattr_index_bloc | |
48 | out: | |
49 | return ret; | |
50 | } | |
51 | + | |
52 | +/* | |
53 | + * 'trusted' attributes support | |
54 | + */ | |
55 | + | |
56 | +#define XATTR_TRUSTED_PREFIX "trusted." | |
57 | + | |
58 | +static size_t ocfs2_xattr_trusted_list(struct inode *inode, char *list, | |
59 | + size_t list_size, const char *name, | |
60 | + size_t name_len) | |
61 | +{ | |
62 | + const size_t prefix_len = sizeof(XATTR_TRUSTED_PREFIX) - 1; | |
63 | + const size_t total_len = prefix_len + name_len + 1; | |
64 | + | |
65 | + if (list && total_len <= list_size) { | |
66 | + memcpy(list, XATTR_TRUSTED_PREFIX, prefix_len); | |
67 | + memcpy(list + prefix_len, name, name_len); | |
68 | + list[prefix_len + name_len] = '\0'; | |
69 | + } | |
70 | + return total_len; | |
71 | +} | |
72 | + | |
73 | +static int ocfs2_xattr_trusted_get(struct inode *inode, const char *name, | |
74 | + void *buffer, size_t size) | |
75 | +{ | |
76 | + if (strcmp(name, "") == 0) | |
77 | + return -EINVAL; | |
78 | + return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_TRUSTED, name, | |
79 | + buffer, size); | |
80 | +} | |
81 | + | |
82 | +static int ocfs2_xattr_trusted_set(struct inode *inode, const char *name, | |
83 | + const void *value, size_t size, int flags) | |
84 | +{ | |
85 | + if (strcmp(name, "") == 0) | |
86 | + return -EINVAL; | |
87 | + | |
88 | + return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_TRUSTED, name, value, | |
89 | + size, flags); | |
90 | +} | |
91 | + | |
92 | +struct xattr_handler ocfs2_xattr_trusted_handler = { | |
93 | + .prefix = XATTR_TRUSTED_PREFIX, | |
94 | + .list = ocfs2_xattr_trusted_list, | |
95 | + .get = ocfs2_xattr_trusted_get, | |
96 | + .set = ocfs2_xattr_trusted_set, | |
97 | +}; | |
98 | + | |
99 | + | |
100 | +/* | |
101 | + * 'user' attributes support | |
102 | + */ | |
103 | + | |
104 | +#define XATTR_USER_PREFIX "user." | |
105 | + | |
106 | +static size_t ocfs2_xattr_user_list(struct inode *inode, char *list, | |
107 | + size_t list_size, const char *name, | |
108 | + size_t name_len) | |
109 | +{ | |
110 | + const size_t prefix_len = sizeof(XATTR_USER_PREFIX) - 1; | |
111 | + const size_t total_len = prefix_len + name_len + 1; | |
112 | + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | |
113 | + | |
114 | + if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) | |
115 | + return 0; | |
116 | + | |
117 | + if (list && total_len <= list_size) { | |
118 | + memcpy(list, XATTR_USER_PREFIX, prefix_len); | |
119 | + memcpy(list + prefix_len, name, name_len); | |
120 | + list[prefix_len + name_len] = '\0'; | |
121 | + } | |
122 | + return total_len; | |
123 | +} | |
124 | + | |
125 | +static int ocfs2_xattr_user_get(struct inode *inode, const char *name, | |
126 | + void *buffer, size_t size) | |
127 | +{ | |
128 | + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | |
129 | + | |
130 | + if (strcmp(name, "") == 0) | |
131 | + return -EINVAL; | |
132 | + if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) | |
133 | + return -EOPNOTSUPP; | |
134 | + return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_USER, name, | |
135 | + buffer, size); | |
136 | +} | |
137 | + | |
138 | +static int ocfs2_xattr_user_set(struct inode *inode, const char *name, | |
139 | + const void *value, size_t size, int flags) | |
140 | +{ | |
141 | + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | |
142 | + | |
143 | + if (strcmp(name, "") == 0) | |
144 | + return -EINVAL; | |
145 | + if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) | |
146 | + return -EOPNOTSUPP; | |
147 | + | |
148 | + return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_USER, name, value, | |
149 | + size, flags); | |
150 | +} | |
151 | + | |
152 | +struct xattr_handler ocfs2_xattr_user_handler = { | |
153 | + .prefix = XATTR_USER_PREFIX, | |
154 | + .list = ocfs2_xattr_user_list, | |
155 | + .get = ocfs2_xattr_user_get, | |
156 | + .set = ocfs2_xattr_user_set, | |
157 | +}; | |
158 | Index: linux-2.6.27/fs/ocfs2/xattr_trusted.c | |
159 | =================================================================== | |
160 | --- linux-2.6.27.orig/fs/ocfs2/xattr_trusted.c | |
161 | +++ /dev/null | |
162 | @@ -1,82 +0,0 @@ | |
163 | -/* -*- mode: c; c-basic-offset: 8; -*- | |
164 | - * vim: noexpandtab sw=8 ts=8 sts=0: | |
165 | - * | |
166 | - * xattr_trusted.c | |
167 | - * | |
168 | - * Copyright (C) 2008 Oracle. All rights reserved. | |
169 | - * | |
170 | - * CREDITS: | |
171 | - * Lots of code in this file is taken from ext3. | |
172 | - * | |
173 | - * This program is free software; you can redistribute it and/or | |
174 | - * modify it under the terms of the GNU General Public | |
175 | - * License as published by the Free Software Foundation; either | |
176 | - * version 2 of the License, or (at your option) any later version. | |
177 | - * | |
178 | - * This program is distributed in the hope that it will be useful, | |
179 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
180 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
181 | - * General Public License for more details. | |
182 | - * | |
183 | - * You should have received a copy of the GNU General Public | |
184 | - * License along with this program; if not, write to the | |
185 | - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
186 | - * Boston, MA 021110-1307, USA. | |
187 | - */ | |
188 | - | |
189 | -#include <linux/init.h> | |
190 | -#include <linux/module.h> | |
191 | -#include <linux/string.h> | |
192 | - | |
193 | -#define MLOG_MASK_PREFIX ML_INODE | |
194 | -#include <cluster/masklog.h> | |
195 | - | |
196 | -#include "ocfs2.h" | |
197 | -#include "alloc.h" | |
198 | -#include "dlmglue.h" | |
199 | -#include "file.h" | |
200 | -#include "ocfs2_fs.h" | |
201 | -#include "xattr.h" | |
202 | - | |
203 | -#define XATTR_TRUSTED_PREFIX "trusted." | |
204 | - | |
205 | -static size_t ocfs2_xattr_trusted_list(struct inode *inode, char *list, | |
206 | - size_t list_size, const char *name, | |
207 | - size_t name_len) | |
208 | -{ | |
209 | - const size_t prefix_len = sizeof(XATTR_TRUSTED_PREFIX) - 1; | |
210 | - const size_t total_len = prefix_len + name_len + 1; | |
211 | - | |
212 | - if (list && total_len <= list_size) { | |
213 | - memcpy(list, XATTR_TRUSTED_PREFIX, prefix_len); | |
214 | - memcpy(list + prefix_len, name, name_len); | |
215 | - list[prefix_len + name_len] = '\0'; | |
216 | - } | |
217 | - return total_len; | |
218 | -} | |
219 | - | |
220 | -static int ocfs2_xattr_trusted_get(struct inode *inode, const char *name, | |
221 | - void *buffer, size_t size) | |
222 | -{ | |
223 | - if (strcmp(name, "") == 0) | |
224 | - return -EINVAL; | |
225 | - return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_TRUSTED, name, | |
226 | - buffer, size); | |
227 | -} | |
228 | - | |
229 | -static int ocfs2_xattr_trusted_set(struct inode *inode, const char *name, | |
230 | - const void *value, size_t size, int flags) | |
231 | -{ | |
232 | - if (strcmp(name, "") == 0) | |
233 | - return -EINVAL; | |
234 | - | |
235 | - return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_TRUSTED, name, value, | |
236 | - size, flags); | |
237 | -} | |
238 | - | |
239 | -struct xattr_handler ocfs2_xattr_trusted_handler = { | |
240 | - .prefix = XATTR_TRUSTED_PREFIX, | |
241 | - .list = ocfs2_xattr_trusted_list, | |
242 | - .get = ocfs2_xattr_trusted_get, | |
243 | - .set = ocfs2_xattr_trusted_set, | |
244 | -}; | |
245 | Index: linux-2.6.27/fs/ocfs2/xattr_user.c | |
246 | =================================================================== | |
247 | --- linux-2.6.27.orig/fs/ocfs2/xattr_user.c | |
248 | +++ /dev/null | |
249 | @@ -1,94 +0,0 @@ | |
250 | -/* -*- mode: c; c-basic-offset: 8; -*- | |
251 | - * vim: noexpandtab sw=8 ts=8 sts=0: | |
252 | - * | |
253 | - * xattr_user.c | |
254 | - * | |
255 | - * Copyright (C) 2008 Oracle. All rights reserved. | |
256 | - * | |
257 | - * CREDITS: | |
258 | - * Lots of code in this file is taken from ext3. | |
259 | - * | |
260 | - * This program is free software; you can redistribute it and/or | |
261 | - * modify it under the terms of the GNU General Public | |
262 | - * License as published by the Free Software Foundation; either | |
263 | - * version 2 of the License, or (at your option) any later version. | |
264 | - * | |
265 | - * This program is distributed in the hope that it will be useful, | |
266 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
267 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
268 | - * General Public License for more details. | |
269 | - * | |
270 | - * You should have received a copy of the GNU General Public | |
271 | - * License along with this program; if not, write to the | |
272 | - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
273 | - * Boston, MA 021110-1307, USA. | |
274 | - */ | |
275 | - | |
276 | -#include <linux/init.h> | |
277 | -#include <linux/module.h> | |
278 | -#include <linux/string.h> | |
279 | - | |
280 | -#define MLOG_MASK_PREFIX ML_INODE | |
281 | -#include <cluster/masklog.h> | |
282 | - | |
283 | -#include "ocfs2.h" | |
284 | -#include "alloc.h" | |
285 | -#include "dlmglue.h" | |
286 | -#include "file.h" | |
287 | -#include "ocfs2_fs.h" | |
288 | -#include "xattr.h" | |
289 | - | |
290 | -#define XATTR_USER_PREFIX "user." | |
291 | - | |
292 | -static size_t ocfs2_xattr_user_list(struct inode *inode, char *list, | |
293 | - size_t list_size, const char *name, | |
294 | - size_t name_len) | |
295 | -{ | |
296 | - const size_t prefix_len = sizeof(XATTR_USER_PREFIX) - 1; | |
297 | - const size_t total_len = prefix_len + name_len + 1; | |
298 | - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | |
299 | - | |
300 | - if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) | |
301 | - return 0; | |
302 | - | |
303 | - if (list && total_len <= list_size) { | |
304 | - memcpy(list, XATTR_USER_PREFIX, prefix_len); | |
305 | - memcpy(list + prefix_len, name, name_len); | |
306 | - list[prefix_len + name_len] = '\0'; | |
307 | - } | |
308 | - return total_len; | |
309 | -} | |
310 | - | |
311 | -static int ocfs2_xattr_user_get(struct inode *inode, const char *name, | |
312 | - void *buffer, size_t size) | |
313 | -{ | |
314 | - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | |
315 | - | |
316 | - if (strcmp(name, "") == 0) | |
317 | - return -EINVAL; | |
318 | - if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) | |
319 | - return -EOPNOTSUPP; | |
320 | - return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_USER, name, | |
321 | - buffer, size); | |
322 | -} | |
323 | - | |
324 | -static int ocfs2_xattr_user_set(struct inode *inode, const char *name, | |
325 | - const void *value, size_t size, int flags) | |
326 | -{ | |
327 | - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | |
328 | - | |
329 | - if (strcmp(name, "") == 0) | |
330 | - return -EINVAL; | |
331 | - if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) | |
332 | - return -EOPNOTSUPP; | |
333 | - | |
334 | - return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_USER, name, value, | |
335 | - size, flags); | |
336 | -} | |
337 | - | |
338 | -struct xattr_handler ocfs2_xattr_user_handler = { | |
339 | - .prefix = XATTR_USER_PREFIX, | |
340 | - .list = ocfs2_xattr_user_list, | |
341 | - .get = ocfs2_xattr_user_get, | |
342 | - .set = ocfs2_xattr_user_set, | |
343 | -}; |