History

Merge branch 'for-linus-3' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull vfs xattr cleanups from Al Viro. * 'for-linus-3' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: f2fs: xattr simplifications squashfs: xattr simplifications 9p: xattr simplifications xattr handlers: Pass handler to operations instead of flags jffs2: Add missing capability check for listing trusted xattrs hfsplus: Remove unused xattr handler list operations ubifs: Remove unused security xattr handler vfs: Fix the posix_acl_xattr_list return value vfs: Check attribute names in posix acl xattr handers

Linus Torvalds committed 11 years ago

Commit 5d2eb542 parents 2870f6c 29608d239 files · +390 −651Browse files

Unified · Split

39 files
  1. fs/9p/Makefile +1 −4
  2. fs/9p/acl.c +13 −52
  3. fs/9p/xattr.c +42 −0
  4. fs/9p/xattr.h +0 −3
  5. fs/9p/xattr_security.c +0 −80
  6. fs/9p/xattr_trusted.c +0 −80
  7. fs/9p/xattr_user.c +0 −80
  8. fs/ext2/xattr.c +3 −4
  9. fs/ext2/xattr_security.c +9 −6
  10. fs/ext2/xattr_trusted.c +9 −6
  11. fs/ext2/xattr_user.c +9 −6
  12. fs/ext4/xattr.c +3 −4
  13. fs/ext4/xattr_security.c +9 −6
  14. fs/ext4/xattr_trusted.c +9 −6
  15. fs/ext4/xattr_user.c +9 −6
  16. fs/f2fs/xattr.c +29 −31
  17. fs/gfs2/xattr.c +8 −5
  18. fs/hfsplus/xattr.c +6 −15
  19. fs/hfsplus/xattr_security.c +6 −15
  20. fs/hfsplus/xattr_trusted.c +6 −15
  21. fs/hfsplus/xattr_user.c +6 −15
  22. fs/jffs2/security.c +10 −6
  23. fs/jffs2/xattr.c +5 −4
  24. fs/jffs2/xattr_trusted.c +13 −6
  25. fs/jffs2/xattr_user.c +10 −6
  26. fs/nfs/nfs4proc.c +20 −14
  27. fs/ocfs2/xattr.c +27 −18
  28. fs/posix_acl.c +18 −18
  29. fs/reiserfs/xattr.c +8 −8
  30. fs/reiserfs/xattr_security.c +7 −6
  31. fs/reiserfs/xattr_trusted.c +7 −6
  32. fs/reiserfs/xattr_user.c +7 −6
  33. fs/squashfs/xattr.c +33 −53
  34. fs/ubifs/super.c +0 −1
  35. fs/ubifs/ubifs.h +0 −1
  36. fs/ubifs/xattr.c +0 −40
  37. fs/xattr.c +31 −8
  38. fs/xfs/xfs_xattr.c +6 −4
  39. include/linux/xattr.h +11 −7
