xattr_trusted.c (bf61c8840efe60fd8f91446860b63338fb424158) xattr_trusted.c (bf29e886b242cebf6a96ca0e43873abc777e0b50)
1/*
2 * linux/fs/hfsplus/xattr_trusted.c
3 *
4 * Vyacheslav Dubeyko <slava@dubeyko.com>
5 *
6 * Handler for trusted extended attributes.
7 */
8
1/*
2 * linux/fs/hfsplus/xattr_trusted.c
3 *
4 * Vyacheslav Dubeyko <slava@dubeyko.com>
5 *
6 * Handler for trusted extended attributes.
7 */
8
9#include <linux/nls.h>
10
9#include "hfsplus_fs.h"
10#include "xattr.h"
11
12static int hfsplus_trusted_getxattr(struct dentry *dentry, const char *name,
13 void *buffer, size_t size, int type)
14{
11#include "hfsplus_fs.h"
12#include "xattr.h"
13
14static int hfsplus_trusted_getxattr(struct dentry *dentry, const char *name,
15 void *buffer, size_t size, int type)
16{
15 char xattr_name[HFSPLUS_ATTR_MAX_STRLEN + 1] = {0};
16 size_t len = strlen(name);
17 char *xattr_name;
18 int res;
17
18 if (!strcmp(name, ""))
19 return -EINVAL;
20
19
20 if (!strcmp(name, ""))
21 return -EINVAL;
22
21 if (len + XATTR_TRUSTED_PREFIX_LEN > HFSPLUS_ATTR_MAX_STRLEN)
22 return -EOPNOTSUPP;
23
23 xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN + 1,
24 GFP_KERNEL);
25 if (!xattr_name)
26 return -ENOMEM;
24 strcpy(xattr_name, XATTR_TRUSTED_PREFIX);
25 strcpy(xattr_name + XATTR_TRUSTED_PREFIX_LEN, name);
26
27 strcpy(xattr_name, XATTR_TRUSTED_PREFIX);
28 strcpy(xattr_name + XATTR_TRUSTED_PREFIX_LEN, name);
29
27 return hfsplus_getxattr(dentry, xattr_name, buffer, size);
30 res = hfsplus_getxattr(dentry, xattr_name, buffer, size);
31 kfree(xattr_name);
32 return res;
28}
29
30static int hfsplus_trusted_setxattr(struct dentry *dentry, const char *name,
31 const void *buffer, size_t size, int flags, int type)
32{
33}
34
35static int hfsplus_trusted_setxattr(struct dentry *dentry, const char *name,
36 const void *buffer, size_t size, int flags, int type)
37{
33 char xattr_name[HFSPLUS_ATTR_MAX_STRLEN + 1] = {0};
34 size_t len = strlen(name);
38 char *xattr_name;
39 int res;
35
36 if (!strcmp(name, ""))
37 return -EINVAL;
38
40
41 if (!strcmp(name, ""))
42 return -EINVAL;
43
39 if (len + XATTR_TRUSTED_PREFIX_LEN > HFSPLUS_ATTR_MAX_STRLEN)
40 return -EOPNOTSUPP;
41
44 xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN + 1,
45 GFP_KERNEL);
46 if (!xattr_name)
47 return -ENOMEM;
42 strcpy(xattr_name, XATTR_TRUSTED_PREFIX);
43 strcpy(xattr_name + XATTR_TRUSTED_PREFIX_LEN, name);
44
48 strcpy(xattr_name, XATTR_TRUSTED_PREFIX);
49 strcpy(xattr_name + XATTR_TRUSTED_PREFIX_LEN, name);
50
45 return hfsplus_setxattr(dentry, xattr_name, buffer, size, flags);
51 res = hfsplus_setxattr(dentry, xattr_name, buffer, size, flags);
52 kfree(xattr_name);
53 return res;
46}
47
48static size_t hfsplus_trusted_listxattr(struct dentry *dentry, char *list,
49 size_t list_size, const char *name, size_t name_len, int type)
50{
51 /*
52 * This method is not used.
53 * It is used hfsplus_listxattr() instead of generic_listxattr().
54 */
55 return -EOPNOTSUPP;
56}
57
58const struct xattr_handler hfsplus_xattr_trusted_handler = {
59 .prefix = XATTR_TRUSTED_PREFIX,
60 .list = hfsplus_trusted_listxattr,
61 .get = hfsplus_trusted_getxattr,
62 .set = hfsplus_trusted_setxattr,
63};
54}
55
56static size_t hfsplus_trusted_listxattr(struct dentry *dentry, char *list,
57 size_t list_size, const char *name, size_t name_len, int type)
58{
59 /*
60 * This method is not used.
61 * It is used hfsplus_listxattr() instead of generic_listxattr().
62 */
63 return -EOPNOTSUPP;
64}
65
66const struct xattr_handler hfsplus_xattr_trusted_handler = {
67 .prefix = XATTR_TRUSTED_PREFIX,
68 .list = hfsplus_trusted_listxattr,
69 .get = hfsplus_trusted_getxattr,
70 .set = hfsplus_trusted_setxattr,
71};