1 From: Mark Fasheh <mfasheh@suse.com>
2 Subject: ocfs2: Move trusted and user attribute support into xattr.c
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.
8 Signed-off-by: Mark Fasheh <mfasheh@suse.com>
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
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 := \
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
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>
45 #define MLOG_MASK_PREFIX ML_XATTR
46 #include <cluster/masklog.h>
47 @@ -4756,3 +4759,110 @@ static int ocfs2_delete_xattr_index_bloc
53 + * 'trusted' attributes support
56 +#define XATTR_TRUSTED_PREFIX "trusted."
58 +static size_t ocfs2_xattr_trusted_list(struct inode *inode, char *list,
59 + size_t list_size, const char *name,
62 + const size_t prefix_len = sizeof(XATTR_TRUSTED_PREFIX) - 1;
63 + const size_t total_len = prefix_len + name_len + 1;
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';
73 +static int ocfs2_xattr_trusted_get(struct inode *inode, const char *name,
74 + void *buffer, size_t size)
76 + if (strcmp(name, "") == 0)
78 + return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_TRUSTED, name,
82 +static int ocfs2_xattr_trusted_set(struct inode *inode, const char *name,
83 + const void *value, size_t size, int flags)
85 + if (strcmp(name, "") == 0)
88 + return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_TRUSTED, name, value,
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,
101 + * 'user' attributes support
104 +#define XATTR_USER_PREFIX "user."
106 +static size_t ocfs2_xattr_user_list(struct inode *inode, char *list,
107 + size_t list_size, const char *name,
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);
114 + if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
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';
125 +static int ocfs2_xattr_user_get(struct inode *inode, const char *name,
126 + void *buffer, size_t size)
128 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
130 + if (strcmp(name, "") == 0)
132 + if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
133 + return -EOPNOTSUPP;
134 + return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_USER, name,
138 +static int ocfs2_xattr_user_set(struct inode *inode, const char *name,
139 + const void *value, size_t size, int flags)
141 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
143 + if (strcmp(name, "") == 0)
145 + if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
146 + return -EOPNOTSUPP;
148 + return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_USER, name, value,
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,
158 Index: linux-2.6.27/fs/ocfs2/xattr_trusted.c
159 ===================================================================
160 --- linux-2.6.27.orig/fs/ocfs2/xattr_trusted.c
163 -/* -*- mode: c; c-basic-offset: 8; -*-
164 - * vim: noexpandtab sw=8 ts=8 sts=0:
168 - * Copyright (C) 2008 Oracle. All rights reserved.
171 - * Lots of code in this file is taken from ext3.
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.
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.
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.
189 -#include <linux/init.h>
190 -#include <linux/module.h>
191 -#include <linux/string.h>
193 -#define MLOG_MASK_PREFIX ML_INODE
194 -#include <cluster/masklog.h>
198 -#include "dlmglue.h"
200 -#include "ocfs2_fs.h"
203 -#define XATTR_TRUSTED_PREFIX "trusted."
205 -static size_t ocfs2_xattr_trusted_list(struct inode *inode, char *list,
206 - size_t list_size, const char *name,
209 - const size_t prefix_len = sizeof(XATTR_TRUSTED_PREFIX) - 1;
210 - const size_t total_len = prefix_len + name_len + 1;
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';
220 -static int ocfs2_xattr_trusted_get(struct inode *inode, const char *name,
221 - void *buffer, size_t size)
223 - if (strcmp(name, "") == 0)
225 - return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_TRUSTED, name,
229 -static int ocfs2_xattr_trusted_set(struct inode *inode, const char *name,
230 - const void *value, size_t size, int flags)
232 - if (strcmp(name, "") == 0)
235 - return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_TRUSTED, name, value,
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,
245 Index: linux-2.6.27/fs/ocfs2/xattr_user.c
246 ===================================================================
247 --- linux-2.6.27.orig/fs/ocfs2/xattr_user.c
250 -/* -*- mode: c; c-basic-offset: 8; -*-
251 - * vim: noexpandtab sw=8 ts=8 sts=0:
255 - * Copyright (C) 2008 Oracle. All rights reserved.
258 - * Lots of code in this file is taken from ext3.
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.
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.
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.
276 -#include <linux/init.h>
277 -#include <linux/module.h>
278 -#include <linux/string.h>
280 -#define MLOG_MASK_PREFIX ML_INODE
281 -#include <cluster/masklog.h>
285 -#include "dlmglue.h"
287 -#include "ocfs2_fs.h"
290 -#define XATTR_USER_PREFIX "user."
292 -static size_t ocfs2_xattr_user_list(struct inode *inode, char *list,
293 - size_t list_size, const char *name,
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);
300 - if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
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';
311 -static int ocfs2_xattr_user_get(struct inode *inode, const char *name,
312 - void *buffer, size_t size)
314 - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
316 - if (strcmp(name, "") == 0)
318 - if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
319 - return -EOPNOTSUPP;
320 - return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_USER, name,
324 -static int ocfs2_xattr_user_set(struct inode *inode, const char *name,
325 - const void *value, size_t size, int flags)
327 - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
329 - if (strcmp(name, "") == 0)
331 - if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
332 - return -EOPNOTSUPP;
334 - return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_USER, name, value,
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,