fs/9p/Makefile+1−4
@@ -10,10 +10,7 @@ obj-$(CONFIG_9P_FS) := 9p.o · 9 unmodified lines
1010 vfs_dentry.o \
1111 v9fs.o \
1212 fid.o \
13− xattr.o \
14− xattr_user.o \
15− xattr_trusted.o
13+ xattr.o
1614
1715 9p-$(CONFIG_9P_FSCACHE) += cache.o
1816 9p-$(CONFIG_9P_FS_POSIX_ACL) += acl.o
19−9p-$(CONFIG_9P_FS_SECURITY) += xattr_security.o
fs/9p/acl.c+13−52
@@ -212,26 +212,9 @@ int v9fs_acl_mode(struct inode *dir, umode_t *modep, · 211 unmodified lines
212212 return 0;
213213 }
214214
215−static int v9fs_remote_get_acl(struct dentry *dentry, const char *name,
216− void *buffer, size_t size, int type)
217−{
218− char *full_name;
219−
220− switch (type) {
221− case ACL_TYPE_ACCESS:
222− full_name = POSIX_ACL_XATTR_ACCESS;
223− break;
224− case ACL_TYPE_DEFAULT:
225− full_name = POSIX_ACL_XATTR_DEFAULT;
226− break;
227− default:
228− BUG();
229− }
230− return v9fs_xattr_get(dentry, full_name, buffer, size);
231−}
232−
233−static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name,
234− void *buffer, size_t size, int type)
215+static int v9fs_xattr_get_acl(const struct xattr_handler *handler,
216+ struct dentry *dentry, const char *name,
217+ void *buffer, size_t size)
235218 {
236219 struct v9fs_session_info *v9ses;
237220 struct posix_acl *acl;
@@ -245,9 +228,9 @@ static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name, · 7 unmodified lines
245228 * We allow set/get/list of acl when access=client is not specified
246229 */
247230 if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT)
248− return v9fs_remote_get_acl(dentry, name, buffer, size, type);
231+ return v9fs_xattr_get(dentry, handler->prefix, buffer, size);
249232
250− acl = v9fs_get_cached_acl(d_inode(dentry), type);
233+ acl = v9fs_get_cached_acl(d_inode(dentry), handler->flags);
251234 if (IS_ERR(acl))
252235 return PTR_ERR(acl);
253236 if (acl == NULL)
@@ -258,29 +241,9 @@ static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name, · 4 unmodified lines
258241 return error;
259242 }
260243
261−static int v9fs_remote_set_acl(struct dentry *dentry, const char *name,
262− const void *value, size_t size,
263− int flags, int type)
264−{
265− char *full_name;
266−
267− switch (type) {
268− case ACL_TYPE_ACCESS:
269− full_name = POSIX_ACL_XATTR_ACCESS;
270− break;
271− case ACL_TYPE_DEFAULT:
272− full_name = POSIX_ACL_XATTR_DEFAULT;
273− break;
274− default:
275− BUG();
276− }
277− return v9fs_xattr_set(dentry, full_name, value, size, flags);
278−}
279−
280−
281−static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
282− const void *value, size_t size,
283− int flags, int type)
244+static int v9fs_xattr_set_acl(const struct xattr_handler *handler,
245+ struct dentry *dentry, const char *name,
246+ const void *value, size_t size, int flags)
284247 {
285248 int retval;
286249 struct posix_acl *acl;
@@ -296,8 +259,8 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name, · 9 unmodified lines
296259 * xattr value. We leave it to the server to validate
297260 */
298261 if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT)
299− return v9fs_remote_set_acl(dentry, name,
300− value, size, flags, type);
262+ return v9fs_xattr_set(dentry, handler->prefix, value, size,
263+ flags);
301264
302265 if (S_ISLNK(inode->i_mode))
303266 return -EOPNOTSUPP;
@@ -316,9 +279,8 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name, · 12 unmodified lines
316279 } else
317280 acl = NULL;
318281
319− switch (type) {
282+ switch (handler->flags) {
320283 case ACL_TYPE_ACCESS:
321− name = POSIX_ACL_XATTR_ACCESS;
322284 if (acl) {
323285 umode_t mode = inode->i_mode;
324286 retval = posix_acl_equiv_mode(acl, &mode);
@@ -349,7 +311,6 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name, · 24 unmodified lines
349311 }
350312 break;
351313 case ACL_TYPE_DEFAULT:
352− name = POSIX_ACL_XATTR_DEFAULT;
353314 if (!S_ISDIR(inode->i_mode)) {
354315 retval = acl ? -EINVAL : 0;
355316 goto err_out;
@@ -358,9 +319,9 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name, · 2 unmodified lines
358319 default:
359320 BUG();
360321 }
361− retval = v9fs_xattr_set(dentry, name, value, size, flags);
322+ retval = v9fs_xattr_set(dentry, handler->prefix, value, size, flags);
362323 if (!retval)
363− set_cached_acl(inode, type, acl);
324+ set_cached_acl(inode, handler->flags, acl);
364325 err_out:
365326 posix_acl_release(acl);
366327 return retval;
fs/9p/xattr.c+42−0
@@ -137,6 +137,48 @@ ssize_t v9fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) · 136 unmodified lines
137137 return v9fs_xattr_get(dentry, NULL, buffer, buffer_size);
138138 }
139139
140+static int v9fs_xattr_handler_get(const struct xattr_handler *handler,
141+ struct dentry *dentry, const char *name,
142+ void *buffer, size_t size)
143+{
144+ const char *full_name = xattr_full_name(handler, name);
145+
146+ if (strcmp(name, "") == 0)
147+ return -EINVAL;
148+ return v9fs_xattr_get(dentry, full_name, buffer, size);
149+}
150+
151+static int v9fs_xattr_handler_set(const struct xattr_handler *handler,
152+ struct dentry *dentry, const char *name,
153+ const void *value, size_t size, int flags)
154+{
155+ const char *full_name = xattr_full_name(handler, name);
156+
157+ if (strcmp(name, "") == 0)
158+ return -EINVAL;
159+ return v9fs_xattr_set(dentry, full_name, value, size, flags);
160+}
161+
162+static struct xattr_handler v9fs_xattr_user_handler = {
163+ .prefix = XATTR_USER_PREFIX,
164+ .get = v9fs_xattr_handler_get,
165+ .set = v9fs_xattr_handler_set,
166+};
167+
168+static struct xattr_handler v9fs_xattr_trusted_handler = {
169+ .prefix = XATTR_TRUSTED_PREFIX,
170+ .get = v9fs_xattr_handler_get,
171+ .set = v9fs_xattr_handler_set,
172+};
173+
174+#ifdef CONFIG_9P_FS_SECURITY
175+static struct xattr_handler v9fs_xattr_security_handler = {
176+ .prefix = XATTR_SECURITY_PREFIX,
177+ .get = v9fs_xattr_handler_get,
178+ .set = v9fs_xattr_handler_set,
179+};
180+#endif
181+
140182 const struct xattr_handler *v9fs_xattr_handlers[] = {
141183 &v9fs_xattr_user_handler,
142184 &v9fs_xattr_trusted_handler,
fs/9p/xattr.h+0−3
@@ -19,9 +19,6 @@ · 18 unmodified lines
1919 #include <net/9p/client.h>
2020
2121 extern const struct xattr_handler *v9fs_xattr_handlers[];
22−extern struct xattr_handler v9fs_xattr_user_handler;
23−extern struct xattr_handler v9fs_xattr_trusted_handler;
24−extern struct xattr_handler v9fs_xattr_security_handler;
2522 extern const struct xattr_handler v9fs_xattr_acl_access_handler;
2623 extern const struct xattr_handler v9fs_xattr_acl_default_handler;
2724
fs/9p/xattr_security.c+0−80
@@ -1,80 +0,0 @@
1−/*
2− * Copyright IBM Corporation, 2010
3− * Author Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
4− *
5− * This program is free software; you can redistribute it and/or modify it
6− * under the terms of version 2.1 of the GNU Lesser General Public License
7− * as published by the Free Software Foundation.
8− *
9− * This program is distributed in the hope that it would be useful, but
10− * WITHOUT ANY WARRANTY; without even the implied warranty of
11− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12− *
13− */
14−
15−
16−#include <linux/module.h>
17−#include <linux/string.h>
18−#include <linux/fs.h>
19−#include <linux/slab.h>
20−#include "xattr.h"
21−
22−static int v9fs_xattr_security_get(struct dentry *dentry, const char *name,
23− void *buffer, size_t size, int type)
24−{
25− int retval;
26− char *full_name;
27− size_t name_len;
28− size_t prefix_len = XATTR_SECURITY_PREFIX_LEN;
29−
30− if (name == NULL)
31− return -EINVAL;
32−
33− if (strcmp(name, "") == 0)
34− return -EINVAL;
35−
36− name_len = strlen(name);
37− full_name = kmalloc(prefix_len + name_len + 1 , GFP_KERNEL);
38− if (!full_name)
39− return -ENOMEM;
40− memcpy(full_name, XATTR_SECURITY_PREFIX, prefix_len);
41− memcpy(full_name+prefix_len, name, name_len);
42− full_name[prefix_len + name_len] = '\0';
43−
44− retval = v9fs_xattr_get(dentry, full_name, buffer, size);
45− kfree(full_name);
46− return retval;
47−}
48−
49−static int v9fs_xattr_security_set(struct dentry *dentry, const char *name,
50− const void *value, size_t size, int flags, int type)
51−{
52− int retval;
53− char *full_name;
54− size_t name_len;
55− size_t prefix_len = XATTR_SECURITY_PREFIX_LEN;
56−
57− if (name == NULL)
58− return -EINVAL;
59−
60− if (strcmp(name, "") == 0)
61− return -EINVAL;
62−
63− name_len = strlen(name);
64− full_name = kmalloc(prefix_len + name_len + 1 , GFP_KERNEL);
65− if (!full_name)
66− return -ENOMEM;
67− memcpy(full_name, XATTR_SECURITY_PREFIX, prefix_len);
68− memcpy(full_name + prefix_len, name, name_len);
69− full_name[prefix_len + name_len] = '\0';
70−
71− retval = v9fs_xattr_set(dentry, full_name, value, size, flags);
72− kfree(full_name);
73− return retval;
74−}
75−
76−struct xattr_handler v9fs_xattr_security_handler = {
77− .prefix = XATTR_SECURITY_PREFIX,
78− .get = v9fs_xattr_security_get,
79− .set = v9fs_xattr_security_set,
80−};
fs/9p/xattr_trusted.c+0−80
@@ -1,80 +0,0 @@
1−/*
2− * Copyright IBM Corporation, 2010
3− * Author Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
4− *
5− * This program is free software; you can redistribute it and/or modify it
6− * under the terms of version 2.1 of the GNU Lesser General Public License
7− * as published by the Free Software Foundation.
8− *
9− * This program is distributed in the hope that it would be useful, but
10− * WITHOUT ANY WARRANTY; without even the implied warranty of
11− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12− *
13− */
14−
15−
16−#include <linux/module.h>
17−#include <linux/string.h>
18−#include <linux/fs.h>
19−#include <linux/slab.h>
20−#include "xattr.h"
21−
22−static int v9fs_xattr_trusted_get(struct dentry *dentry, const char *name,
23− void *buffer, size_t size, int type)
24−{
25− int retval;
26− char *full_name;
27− size_t name_len;
28− size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN;
29−
30− if (name == NULL)
31− return -EINVAL;
32−
33− if (strcmp(name, "") == 0)
34− return -EINVAL;
35−
36− name_len = strlen(name);
37− full_name = kmalloc(prefix_len + name_len + 1 , GFP_KERNEL);
38− if (!full_name)
39− return -ENOMEM;
40− memcpy(full_name, XATTR_TRUSTED_PREFIX, prefix_len);
41− memcpy(full_name+prefix_len, name, name_len);
42− full_name[prefix_len + name_len] = '\0';
43−
44− retval = v9fs_xattr_get(dentry, full_name, buffer, size);
45− kfree(full_name);
46− return retval;
47−}
48−
49−static int v9fs_xattr_trusted_set(struct dentry *dentry, const char *name,
50− const void *value, size_t size, int flags, int type)
51−{
52− int retval;
53− char *full_name;
54− size_t name_len;
55− size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN;
56−
57− if (name == NULL)
58− return -EINVAL;
59−
60− if (strcmp(name, "") == 0)
61− return -EINVAL;
62−
63− name_len = strlen(name);
64− full_name = kmalloc(prefix_len + name_len + 1 , GFP_KERNEL);
65− if (!full_name)
66− return -ENOMEM;
67− memcpy(full_name, XATTR_TRUSTED_PREFIX, prefix_len);
68− memcpy(full_name + prefix_len, name, name_len);
69− full_name[prefix_len + name_len] = '\0';
70−
71− retval = v9fs_xattr_set(dentry, full_name, value, size, flags);
72− kfree(full_name);
73− return retval;
74−}
75−
76−struct xattr_handler v9fs_xattr_trusted_handler = {
77− .prefix = XATTR_TRUSTED_PREFIX,
78− .get = v9fs_xattr_trusted_get,
79− .set = v9fs_xattr_trusted_set,
80−};
fs/9p/xattr_user.c+0−80
@@ -1,80 +0,0 @@
1−/*
2− * Copyright IBM Corporation, 2010
3− * Author Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
4− *
5− * This program is free software; you can redistribute it and/or modify it
6− * under the terms of version 2.1 of the GNU Lesser General Public License
7− * as published by the Free Software Foundation.
8− *
9− * This program is distributed in the hope that it would be useful, but
10− * WITHOUT ANY WARRANTY; without even the implied warranty of
11− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12− *
13− */
14−
15−
16−#include <linux/module.h>
17−#include <linux/string.h>
18−#include <linux/fs.h>
19−#include <linux/slab.h>
20−#include "xattr.h"
21−
22−static int v9fs_xattr_user_get(struct dentry *dentry, const char *name,
23− void *buffer, size_t size, int type)
24−{
25− int retval;
26− char *full_name;
27− size_t name_len;
28− size_t prefix_len = XATTR_USER_PREFIX_LEN;
29−
30− if (name == NULL)
31− return -EINVAL;
32−
33− if (strcmp(name, "") == 0)
34− return -EINVAL;
35−
36− name_len = strlen(name);
37− full_name = kmalloc(prefix_len + name_len + 1 , GFP_KERNEL);
38− if (!full_name)
39− return -ENOMEM;
40− memcpy(full_name, XATTR_USER_PREFIX, prefix_len);
41− memcpy(full_name+prefix_len, name, name_len);
42− full_name[prefix_len + name_len] = '\0';
43−
44− retval = v9fs_xattr_get(dentry, full_name, buffer, size);
45− kfree(full_name);
46− return retval;
47−}
48−
49−static int v9fs_xattr_user_set(struct dentry *dentry, const char *name,
50− const void *value, size_t size, int flags, int type)
51−{
52− int retval;
53− char *full_name;
54− size_t name_len;
55− size_t prefix_len = XATTR_USER_PREFIX_LEN;
56−
57− if (name == NULL)
58− return -EINVAL;
59−
60− if (strcmp(name, "") == 0)
61− return -EINVAL;
62−
63− name_len = strlen(name);
64− full_name = kmalloc(prefix_len + name_len + 1 , GFP_KERNEL);
65− if (!full_name)
66− return -ENOMEM;
67− memcpy(full_name, XATTR_USER_PREFIX, prefix_len);
68− memcpy(full_name + prefix_len, name, name_len);
69− full_name[prefix_len + name_len] = '\0';
70−
71− retval = v9fs_xattr_set(dentry, full_name, value, size, flags);
72− kfree(full_name);
73− return retval;
74−}
75−
76−struct xattr_handler v9fs_xattr_user_handler = {
77− .prefix = XATTR_USER_PREFIX,
78− .get = v9fs_xattr_user_get,
79− .set = v9fs_xattr_user_set,
80−};
fs/ext2/xattr.c+3−4
@@ -293,10 +293,9 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list", · 292 unmodified lines
293293 ext2_xattr_handler(entry->e_name_index);
294294
295295 if (handler) {
296− size_t size = handler->list(dentry, buffer, rest,
297− entry->e_name,
298− entry->e_name_len,
299− handler->flags);
296+ size_t size = handler->list(handler, dentry, buffer,
297+ rest, entry->e_name,
298+ entry->e_name_len);
300299 if (buffer) {
301300 if (size > rest) {
302301 error = -ERANGE;
fs/ext2/xattr_security.c+9−6
@@ -8,8 +8,9 @@ · 7 unmodified lines
88 #include "xattr.h"
99
1010 static size_t
11−ext2_xattr_security_list(struct dentry *dentry, char *list, size_t list_size,
12− const char *name, size_t name_len, int type)
11+ext2_xattr_security_list(const struct xattr_handler *handler,
12+ struct dentry *dentry, char *list, size_t list_size,
13+ const char *name, size_t name_len)
1314 {
1415 const int prefix_len = XATTR_SECURITY_PREFIX_LEN;
1516 const size_t total_len = prefix_len + name_len + 1;
@@ -23,8 +24,9 @@ ext2_xattr_security_list(struct dentry *dentry, char *list, size_t list_size, · 7 unmodified lines
2324 }
2425
2526 static int
26−ext2_xattr_security_get(struct dentry *dentry, const char *name,
27− void *buffer, size_t size, int type)
27+ext2_xattr_security_get(const struct xattr_handler *handler,
28+ struct dentry *dentry, const char *name,
29+ void *buffer, size_t size)
2830 {
2931 if (strcmp(name, "") == 0)
3032 return -EINVAL;
@@ -33,8 +35,9 @@ ext2_xattr_security_get(struct dentry *dentry, const char *name, · 2 unmodified lines
3335 }
3436
3537 static int
36−ext2_xattr_security_set(struct dentry *dentry, const char *name,
37− const void *value, size_t size, int flags, int type)
38+ext2_xattr_security_set(const struct xattr_handler *handler,
39+ struct dentry *dentry, const char *name,
40+ const void *value, size_t size, int flags)
3841 {
3942 if (strcmp(name, "") == 0)
4043 return -EINVAL;
fs/ext2/xattr_trusted.c+9−6
@@ -9,8 +9,9 @@ · 8 unmodified lines
99 #include "xattr.h"
1010
1111 static size_t
12−ext2_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size,
13− const char *name, size_t name_len, int type)
12+ext2_xattr_trusted_list(const struct xattr_handler *handler,
13+ struct dentry *dentry, char *list, size_t list_size,
14+ const char *name, size_t name_len)
1415 {
1516 const int prefix_len = XATTR_TRUSTED_PREFIX_LEN;
1617 const size_t total_len = prefix_len + name_len + 1;
@@ -27,8 +28,9 @@ ext2_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size, · 10 unmodified lines
2728 }
2829
2930 static int
30−ext2_xattr_trusted_get(struct dentry *dentry, const char *name,
31− void *buffer, size_t size, int type)
31+ext2_xattr_trusted_get(const struct xattr_handler *handler,
32+ struct dentry *dentry, const char *name,
33+ void *buffer, size_t size)
3234 {
3335 if (strcmp(name, "") == 0)
3436 return -EINVAL;
@@ -37,8 +39,9 @@ ext2_xattr_trusted_get(struct dentry *dentry, const char *name, · 2 unmodified lines
3739 }
3840
3941 static int
40−ext2_xattr_trusted_set(struct dentry *dentry, const char *name,
41− const void *value, size_t size, int flags, int type)
42+ext2_xattr_trusted_set(const struct xattr_handler *handler,
43+ struct dentry *dentry, const char *name,
44+ const void *value, size_t size, int flags)
4245 {
4346 if (strcmp(name, "") == 0)
4447 return -EINVAL;
fs/ext2/xattr_user.c+9−6
@@ -11,8 +11,9 @@ · 10 unmodified lines
1111 #include "xattr.h"
1212
1313 static size_t
14−ext2_xattr_user_list(struct dentry *dentry, char *list, size_t list_size,
15− const char *name, size_t name_len, int type)
14+ext2_xattr_user_list(const struct xattr_handler *handler,
15+ struct dentry *dentry, char *list, size_t list_size,
16+ const char *name, size_t name_len)
1617 {
1718 const size_t prefix_len = XATTR_USER_PREFIX_LEN;
1819 const size_t total_len = prefix_len + name_len + 1;
@@ -29,8 +30,9 @@ ext2_xattr_user_list(struct dentry *dentry, char *list, size_t list_size, · 10 unmodified lines
2930 }
3031
3132 static int
32−ext2_xattr_user_get(struct dentry *dentry, const char *name,
33− void *buffer, size_t size, int type)
33+ext2_xattr_user_get(const struct xattr_handler *handler,
34+ struct dentry *dentry, const char *name,
35+ void *buffer, size_t size)
3436 {
3537 if (strcmp(name, "") == 0)
3638 return -EINVAL;
@@ -41,8 +43,9 @@ ext2_xattr_user_get(struct dentry *dentry, const char *name, · 4 unmodified lines
4143 }
4244
4345 static int
44−ext2_xattr_user_set(struct dentry *dentry, const char *name,
45− const void *value, size_t size, int flags, int type)
46+ext2_xattr_user_set(const struct xattr_handler *handler,
47+ struct dentry *dentry, const char *name,
48+ const void *value, size_t size, int flags)
4649 {
4750 if (strcmp(name, "") == 0)
4851 return -EINVAL;
fs/ext4/xattr.c+3−4
@@ -405,10 +405,9 @@ ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry, · 404 unmodified lines
405405 ext4_xattr_handler(entry->e_name_index);
406406
407407 if (handler) {
408− size_t size = handler->list(dentry, buffer, rest,
409− entry->e_name,
410− entry->e_name_len,
411− handler->flags);
408+ size_t size = handler->list(handler, dentry, buffer,
409+ rest, entry->e_name,
410+ entry->e_name_len);
412411 if (buffer) {
413412 if (size > rest)
414413 return -ERANGE;
fs/ext4/xattr_security.c+9−6
@@ -12,8 +12,9 @@ · 11 unmodified lines
1212 #include "xattr.h"
1313
1414 static size_t
15−ext4_xattr_security_list(struct dentry *dentry, char *list, size_t list_size,
16− const char *name, size_t name_len, int type)
15+ext4_xattr_security_list(const struct xattr_handler *handler,
16+ struct dentry *dentry, char *list, size_t list_size,
17+ const char *name, size_t name_len)
1718 {
1819 const size_t prefix_len = sizeof(XATTR_SECURITY_PREFIX)-1;
1920 const size_t total_len = prefix_len + name_len + 1;
@@ -28,8 +29,9 @@ ext4_xattr_security_list(struct dentry *dentry, char *list, size_t list_size, · 8 unmodified lines
2829 }
2930
3031 static int
31−ext4_xattr_security_get(struct dentry *dentry, const char *name,
32− void *buffer, size_t size, int type)
32+ext4_xattr_security_get(const struct xattr_handler *handler,
33+ struct dentry *dentry, const char *name,
34+ void *buffer, size_t size)
3335 {
3436 if (strcmp(name, "") == 0)
3537 return -EINVAL;
@@ -38,8 +40,9 @@ ext4_xattr_security_get(struct dentry *dentry, const char *name, · 2 unmodified lines
3840 }
3941
4042 static int
41−ext4_xattr_security_set(struct dentry *dentry, const char *name,
42− const void *value, size_t size, int flags, int type)
43+ext4_xattr_security_set(const struct xattr_handler *handler,
44+ struct dentry *dentry, const char *name,
45+ const void *value, size_t size, int flags)
4346 {
4447 if (strcmp(name, "") == 0)
4548 return -EINVAL;
fs/ext4/xattr_trusted.c+9−6
@@ -13,8 +13,9 @@ · 12 unmodified lines
1313 #include "xattr.h"
1414
1515 static size_t
16−ext4_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size,
17− const char *name, size_t name_len, int type)
16+ext4_xattr_trusted_list(const struct xattr_handler *handler,
17+ struct dentry *dentry, char *list, size_t list_size,
18+ const char *name, size_t name_len)
1819 {
1920 const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN;
2021 const size_t total_len = prefix_len + name_len + 1;
@@ -31,8 +32,9 @@ ext4_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size, · 10 unmodified lines
3132 }
3233
3334 static int
34−ext4_xattr_trusted_get(struct dentry *dentry, const char *name, void *buffer,
35− size_t size, int type)
35+ext4_xattr_trusted_get(const struct xattr_handler *handler,
36+ struct dentry *dentry, const char *name, void *buffer,
37+ size_t size)
3638 {
3739 if (strcmp(name, "") == 0)
3840 return -EINVAL;
@@ -41,8 +43,9 @@ ext4_xattr_trusted_get(struct dentry *dentry, const char *name, void *buffer, · 2 unmodified lines
4143 }
4244
4345 static int
44−ext4_xattr_trusted_set(struct dentry *dentry, const char *name,
45− const void *value, size_t size, int flags, int type)
46+ext4_xattr_trusted_set(const struct xattr_handler *handler,
47+ struct dentry *dentry, const char *name,
48+ const void *value, size_t size, int flags)
4649 {
4750 if (strcmp(name, "") == 0)
4851 return -EINVAL;
fs/ext4/xattr_user.c+9−6
@@ -12,8 +12,9 @@ · 11 unmodified lines
1212 #include "xattr.h"
1313
1414 static size_t
15−ext4_xattr_user_list(struct dentry *dentry, char *list, size_t list_size,
16− const char *name, size_t name_len, int type)
15+ext4_xattr_user_list(const struct xattr_handler *handler,
16+ struct dentry *dentry, char *list, size_t list_size,
17+ const char *name, size_t name_len)
1718 {
1819 const size_t prefix_len = XATTR_USER_PREFIX_LEN;
1920 const size_t total_len = prefix_len + name_len + 1;
@@ -30,8 +31,9 @@ ext4_xattr_user_list(struct dentry *dentry, char *list, size_t list_size, · 10 unmodified lines
3031 }
3132
3233 static int
33−ext4_xattr_user_get(struct dentry *dentry, const char *name,
34− void *buffer, size_t size, int type)
34+ext4_xattr_user_get(const struct xattr_handler *handler,
35+ struct dentry *dentry, const char *name,
36+ void *buffer, size_t size)
3537 {
3638 if (strcmp(name, "") == 0)
3739 return -EINVAL;
@@ -42,8 +44,9 @@ ext4_xattr_user_get(struct dentry *dentry, const char *name, · 4 unmodified lines
4244 }
4345
4446 static int
45−ext4_xattr_user_set(struct dentry *dentry, const char *name,
46− const void *value, size_t size, int flags, int type)
47+ext4_xattr_user_set(const struct xattr_handler *handler,
48+ struct dentry *dentry, const char *name,
49+ const void *value, size_t size, int flags)
4750 {
4851 if (strcmp(name, "") == 0)
4952 return -EINVAL;
fs/f2fs/xattr.c+29−31
@@ -25,49 +25,45 @@ · 24 unmodified lines
2525 #include "f2fs.h"
2626 #include "xattr.h"
2727
28−static size_t f2fs_xattr_generic_list(struct dentry *dentry, char *list,
29− size_t list_size, const char *name, size_t len, int type)
28+static size_t f2fs_xattr_generic_list(const struct xattr_handler *handler,
29+ struct dentry *dentry, char *list, size_t list_size,
30+ const char *name, size_t len)
3031 {
3132 struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb);
32− int total_len, prefix_len = 0;
33− const char *prefix = NULL;
33+ int total_len, prefix_len;
3434
35− switch (type) {
35+ switch (handler->flags) {
3636 case F2FS_XATTR_INDEX_USER:
3737 if (!test_opt(sbi, XATTR_USER))
3838 return -EOPNOTSUPP;
39− prefix = XATTR_USER_PREFIX;
40− prefix_len = XATTR_USER_PREFIX_LEN;
4139 break;
4240 case F2FS_XATTR_INDEX_TRUSTED:
4341 if (!capable(CAP_SYS_ADMIN))
4442 return -EPERM;
45− prefix = XATTR_TRUSTED_PREFIX;
46− prefix_len = XATTR_TRUSTED_PREFIX_LEN;
4743 break;
4844 case F2FS_XATTR_INDEX_SECURITY:
49− prefix = XATTR_SECURITY_PREFIX;
50− prefix_len = XATTR_SECURITY_PREFIX_LEN;
5145 break;
5246 default:
5347 return -EINVAL;
5448 }
5549
50+ prefix_len = strlen(handler->prefix);
5651 total_len = prefix_len + len + 1;
5752 if (list && total_len <= list_size) {
58− memcpy(list, prefix, prefix_len);
53+ memcpy(list, handler->prefix, prefix_len);
5954 memcpy(list + prefix_len, name, len);
6055 list[prefix_len + len] = '\0';
6156 }
6257 return total_len;
6358 }
6459
65−static int f2fs_xattr_generic_get(struct dentry *dentry, const char *name,
66− void *buffer, size_t size, int type)
60+static int f2fs_xattr_generic_get(const struct xattr_handler *handler,
61+ struct dentry *dentry, const char *name, void *buffer,
62+ size_t size)
6763 {
6864 struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb);
6965
70− switch (type) {
66+ switch (handler->flags) {
7167 case F2FS_XATTR_INDEX_USER:
7268 if (!test_opt(sbi, XATTR_USER))
7369 return -EOPNOTSUPP;
@@ -83,15 +79,17 @@ static int f2fs_xattr_generic_get(struct dentry *dentry, const char *name, · 9 unmodified lines
8379 }
8480 if (strcmp(name, "") == 0)
8581 return -EINVAL;
86− return f2fs_getxattr(d_inode(dentry), type, name, buffer, size, NULL);
82+ return f2fs_getxattr(d_inode(dentry), handler->flags, name,
83+ buffer, size, NULL);
8784 }
8885
89−static int f2fs_xattr_generic_set(struct dentry *dentry, const char *name,
90− const void *value, size_t size, int flags, int type)
86+static int f2fs_xattr_generic_set(const struct xattr_handler *handler,
87+ struct dentry *dentry, const char *name, const void *value,
88+ size_t size, int flags)
9189 {
9290 struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb);
9391
94− switch (type) {
92+ switch (handler->flags) {
9593 case F2FS_XATTR_INDEX_USER:
9694 if (!test_opt(sbi, XATTR_USER))
9795 return -EOPNOTSUPP;
@@ -108,27 +106,26 @@ static int f2fs_xattr_generic_set(struct dentry *dentry, const char *name, · 10 unmodified lines
108106 if (strcmp(name, "") == 0)
109107 return -EINVAL;
110108
111− return f2fs_setxattr(d_inode(dentry), type, name,
109+ return f2fs_setxattr(d_inode(dentry), handler->flags, name,
112110 value, size, NULL, flags);
113111 }
114112
115−static size_t f2fs_xattr_advise_list(struct dentry *dentry, char *list,
116− size_t list_size, const char *name, size_t len, int type)
113+static size_t f2fs_xattr_advise_list(const struct xattr_handler *handler,
114+ struct dentry *dentry, char *list, size_t list_size,
115+ const char *name, size_t len)
117116 {
118117 const char *xname = F2FS_SYSTEM_ADVISE_PREFIX;
119118 size_t size;
120119
121− if (type != F2FS_XATTR_INDEX_ADVISE)
122− return 0;
123−
124120 size = strlen(xname) + 1;
125121 if (list && size <= list_size)
126122 memcpy(list, xname, size);
127123 return size;
128124 }
129125
130−static int f2fs_xattr_advise_get(struct dentry *dentry, const char *name,
131− void *buffer, size_t size, int type)
126+static int f2fs_xattr_advise_get(const struct xattr_handler *handler,
127+ struct dentry *dentry, const char *name, void *buffer,
128+ size_t size)
132129 {
133130 struct inode *inode = d_inode(dentry);
134131
@@ -140,8 +137,9 @@ static int f2fs_xattr_advise_get(struct dentry *dentry, const char *name, · 5 unmodified lines
140137 return sizeof(char);
141138 }
142139
143−static int f2fs_xattr_advise_set(struct dentry *dentry, const char *name,
144− const void *value, size_t size, int flags, int type)
140+static int f2fs_xattr_advise_set(const struct xattr_handler *handler,
141+ struct dentry *dentry, const char *name, const void *value,
142+ size_t size, int flags)
145143 {
146144 struct inode *inode = d_inode(dentry);
147145
@@ -462,8 +460,8 @@ ssize_t f2fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) · 314 unmodified lines
462460 if (!handler)
463461 continue;
464462
465− size = handler->list(dentry, buffer, rest, entry->e_name,
466− entry->e_name_len, handler->flags);
463+ size = handler->list(handler, dentry, buffer, rest,
464+ entry->e_name, entry->e_name_len);
467465 if (buffer && size > rest) {
468466 error = -ERANGE;
469467 goto cleanup;
fs/gfs2/xattr.c+8−5
@@ -583,11 +583,13 @@ out: · 582 unmodified lines
583583 *
584584 * Returns: actual size of data on success, -errno on error
585585 */
586−static int gfs2_xattr_get(struct dentry *dentry, const char *name,
587− void *buffer, size_t size, int type)
586+static int gfs2_xattr_get(const struct xattr_handler *handler,
587+ struct dentry *dentry, const char *name,
588+ void *buffer, size_t size)
588589 {
589590 struct gfs2_inode *ip = GFS2_I(d_inode(dentry));
590591 struct gfs2_ea_location el;
592+ int type = handler->flags;
591593 int error;
592594
593595 if (!ip->i_eattr)
@@ -1227,11 +1229,12 @@ int __gfs2_xattr_set(struct inode *inode, const char *name, · 633 unmodified lines
12271229 return error;
12281230 }
12291231
1230−static int gfs2_xattr_set(struct dentry *dentry, const char *name,
1231− const void *value, size_t size, int flags, int type)
1232+static int gfs2_xattr_set(const struct xattr_handler *handler,
1233+ struct dentry *dentry, const char *name,
1234+ const void *value, size_t size, int flags)
12321235 {
12331236 return __gfs2_xattr_set(d_inode(dentry), name, value,
1234− size, flags, type);
1237+ size, flags, handler->flags);
12351238 }
12361239
12371240
fs/hfsplus/xattr.c+6−15
@@ -849,8 +849,9 @@ end_removexattr: · 848 unmodified lines
849849 return err;
850850 }
851851
852−static int hfsplus_osx_getxattr(struct dentry *dentry, const char *name,
853− void *buffer, size_t size, int type)
852+static int hfsplus_osx_getxattr(const struct xattr_handler *handler,
853+ struct dentry *dentry, const char *name,
854+ void *buffer, size_t size)
854855 {
855856 if (!strcmp(name, ""))
856857 return -EINVAL;
@@ -871,8 +872,9 @@ static int hfsplus_osx_getxattr(struct dentry *dentry, const char *name, · 14 unmodified lines
871872 return __hfsplus_getxattr(d_inode(dentry), name, buffer, size);
872873 }
873874
874−static int hfsplus_osx_setxattr(struct dentry *dentry, const char *name,
875− const void *buffer, size_t size, int flags, int type)
875+static int hfsplus_osx_setxattr(const struct xattr_handler *handler,
876+ struct dentry *dentry, const char *name,
877+ const void *buffer, size_t size, int flags)
876878 {
877879 if (!strcmp(name, ""))
878880 return -EINVAL;
@@ -893,19 +895,8 @@ static int hfsplus_osx_setxattr(struct dentry *dentry, const char *name, · 14 unmodified lines
893895 return __hfsplus_setxattr(d_inode(dentry), name, buffer, size, flags);
894896 }
895897
896−static size_t hfsplus_osx_listxattr(struct dentry *dentry, char *list,
897− size_t list_size, const char *name, size_t name_len, int type)
898−{
899− /*
900− * This method is not used.
901− * It is used hfsplus_listxattr() instead of generic_listxattr().
902− */
903− return -EOPNOTSUPP;
904−}
905−
906898 const struct xattr_handler hfsplus_xattr_osx_handler = {
907899 .prefix = XATTR_MAC_OSX_PREFIX,
908− .list = hfsplus_osx_listxattr,
909900 .get = hfsplus_osx_getxattr,
910901 .set = hfsplus_osx_setxattr,
911902 };
fs/hfsplus/xattr_security.c+6−15
@@ -13,32 +13,24 @@ · 12 unmodified lines
1313 #include "xattr.h"
1414 #include "acl.h"
1515
16−static int hfsplus_security_getxattr(struct dentry *dentry, const char *name,
17− void *buffer, size_t size, int type)
16+static int hfsplus_security_getxattr(const struct xattr_handler *handler,
17+ struct dentry *dentry, const char *name,
18+ void *buffer, size_t size)
1819 {
1920 return hfsplus_getxattr(dentry, name, buffer, size,
2021 XATTR_SECURITY_PREFIX,
2122 XATTR_SECURITY_PREFIX_LEN);
2223 }
2324
24−static int hfsplus_security_setxattr(struct dentry *dentry, const char *name,
25− const void *buffer, size_t size, int flags, int type)
25+static int hfsplus_security_setxattr(const struct xattr_handler *handler,
26+ struct dentry *dentry, const char *name,
27+ const void *buffer, size_t size, int flags)
2628 {
2729 return hfsplus_setxattr(dentry, name, buffer, size, flags,
2830 XATTR_SECURITY_PREFIX,
2931 XATTR_SECURITY_PREFIX_LEN);
3032 }
3133
32−static size_t hfsplus_security_listxattr(struct dentry *dentry, char *list,
33− size_t list_size, const char *name, size_t name_len, int type)
34−{
35− /*
36− * This method is not used.
37− * It is used hfsplus_listxattr() instead of generic_listxattr().
38− */
39− return -EOPNOTSUPP;
40−}
41−
4234 static int hfsplus_initxattrs(struct inode *inode,
4335 const struct xattr *xattr_array,
4436 void *fs_info)
@@ -92,7 +84,6 @@ int hfsplus_init_inode_security(struct inode *inode, · 47 unmodified lines
9284
9385 const struct xattr_handler hfsplus_xattr_security_handler = {
9486 .prefix = XATTR_SECURITY_PREFIX,
95− .list = hfsplus_security_listxattr,
9687 .get = hfsplus_security_getxattr,
9788 .set = hfsplus_security_setxattr,
9889 };
fs/hfsplus/xattr_trusted.c+6−15
@@ -11,34 +11,25 @@ · 10 unmodified lines
1111 #include "hfsplus_fs.h"
1212 #include "xattr.h"
1313
14−static int hfsplus_trusted_getxattr(struct dentry *dentry, const char *name,
15− void *buffer, size_t size, int type)
14+static int hfsplus_trusted_getxattr(const struct xattr_handler *handler,
15+ struct dentry *dentry, const char *name,
16+ void *buffer, size_t size)
1617 {
1718 return hfsplus_getxattr(dentry, name, buffer, size,
1819 XATTR_TRUSTED_PREFIX,
1920 XATTR_TRUSTED_PREFIX_LEN);
2021 }
2122
22−static int hfsplus_trusted_setxattr(struct dentry *dentry, const char *name,
23− const void *buffer, size_t size, int flags, int type)
23+static int hfsplus_trusted_setxattr(const struct xattr_handler *handler,
24+ struct dentry *dentry, const char *name,
25+ const void *buffer, size_t size, int flags)
2426 {
2527 return hfsplus_setxattr(dentry, name, buffer, size, flags,
2628 XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN);
2729 }
2830
29−static size_t hfsplus_trusted_listxattr(struct dentry *dentry, char *list,
30− size_t list_size, const char *name, size_t name_len, int type)
31−{
32− /*
33− * This method is not used.
34− * It is used hfsplus_listxattr() instead of generic_listxattr().
35− */
36− return -EOPNOTSUPP;
37−}
38−
3931 const struct xattr_handler hfsplus_xattr_trusted_handler = {
4032 .prefix = XATTR_TRUSTED_PREFIX,
41− .list = hfsplus_trusted_listxattr,
4233 .get = hfsplus_trusted_getxattr,
4334 .set = hfsplus_trusted_setxattr,
4435 };
fs/hfsplus/xattr_user.c+6−15
@@ -11,34 +11,25 @@ · 10 unmodified lines
1111 #include "hfsplus_fs.h"
1212 #include "xattr.h"
1313
14−static int hfsplus_user_getxattr(struct dentry *dentry, const char *name,
15− void *buffer, size_t size, int type)
14+static int hfsplus_user_getxattr(const struct xattr_handler *handler,
15+ struct dentry *dentry, const char *name,
16+ void *buffer, size_t size)
1617 {
1718
1819 return hfsplus_getxattr(dentry, name, buffer, size,
1920 XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN);
2021 }
2122
22−static int hfsplus_user_setxattr(struct dentry *dentry, const char *name,
23− const void *buffer, size_t size, int flags, int type)
23+static int hfsplus_user_setxattr(const struct xattr_handler *handler,
24+ struct dentry *dentry, const char *name,
25+ const void *buffer, size_t size, int flags)
2426 {
2527 return hfsplus_setxattr(dentry, name, buffer, size, flags,
2628 XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN);
2729 }
2830
29−static size_t hfsplus_user_listxattr(struct dentry *dentry, char *list,
30− size_t list_size, const char *name, size_t name_len, int type)
31−{
32− /*
33− * This method is not used.
34− * It is used hfsplus_listxattr() instead of generic_listxattr().
35− */
36− return -EOPNOTSUPP;
37−}
38−
3931 const struct xattr_handler hfsplus_xattr_user_handler = {
4032 .prefix = XATTR_USER_PREFIX,
41− .list = hfsplus_user_listxattr,
4233 .get = hfsplus_user_getxattr,
4334 .set = hfsplus_user_setxattr,
4435 };
fs/jffs2/security.c+10−6
@@ -48,8 +48,9 @@ int jffs2_init_security(struct inode *inode, struct inode *dir, · 47 unmodified lines
4848 }
4949
5050 /* ---- XATTR Handler for "security.*" ----------------- */
51−static int jffs2_security_getxattr(struct dentry *dentry, const char *name,
52− void *buffer, size_t size, int type)
51+static int jffs2_security_getxattr(const struct xattr_handler *handler,
52+ struct dentry *dentry, const char *name,
53+ void *buffer, size_t size)
5354 {
5455 if (!strcmp(name, ""))
5556 return -EINVAL;
@@ -58,8 +59,9 @@ static int jffs2_security_getxattr(struct dentry *dentry, const char *name, · 2 unmodified lines
5859 name, buffer, size);
5960 }
6061
61−static int jffs2_security_setxattr(struct dentry *dentry, const char *name,
62− const void *buffer, size_t size, int flags, int type)
62+static int jffs2_security_setxattr(const struct xattr_handler *handler,
63+ struct dentry *dentry, const char *name,
64+ const void *buffer, size_t size, int flags)
6365 {
6466 if (!strcmp(name, ""))
6567 return -EINVAL;
@@ -68,8 +70,10 @@ static int jffs2_security_setxattr(struct dentry *dentry, const char *name, · 2 unmodified lines
6870 name, buffer, size, flags);
6971 }
7072
71−static size_t jffs2_security_listxattr(struct dentry *dentry, char *list,
72− size_t list_size, const char *name, size_t name_len, int type)
73+static size_t jffs2_security_listxattr(const struct xattr_handler *handler,
74+ struct dentry *dentry, char *list,
75+ size_t list_size, const char *name,
76+ size_t name_len)
7377 {
7478 size_t retlen = XATTR_SECURITY_PREFIX_LEN + name_len + 1;
7579
fs/jffs2/xattr.c+5−4
@@ -1001,11 +1001,12 @@ ssize_t jffs2_listxattr(struct dentry *dentry, char *buffer, size_t size) · 1000 unmodified lines
10011001 if (!xhandle)
10021002 continue;
10031003 if (buffer) {
1004− rc = xhandle->list(dentry, buffer+len, size-len,
1005− xd->xname, xd->name_len, xd->flags);
1004+ rc = xhandle->list(xhandle, dentry, buffer + len,
1005+ size - len, xd->xname,
1006+ xd->name_len);
10061007 } else {
1007− rc = xhandle->list(dentry, NULL, 0, xd->xname,
1008− xd->name_len, xd->flags);
1008+ rc = xhandle->list(xhandle, dentry, NULL, 0,
1009+ xd->xname, xd->name_len);
10091010 }
10101011 if (rc < 0)
10111012 goto out;
fs/jffs2/xattr_trusted.c+13−6
@@ -16,8 +16,9 @@ · 15 unmodified lines
1616 #include <linux/mtd/mtd.h>
1717 #include "nodelist.h"
1818
19−static int jffs2_trusted_getxattr(struct dentry *dentry, const char *name,
20− void *buffer, size_t size, int type)
19+static int jffs2_trusted_getxattr(const struct xattr_handler *handler,
20+ struct dentry *dentry, const char *name,
21+ void *buffer, size_t size)
2122 {
2223 if (!strcmp(name, ""))
2324 return -EINVAL;
@@ -25,8 +26,9 @@ static int jffs2_trusted_getxattr(struct dentry *dentry, const char *name, · 1 unmodified line
2526 name, buffer, size);
2627 }
2728
28−static int jffs2_trusted_setxattr(struct dentry *dentry, const char *name,
29− const void *buffer, size_t size, int flags, int type)
29+static int jffs2_trusted_setxattr(const struct xattr_handler *handler,
30+ struct dentry *dentry, const char *name,
31+ const void *buffer, size_t size, int flags)
3032 {
3133 if (!strcmp(name, ""))
3234 return -EINVAL;
@@ -34,11 +36,16 @@ static int jffs2_trusted_setxattr(struct dentry *dentry, const char *name, · 1 unmodified line
3436 name, buffer, size, flags);
3537 }
3638
37−static size_t jffs2_trusted_listxattr(struct dentry *dentry, char *list,
38− size_t list_size, const char *name, size_t name_len, int type)
39+static size_t jffs2_trusted_listxattr(const struct xattr_handler *handler,
40+ struct dentry *dentry, char *list,
41+ size_t list_size, const char *name,
42+ size_t name_len)
3943 {
4044 size_t retlen = XATTR_TRUSTED_PREFIX_LEN + name_len + 1;
4145
46+ if (!capable(CAP_SYS_ADMIN))
47+ return 0;
48+
4249 if (list && retlen<=list_size) {
4350 strcpy(list, XATTR_TRUSTED_PREFIX);
4451 strcpy(list + XATTR_TRUSTED_PREFIX_LEN, name);
fs/jffs2/xattr_user.c+10−6
@@ -16,8 +16,9 @@ · 15 unmodified lines
1616 #include <linux/mtd/mtd.h>
1717 #include "nodelist.h"
1818
19−static int jffs2_user_getxattr(struct dentry *dentry, const char *name,
20− void *buffer, size_t size, int type)
19+static int jffs2_user_getxattr(const struct xattr_handler *handler,
20+ struct dentry *dentry, const char *name,
21+ void *buffer, size_t size)
2122 {
2223 if (!strcmp(name, ""))
2324 return -EINVAL;
@@ -25,8 +26,9 @@ static int jffs2_user_getxattr(struct dentry *dentry, const char *name, · 1 unmodified line
2526 name, buffer, size);
2627 }
2728
28−static int jffs2_user_setxattr(struct dentry *dentry, const char *name,
29− const void *buffer, size_t size, int flags, int type)
29+static int jffs2_user_setxattr(const struct xattr_handler *handler,
30+ struct dentry *dentry, const char *name,
31+ const void *buffer, size_t size, int flags)
3032 {
3133 if (!strcmp(name, ""))
3234 return -EINVAL;
@@ -34,8 +36,10 @@ static int jffs2_user_setxattr(struct dentry *dentry, const char *name, · 1 unmodified line
3436 name, buffer, size, flags);
3537 }
3638
37−static size_t jffs2_user_listxattr(struct dentry *dentry, char *list,
38− size_t list_size, const char *name, size_t name_len, int type)
39+static size_t jffs2_user_listxattr(const struct xattr_handler *handler,
40+ struct dentry *dentry, char *list,
41+ size_t list_size, const char *name,
42+ size_t name_len)
3943 {
4044 size_t retlen = XATTR_USER_PREFIX_LEN + name_len + 1;
4145
fs/nfs/nfs4proc.c+20−14
@@ -6248,9 +6248,10 @@ nfs4_release_lockowner(struct nfs_server *server, struct nfs4_lock_state *lsp) · 6247 unmodified lines
62486248
62496249 #define XATTR_NAME_NFSV4_ACL "system.nfs4_acl"
62506250
6251−static int nfs4_xattr_set_nfs4_acl(struct dentry *dentry, const char *key,
6251+static int nfs4_xattr_set_nfs4_acl(const struct xattr_handler *handler,
6252+ struct dentry *dentry, const char *key,
62526253 const void *buf, size_t buflen,
6253− int flags, int type)
6254+ int flags)
62546255 {
62556256 if (strcmp(key, "") != 0)
62566257 return -EINVAL;
@@ -6258,8 +6259,9 @@ static int nfs4_xattr_set_nfs4_acl(struct dentry *dentry, const char *key, · 1 unmodified line
62586259 return nfs4_proc_set_acl(d_inode(dentry), buf, buflen);
62596260 }
62606261
6261−static int nfs4_xattr_get_nfs4_acl(struct dentry *dentry, const char *key,
6262− void *buf, size_t buflen, int type)
6262+static int nfs4_xattr_get_nfs4_acl(const struct xattr_handler *handler,
6263+ struct dentry *dentry, const char *key,
6264+ void *buf, size_t buflen)
62636265 {
62646266 if (strcmp(key, "") != 0)
62656267 return -EINVAL;
@@ -6267,9 +6269,10 @@ static int nfs4_xattr_get_nfs4_acl(struct dentry *dentry, const char *key, · 1 unmodified line
62676269 return nfs4_proc_get_acl(d_inode(dentry), buf, buflen);
62686270 }
62696271
6270−static size_t nfs4_xattr_list_nfs4_acl(struct dentry *dentry, char *list,
6272+static size_t nfs4_xattr_list_nfs4_acl(const struct xattr_handler *handler,
6273+ struct dentry *dentry, char *list,
62716274 size_t list_len, const char *name,
6272− size_t name_len, int type)
6275+ size_t name_len)
62736276 {
62746277 size_t len = sizeof(XATTR_NAME_NFSV4_ACL);
62756278
@@ -6287,9 +6290,10 @@ static inline int nfs4_server_supports_labels(struct nfs_server *server) · 11 unmodified lines
62876290 return server->caps & NFS_CAP_SECURITY_LABEL;
62886291 }
62896292
6290−static int nfs4_xattr_set_nfs4_label(struct dentry *dentry, const char *key,
6291− const void *buf, size_t buflen,
6292− int flags, int type)
6293+static int nfs4_xattr_set_nfs4_label(const struct xattr_handler *handler,
6294+ struct dentry *dentry, const char *key,
6295+ const void *buf, size_t buflen,
6296+ int flags)
62936297 {
62946298 if (security_ismaclabel(key))
62956299 return nfs4_set_security_label(dentry, buf, buflen);
@@ -6297,17 +6301,19 @@ static int nfs4_xattr_set_nfs4_label(struct dentry *dentry, const char *key, · 1 unmodified line
62976301 return -EOPNOTSUPP;
62986302 }
62996303
6300−static int nfs4_xattr_get_nfs4_label(struct dentry *dentry, const char *key,
6301− void *buf, size_t buflen, int type)
6304+static int nfs4_xattr_get_nfs4_label(const struct xattr_handler *handler,
6305+ struct dentry *dentry, const char *key,
6306+ void *buf, size_t buflen)
63026307 {
63036308 if (security_ismaclabel(key))
63046309 return nfs4_get_security_label(d_inode(dentry), buf, buflen);
63056310 return -EOPNOTSUPP;
63066311 }
63076312
6308−static size_t nfs4_xattr_list_nfs4_label(struct dentry *dentry, char *list,
6309− size_t list_len, const char *name,
6310− size_t name_len, int type)
6313+static size_t nfs4_xattr_list_nfs4_label(const struct xattr_handler *handler,
6314+ struct dentry *dentry, char *list,
6315+ size_t list_len, const char *name,
6316+ size_t name_len)
63116317 {
63126318 size_t len = 0;
63136319
fs/ocfs2/xattr.c+27−18
@@ -7229,9 +7229,10 @@ leave: · 7228 unmodified lines
72297229 /*
72307230 * 'security' attributes support
72317231 */
7232−static size_t ocfs2_xattr_security_list(struct dentry *dentry, char *list,
7232+static size_t ocfs2_xattr_security_list(const struct xattr_handler *handler,
7233+ struct dentry *dentry, char *list,
72337234 size_t list_size, const char *name,
7234− size_t name_len, int type)
7235+ size_t name_len)
72357236 {
72367237 const size_t prefix_len = XATTR_SECURITY_PREFIX_LEN;
72377238 const size_t total_len = prefix_len + name_len + 1;
@@ -7244,8 +7245,9 @@ static size_t ocfs2_xattr_security_list(struct dentry *dentry, char *list, · 6 unmodified lines
72447245 return total_len;
72457246 }
72467247
7247−static int ocfs2_xattr_security_get(struct dentry *dentry, const char *name,
7248− void *buffer, size_t size, int type)
7248+static int ocfs2_xattr_security_get(const struct xattr_handler *handler,
7249+ struct dentry *dentry, const char *name,
7250+ void *buffer, size_t size)
72497251 {
72507252 if (strcmp(name, "") == 0)
72517253 return -EINVAL;
@@ -7253,8 +7255,9 @@ static int ocfs2_xattr_security_get(struct dentry *dentry, const char *name, · 1 unmodified line
72537255 name, buffer, size);
72547256 }
72557257
7256−static int ocfs2_xattr_security_set(struct dentry *dentry, const char *name,
7257− const void *value, size_t size, int flags, int type)
7258+static int ocfs2_xattr_security_set(const struct xattr_handler *handler,
7259+ struct dentry *dentry, const char *name,
7260+ const void *value, size_t size, int flags)
72587261 {
72597262 if (strcmp(name, "") == 0)
72607263 return -EINVAL;
@@ -7319,9 +7322,10 @@ const struct xattr_handler ocfs2_xattr_security_handler = { · 58 unmodified lines
73197322 /*
73207323 * 'trusted' attributes support
73217324 */
7322−static size_t ocfs2_xattr_trusted_list(struct dentry *dentry, char *list,
7325+static size_t ocfs2_xattr_trusted_list(const struct xattr_handler *handler,
7326+ struct dentry *dentry, char *list,
73237327 size_t list_size, const char *name,
7324− size_t name_len, int type)
7328+ size_t name_len)
73257329 {
73267330 const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN;
73277331 const size_t total_len = prefix_len + name_len + 1;
@@ -7337,8 +7341,9 @@ static size_t ocfs2_xattr_trusted_list(struct dentry *dentry, char *list, · 9 unmodified lines
73377341 return total_len;
73387342 }
73397343
7340−static int ocfs2_xattr_trusted_get(struct dentry *dentry, const char *name,
7341− void *buffer, size_t size, int type)
7344+static int ocfs2_xattr_trusted_get(const struct xattr_handler *handler,
7345+ struct dentry *dentry, const char *name,
7346+ void *buffer, size_t size)
73427347 {
73437348 if (strcmp(name, "") == 0)
73447349 return -EINVAL;
@@ -7346,8 +7351,9 @@ static int ocfs2_xattr_trusted_get(struct dentry *dentry, const char *name, · 1 unmodified line
73467351 name, buffer, size);
73477352 }
73487353
7349−static int ocfs2_xattr_trusted_set(struct dentry *dentry, const char *name,
7350− const void *value, size_t size, int flags, int type)
7354+static int ocfs2_xattr_trusted_set(const struct xattr_handler *handler,
7355+ struct dentry *dentry, const char *name,
7356+ const void *value, size_t size, int flags)
73517357 {
73527358 if (strcmp(name, "") == 0)
73537359 return -EINVAL;
@@ -7366,9 +7372,10 @@ const struct xattr_handler ocfs2_xattr_trusted_handler = { · 12 unmodified lines
73667372 /*
73677373 * 'user' attributes support
73687374 */
7369−static size_t ocfs2_xattr_user_list(struct dentry *dentry, char *list,
7375+static size_t ocfs2_xattr_user_list(const struct xattr_handler *handler,
7376+ struct dentry *dentry, char *list,
73707377 size_t list_size, const char *name,
7371− size_t name_len, int type)
7378+ size_t name_len)
73727379 {
73737380 const size_t prefix_len = XATTR_USER_PREFIX_LEN;
73747381 const size_t total_len = prefix_len + name_len + 1;
@@ -7385,8 +7392,9 @@ static size_t ocfs2_xattr_user_list(struct dentry *dentry, char *list, · 10 unmodified lines
73857392 return total_len;
73867393 }
73877394
7388−static int ocfs2_xattr_user_get(struct dentry *dentry, const char *name,
7389− void *buffer, size_t size, int type)
7395+static int ocfs2_xattr_user_get(const struct xattr_handler *handler,
7396+ struct dentry *dentry, const char *name,
7397+ void *buffer, size_t size)
73907398 {
73917399 struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
73927400
@@ -7398,8 +7406,9 @@ static int ocfs2_xattr_user_get(struct dentry *dentry, const char *name, · 5 unmodified lines
73987406 buffer, size);
73997407 }
74007408
7401−static int ocfs2_xattr_user_set(struct dentry *dentry, const char *name,
7402− const void *value, size_t size, int flags, int type)
7409+static int ocfs2_xattr_user_set(const struct xattr_handler *handler,
7410+ struct dentry *dentry, const char *name,
7411+ const void *value, size_t size, int flags)
74037412 {
74047413 struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
74057414
fs/posix_acl.c+18−18
@@ -762,18 +762,21 @@ posix_acl_to_xattr(struct user_namespace *user_ns, const struct posix_acl *acl, · 761 unmodified lines
762762 EXPORT_SYMBOL (posix_acl_to_xattr);
763763
764764 static int
765−posix_acl_xattr_get(struct dentry *dentry, const char *name,
766− void *value, size_t size, int type)
765+posix_acl_xattr_get(const struct xattr_handler *handler,
766+ struct dentry *dentry, const char *name,
767+ void *value, size_t size)
767768 {
768769 struct posix_acl *acl;
769770 int error;
770771
772+ if (strcmp(name, "") != 0)
773+ return -EINVAL;
771774 if (!IS_POSIXACL(d_backing_inode(dentry)))
772775 return -EOPNOTSUPP;
773776 if (d_is_symlink(dentry))
774777 return -EOPNOTSUPP;
775778
776− acl = get_acl(d_backing_inode(dentry), type);
779+ acl = get_acl(d_backing_inode(dentry), handler->flags);
777780 if (IS_ERR(acl))
778781 return PTR_ERR(acl);
779782 if (acl == NULL)
@@ -786,19 +789,22 @@ posix_acl_xattr_get(struct dentry *dentry, const char *name, · 6 unmodified lines
786789 }
787790
788791 static int
789−posix_acl_xattr_set(struct dentry *dentry, const char *name,
790− const void *value, size_t size, int flags, int type)
792+posix_acl_xattr_set(const struct xattr_handler *handler,
793+ struct dentry *dentry, const char *name,
794+ const void *value, size_t size, int flags)
791795 {
792796 struct inode *inode = d_backing_inode(dentry);
793797 struct posix_acl *acl = NULL;
794798 int ret;
795799
800+ if (strcmp(name, "") != 0)
801+ return -EINVAL;
796802 if (!IS_POSIXACL(inode))
797803 return -EOPNOTSUPP;
798804 if (!inode->i_op->set_acl)
799805 return -EOPNOTSUPP;
800806
801− if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
807+ if (handler->flags == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
802808 return value ? -EACCES : 0;
803809 if (!inode_owner_or_capable(inode))
804810 return -EPERM;
@@ -815,28 +821,22 @@ posix_acl_xattr_set(struct dentry *dentry, const char *name, · 10 unmodified lines
815821 }
816822 }
817823
818− ret = inode->i_op->set_acl(inode, acl, type);
824+ ret = inode->i_op->set_acl(inode, acl, handler->flags);
819825 out:
820826 posix_acl_release(acl);
821827 return ret;
822828 }
823829
824830 static size_t
825−posix_acl_xattr_list(struct dentry *dentry, char *list, size_t list_size,
826− const char *name, size_t name_len, int type)
831+posix_acl_xattr_list(const struct xattr_handler *handler,
832+ struct dentry *dentry, char *list, size_t list_size,
833+ const char *name, size_t name_len)
827834 {
828− const char *xname;
835+ const char *xname = handler->prefix;
829836 size_t size;
830837
831838 if (!IS_POSIXACL(d_backing_inode(dentry)))
832− return -EOPNOTSUPP;
833− if (d_is_symlink(dentry))
834− return -EOPNOTSUPP;
835−
836− if (type == ACL_TYPE_ACCESS)
837− xname = POSIX_ACL_XATTR_ACCESS;
838− else
839− xname = POSIX_ACL_XATTR_DEFAULT;
839+ return 0;
840840
841841 size = strlen(xname) + 1;
842842 if (list && size <= list_size)
fs/reiserfs/xattr.c+8−8
@@ -778,7 +778,7 @@ reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer, · 777 unmodified lines
778778 if (!handler || get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1)
779779 return -EOPNOTSUPP;
780780
781− return handler->get(dentry, name, buffer, size, handler->flags);
781+ return handler->get(handler, dentry, name, buffer, size);
782782 }
783783
784784 /*
@@ -797,7 +797,7 @@ reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value, · 12 unmodified lines
797797 if (!handler || get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1)
798798 return -EOPNOTSUPP;
799799
800− return handler->set(dentry, name, value, size, flags, handler->flags);
800+ return handler->set(handler, dentry, name, value, size, flags);
801801 }
802802
803803 /*
@@ -814,7 +814,7 @@ int reiserfs_removexattr(struct dentry *dentry, const char *name) · 10 unmodified lines
814814 if (!handler || get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1)
815815 return -EOPNOTSUPP;
816816
817− return handler->set(dentry, name, NULL, 0, XATTR_REPLACE, handler->flags);
817+ return handler->set(handler, dentry, name, NULL, 0, XATTR_REPLACE);
818818 }
819819
820820 struct listxattr_buf {
@@ -842,14 +842,14 @@ static int listxattr_filler(struct dir_context *ctx, const char *name, · 21 unmodified lines
842842 if (!handler) /* Unsupported xattr name */
843843 return 0;
844844 if (b->buf) {
845− size = handler->list(b->dentry, b->buf + b->pos,
846− b->size, name, namelen,
847− handler->flags);
845+ size = handler->list(handler, b->dentry,
846+ b->buf + b->pos, b->size, name,
847+ namelen);
848848 if (size > b->size)
849849 return -ERANGE;
850850 } else {
851− size = handler->list(b->dentry, NULL, 0, name,
852− namelen, handler->flags);
851+ size = handler->list(handler, b->dentry,
852+ NULL, 0, name, namelen);
853853 }
854854
855855 b->pos += size;
fs/reiserfs/xattr_security.c+7−6
@@ -9,8 +9,8 @@ · 8 unmodified lines
99 #include <linux/uaccess.h>
1010
1111 static int
12−security_get(struct dentry *dentry, const char *name, void *buffer, size_t size,
13− int handler_flags)
12+security_get(const struct xattr_handler *handler, struct dentry *dentry,
13+ const char *name, void *buffer, size_t size)
1414 {
1515 if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
1616 return -EINVAL;
@@ -22,8 +22,8 @@ security_get(struct dentry *dentry, const char *name, void *buffer, size_t size, · 5 unmodified lines
2222 }
2323
2424 static int
25−security_set(struct dentry *dentry, const char *name, const void *buffer,
26− size_t size, int flags, int handler_flags)
25+security_set(const struct xattr_handler *handler, struct dentry *dentry,
26+ const char *name, const void *buffer, size_t size, int flags)
2727 {
2828 if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
2929 return -EINVAL;
@@ -34,8 +34,9 @@ security_set(struct dentry *dentry, const char *name, const void *buffer, · 4 unmodified lines
3434 return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags);
3535 }
3636
37−static size_t security_list(struct dentry *dentry, char *list, size_t list_len,
38− const char *name, size_t namelen, int handler_flags)
37+static size_t security_list(const struct xattr_handler *handler,
38+ struct dentry *dentry, char *list, size_t list_len,
39+ const char *name, size_t namelen)
3940 {
4041 const size_t len = namelen + 1;
4142
fs/reiserfs/xattr_trusted.c+7−6
@@ -8,8 +8,8 @@ · 7 unmodified lines
88 #include <linux/uaccess.h>
99
1010 static int
11−trusted_get(struct dentry *dentry, const char *name, void *buffer, size_t size,
12− int handler_flags)
11+trusted_get(const struct xattr_handler *handler, struct dentry *dentry,
12+ const char *name, void *buffer, size_t size)
1313 {
1414 if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
1515 return -EINVAL;
@@ -21,8 +21,8 @@ trusted_get(struct dentry *dentry, const char *name, void *buffer, size_t size, · 5 unmodified lines
2121 }
2222
2323 static int
24−trusted_set(struct dentry *dentry, const char *name, const void *buffer,
25− size_t size, int flags, int handler_flags)
24+trusted_set(const struct xattr_handler *handler, struct dentry *dentry,
25+ const char *name, const void *buffer, size_t size, int flags)
2626 {
2727 if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
2828 return -EINVAL;
@@ -33,8 +33,9 @@ trusted_set(struct dentry *dentry, const char *name, const void *buffer, · 4 unmodified lines
3333 return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags);
3434 }
3535
36−static size_t trusted_list(struct dentry *dentry, char *list, size_t list_size,
37− const char *name, size_t name_len, int handler_flags)
36+static size_t trusted_list(const struct xattr_handler *handler,
37+ struct dentry *dentry, char *list, size_t list_size,
38+ const char *name, size_t name_len)
3839 {
3940 const size_t len = name_len + 1;
4041
fs/reiserfs/xattr_user.c+7−6
@@ -7,8 +7,8 @@ · 6 unmodified lines
77 #include <linux/uaccess.h>
88
99 static int
10−user_get(struct dentry *dentry, const char *name, void *buffer, size_t size,
11− int handler_flags)
10+user_get(const struct xattr_handler *handler, struct dentry *dentry,
11+ const char *name, void *buffer, size_t size)
1212 {
1313
1414 if (strlen(name) < sizeof(XATTR_USER_PREFIX))
@@ -19,8 +19,8 @@ user_get(struct dentry *dentry, const char *name, void *buffer, size_t size, · 4 unmodified lines
1919 }
2020
2121 static int
22−user_set(struct dentry *dentry, const char *name, const void *buffer,
23− size_t size, int flags, int handler_flags)
22+user_set(const struct xattr_handler *handler, struct dentry *dentry,
23+ const char *name, const void *buffer, size_t size, int flags)
2424 {
2525 if (strlen(name) < sizeof(XATTR_USER_PREFIX))
2626 return -EINVAL;
@@ -30,8 +30,9 @@ user_set(struct dentry *dentry, const char *name, const void *buffer, · 3 unmodified lines
3030 return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags);
3131 }
3232
33−static size_t user_list(struct dentry *dentry, char *list, size_t list_size,
34− const char *name, size_t name_len, int handler_flags)
33+static size_t user_list(const struct xattr_handler *handler,
34+ struct dentry *dentry, char *list, size_t list_size,
35+ const char *name, size_t name_len)
3536 {
3637 const size_t len = name_len + 1;
3738
fs/squashfs/xattr.c+33−53
@@ -68,8 +68,8 @@ ssize_t squashfs_listxattr(struct dentry *d, char *buffer, · 67 unmodified lines
6868 name_size = le16_to_cpu(entry.size);
6969 handler = squashfs_xattr_handler(le16_to_cpu(entry.type));
7070 if (handler)
71− prefix_size = handler->list(d, buffer, rest, NULL,
72− name_size, handler->flags);
71+ prefix_size = handler->list(handler, d, buffer, rest,
72+ NULL, name_size);
7373 if (prefix_size) {
7474 if (buffer) {
7575 if (prefix_size + name_size + 1 > rest) {
@@ -212,88 +212,68 @@ failed: · 136 unmodified lines
212212 }
213213
214214
215−/*
216− * User namespace support
217− */
218−static size_t squashfs_user_list(struct dentry *d, char *list, size_t list_size,
219− const char *name, size_t name_len, int type)
215+static size_t squashfs_xattr_handler_list(const struct xattr_handler *handler,
216+ struct dentry *d, char *list,
217+ size_t list_size, const char *name,
218+ size_t name_len)
220219 {
221− if (list && XATTR_USER_PREFIX_LEN <= list_size)
222− memcpy(list, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN);
223− return XATTR_USER_PREFIX_LEN;
220+ int len = strlen(handler->prefix);
221+
222+ if (list && len <= list_size)
223+ memcpy(list, handler->prefix, len);
224+ return len;
224225 }
225226
226−static int squashfs_user_get(struct dentry *d, const char *name, void *buffer,
227− size_t size, int type)
227+static int squashfs_xattr_handler_get(const struct xattr_handler *handler,
228+ struct dentry *d, const char *name,
229+ void *buffer, size_t size)
228230 {
229231 if (name[0] == '\0')
230232 return -EINVAL;
231233
232− return squashfs_xattr_get(d_inode(d), SQUASHFS_XATTR_USER, name,
234+ return squashfs_xattr_get(d_inode(d), handler->flags, name,
233235 buffer, size);
234236 }
235237
238+/*
239+ * User namespace support
240+ */
236241 static const struct xattr_handler squashfs_xattr_user_handler = {
237242 .prefix = XATTR_USER_PREFIX,
238− .list = squashfs_user_list,
239− .get = squashfs_user_get
243+ .flags = SQUASHFS_XATTR_USER,
244+ .list = squashfs_xattr_handler_list,
245+ .get = squashfs_xattr_handler_get
240246 };
241247
242248 /*
243249 * Trusted namespace support
244250 */
245−static size_t squashfs_trusted_list(struct dentry *d, char *list,
246− size_t list_size, const char *name, size_t name_len, int type)
251+static size_t squashfs_trusted_xattr_handler_list(const struct xattr_handler *handler,
252+ struct dentry *d, char *list,
253+ size_t list_size, const char *name,
254+ size_t name_len)
247255 {
248256 if (!capable(CAP_SYS_ADMIN))
249257 return 0;
250−
251− if (list && XATTR_TRUSTED_PREFIX_LEN <= list_size)
252− memcpy(list, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN);
253− return XATTR_TRUSTED_PREFIX_LEN;
254−}
255−
256−static int squashfs_trusted_get(struct dentry *d, const char *name,
257− void *buffer, size_t size, int type)
258−{
259− if (name[0] == '\0')
260− return -EINVAL;
261−
262− return squashfs_xattr_get(d_inode(d), SQUASHFS_XATTR_TRUSTED, name,
263− buffer, size);
258+ return squashfs_xattr_handler_list(handler, d, list, list_size, name,
259+ name_len);
264260 }
265261
266262 static const struct xattr_handler squashfs_xattr_trusted_handler = {
267263 .prefix = XATTR_TRUSTED_PREFIX,
268− .list = squashfs_trusted_list,
269− .get = squashfs_trusted_get
264+ .flags = SQUASHFS_XATTR_TRUSTED,
265+ .list = squashfs_trusted_xattr_handler_list,
266+ .get = squashfs_xattr_handler_get
270267 };
271268
272269 /*
273270 * Security namespace support
274271 */
275−static size_t squashfs_security_list(struct dentry *d, char *list,
276− size_t list_size, const char *name, size_t name_len, int type)
277−{
278− if (list && XATTR_SECURITY_PREFIX_LEN <= list_size)
279− memcpy(list, XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN);
280− return XATTR_SECURITY_PREFIX_LEN;
281−}
282−
283−static int squashfs_security_get(struct dentry *d, const char *name,
284− void *buffer, size_t size, int type)
285−{
286− if (name[0] == '\0')
287− return -EINVAL;
288−
289− return squashfs_xattr_get(d_inode(d), SQUASHFS_XATTR_SECURITY, name,
290− buffer, size);
291−}
292−
293272 static const struct xattr_handler squashfs_xattr_security_handler = {
294273 .prefix = XATTR_SECURITY_PREFIX,
295− .list = squashfs_security_list,
296− .get = squashfs_security_get
274+ .flags = SQUASHFS_XATTR_SECURITY,
275+ .list = squashfs_xattr_handler_list,
276+ .get = squashfs_xattr_handler_get
297277 };
298278
299279 static const struct xattr_handler *squashfs_xattr_handler(int type)
fs/ubifs/super.c+0−1
@@ -2040,7 +2040,6 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent) · 2039 unmodified lines
20402040 if (c->max_inode_sz > MAX_LFS_FILESIZE)
20412041 sb->s_maxbytes = c->max_inode_sz = MAX_LFS_FILESIZE;
20422042 sb->s_op = &ubifs_super_operations;
2043− sb->s_xattr = ubifs_xattr_handlers;
20442043
20452044 mutex_lock(&c->umount_mutex);
20462045 err = mount_ubifs(c);
fs/ubifs/ubifs.h+0−1
@@ -1470,7 +1470,6 @@ extern spinlock_t ubifs_infos_lock; · 1469 unmodified lines
14701470 extern atomic_long_t ubifs_clean_zn_cnt;
14711471 extern struct kmem_cache *ubifs_inode_slab;
14721472 extern const struct super_operations ubifs_super_operations;
1473−extern const struct xattr_handler *ubifs_xattr_handlers[];
14741473 extern const struct address_space_operations ubifs_file_address_operations;
14751474 extern const struct file_operations ubifs_file_operations;
14761475 extern const struct inode_operations ubifs_file_inode_operations;
fs/ubifs/xattr.c+0−40
@@ -588,46 +588,6 @@ out_free: · 587 unmodified lines
588588 return err;
589589 }
590590
591−static size_t security_listxattr(struct dentry *d, char *list, size_t list_size,
592− const char *name, size_t name_len, int flags)
593−{
594− const int prefix_len = XATTR_SECURITY_PREFIX_LEN;
595− const size_t total_len = prefix_len + name_len + 1;
596−
597− if (list && total_len <= list_size) {
598− memcpy(list, XATTR_SECURITY_PREFIX, prefix_len);
599− memcpy(list + prefix_len, name, name_len);
600− list[prefix_len + name_len] = '\0';
601− }
602−
603− return total_len;
604−}
605−
606−static int security_getxattr(struct dentry *d, const char *name, void *buffer,
607− size_t size, int flags)
608−{
609− return ubifs_getxattr(d, name, buffer, size);
610−}
611−
612−static int security_setxattr(struct dentry *d, const char *name,
613− const void *value, size_t size, int flags,
614− int handler_flags)
615−{
616− return ubifs_setxattr(d, name, value, size, flags);
617−}
618−
619−static const struct xattr_handler ubifs_xattr_security_handler = {
620− .prefix = XATTR_SECURITY_PREFIX,
621− .list = security_listxattr,
622− .get = security_getxattr,
623− .set = security_setxattr,
624−};
625−
626−const struct xattr_handler *ubifs_xattr_handlers[] = {
627− &ubifs_xattr_security_handler,
628− NULL,
629−};
630−
631591 static int init_xattrs(struct inode *inode, const struct xattr *xattr_array,
632592 void *fs_info)
633593 {
fs/xattr.c+31−8
@@ -720,7 +720,7 @@ generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t s · 719 unmodified lines
720720 handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
721721 if (!handler)
722722 return -EOPNOTSUPP;
723− return handler->get(dentry, name, buffer, size, handler->flags);
723+ return handler->get(handler, dentry, name, buffer, size);
724724 }
725725
726726 /*
@@ -735,15 +735,15 @@ generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) · 8 unmodified lines
735735
736736 if (!buffer) {
737737 for_each_xattr_handler(handlers, handler) {
738− size += handler->list(dentry, NULL, 0, NULL, 0,
739− handler->flags);
738+ size += handler->list(handler, dentry, NULL, 0,
739+ NULL, 0);
740740 }
741741 } else {
742742 char *buf = buffer;
743743
744744 for_each_xattr_handler(handlers, handler) {
745− size = handler->list(dentry, buf, buffer_size,
746− NULL, 0, handler->flags);
745+ size = handler->list(handler, dentry, buf, buffer_size,
746+ NULL, 0);
747747 if (size > buffer_size)
748748 return -ERANGE;
749749 buf += size;
@@ -767,7 +767,7 @@ generic_setxattr(struct dentry *dentry, const char *name, const void *value, siz · 17 unmodified lines
767767 handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
768768 if (!handler)
769769 return -EOPNOTSUPP;
770− return handler->set(dentry, name, value, size, flags, handler->flags);
770+ return handler->set(handler, dentry, name, value, size, flags);
771771 }
772772
773773 /*
@@ -782,8 +782,7 @@ generic_removexattr(struct dentry *dentry, const char *name) · 8 unmodified lines
782782 handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
783783 if (!handler)
784784 return -EOPNOTSUPP;
785− return handler->set(dentry, name, NULL, 0,
786− XATTR_REPLACE, handler->flags);
785+ return handler->set(handler, dentry, name, NULL, 0, XATTR_REPLACE);
787786 }
788787
789788 EXPORT_SYMBOL(generic_getxattr);
@@ -791,6 +790,30 @@ EXPORT_SYMBOL(generic_listxattr); · 1 unmodified line
791790 EXPORT_SYMBOL(generic_setxattr);
792791 EXPORT_SYMBOL(generic_removexattr);
793792
793+/**
794+ * xattr_full_name - Compute full attribute name from suffix
795+ *
796+ * @handler: handler of the xattr_handler operation
797+ * @name: name passed to the xattr_handler operation
798+ *
799+ * The get and set xattr handler operations are called with the remainder of
800+ * the attribute name after skipping the handler's prefix: for example, "foo"
801+ * is passed to the get operation of a handler with prefix "user." to get
802+ * attribute "user.foo". The full name is still "there" in the name though.
803+ *
804+ * Note: the list xattr handler operation when called from the vfs is passed a
805+ * NULL name; some file systems use this operation internally, with varying
806+ * semantics.
807+ */
808+const char *xattr_full_name(const struct xattr_handler *handler,
809+ const char *name)
810+{
811+ size_t prefix_len = strlen(handler->prefix);
812+
813+ return name - prefix_len;
814+}
815+EXPORT_SYMBOL(xattr_full_name);
816+
794817 /*
795818 * Allocate new xattr and copy in the value; but leave the name to callers.
796819 */
fs/xfs/xfs_xattr.c+6−4
@@ -32,9 +32,10 @@ · 31 unmodified lines
3232
3333
3434 static int
35−xfs_xattr_get(struct dentry *dentry, const char *name,
36− void *value, size_t size, int xflags)
35+xfs_xattr_get(const struct xattr_handler *handler, struct dentry *dentry,
36+ const char *name, void *value, size_t size)
3737 {
38+ int xflags = handler->flags;
3839 struct xfs_inode *ip = XFS_I(d_inode(dentry));
3940 int error, asize = size;
4041
@@ -76,9 +77,10 @@ xfs_forget_acl( · 35 unmodified lines
7677 }
7778
7879 static int
79−xfs_xattr_set(struct dentry *dentry, const char *name, const void *value,
80− size_t size, int flags, int xflags)
80+xfs_xattr_set(const struct xattr_handler *handler, struct dentry *dentry,
81+ const char *name, const void *value, size_t size, int flags)
8182 {
83+ int xflags = handler->flags;
8284 struct xfs_inode *ip = XFS_I(d_inode(dentry));
8385 int error;
8486
include/linux/xattr.h+11−7
@@ -21,15 +21,19 @@ struct dentry; · 20 unmodified lines
2121
2222 struct xattr_handler {
2323 const char *prefix;
24− int flags; /* fs private flags passed back to the handlers */
25− size_t (*list)(struct dentry *dentry, char *list, size_t list_size,
26− const char *name, size_t name_len, int handler_flags);
27− int (*get)(struct dentry *dentry, const char *name, void *buffer,
28− size_t size, int handler_flags);
29− int (*set)(struct dentry *dentry, const char *name, const void *buffer,
30− size_t size, int flags, int handler_flags);
24+ int flags; /* fs private flags */
25+ size_t (*list)(const struct xattr_handler *, struct dentry *dentry,
26+ char *list, size_t list_size, const char *name,
27+ size_t name_len);
28+ int (*get)(const struct xattr_handler *, struct dentry *dentry,
29+ const char *name, void *buffer, size_t size);
30+ int (*set)(const struct xattr_handler *, struct dentry *dentry,
31+ const char *name, const void *buffer, size_t size,
32+ int flags);
3133 };
3234
35+const char *xattr_full_name(const struct xattr_handler *, const char *);
36+
3337 struct xattr {
3438 const char *name;
3539 void *value;