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_user_get(struct dentry
*dentry
, const char *name
,
23 void *buffer
, size_t size
, int type
)
28 size_t prefix_len
= XATTR_USER_PREFIX_LEN
;
33 if (strcmp(name
, "") == 0)
36 name_len
= strlen(name
);
37 full_name
= kmalloc(prefix_len
+ name_len
+ 1 , GFP_KERNEL
);
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';
44 retval
= v9fs_xattr_get(dentry
, full_name
, buffer
, size
);
49 static int v9fs_xattr_user_set(struct dentry
*dentry
, const char *name
,
50 const void *value
, size_t size
, int flags
, int type
)
55 size_t prefix_len
= XATTR_USER_PREFIX_LEN
;
60 if (strcmp(name
, "") == 0)
63 name_len
= strlen(name
);
64 full_name
= kmalloc(prefix_len
+ name_len
+ 1 , GFP_KERNEL
);
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';
71 retval
= v9fs_xattr_set(dentry
, full_name
, value
, size
, flags
);
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
,