2 * Copyright IBM Corporation, 2010
3 * Author Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
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.
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.
16 #include <linux/module.h>
17 #include <linux/string.h>
19 #include <linux/slab.h>
22 static int v9fs_xattr_trusted_get(const struct xattr_handler *handler,
23 struct dentry *dentry, const char *name,
24 void *buffer, size_t size)
29 size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN;
34 if (strcmp(name, "") == 0)
37 name_len = strlen(name);
38 full_name = kmalloc(prefix_len + name_len + 1 , GFP_KERNEL);
41 memcpy(full_name, XATTR_TRUSTED_PREFIX, prefix_len);
42 memcpy(full_name+prefix_len, name, name_len);
43 full_name[prefix_len + name_len] = '\0';
45 retval = v9fs_xattr_get(dentry, full_name, buffer, size);
50 static int v9fs_xattr_trusted_set(const struct xattr_handler *handler,
51 struct dentry *dentry, const char *name,
52 const void *value, size_t size, int flags)
57 size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN;
62 if (strcmp(name, "") == 0)
65 name_len = strlen(name);
66 full_name = kmalloc(prefix_len + name_len + 1 , GFP_KERNEL);
69 memcpy(full_name, XATTR_TRUSTED_PREFIX, prefix_len);
70 memcpy(full_name + prefix_len, name, name_len);
71 full_name[prefix_len + name_len] = '\0';
73 retval = v9fs_xattr_set(dentry, full_name, value, size, flags);
78 struct xattr_handler v9fs_xattr_trusted_handler = {
79 .prefix = XATTR_TRUSTED_PREFIX,
80 .get = v9fs_xattr_trusted_get,
81 .set = v9fs_xattr_trusted_set,