[PATCH] DVB: Documentation and Kconfig updazes
[linux-2.6/history.git] / fs / ext3 / xattr_security.c
blobc948effaa25741fa103fbf7cb83268fbeecb201e
1 /*
2 * linux/fs/ext3/xattr_security.c
3 * Handler for storing security labels as extended attributes.
4 */
6 #include <linux/module.h>
7 #include <linux/string.h>
8 #include <linux/fs.h>
9 #include <linux/smp_lock.h>
10 #include <linux/ext3_jbd.h>
11 #include <linux/ext3_fs.h>
12 #include "xattr.h"
14 static size_t
15 ext3_xattr_security_list(char *list, struct inode *inode,
16 const char *name, int name_len)
18 const int prefix_len = sizeof(XATTR_SECURITY_PREFIX)-1;
20 if (list) {
21 memcpy(list, XATTR_SECURITY_PREFIX, prefix_len);
22 memcpy(list+prefix_len, name, name_len);
23 list[prefix_len + name_len] = '\0';
25 return prefix_len + name_len + 1;
28 static int
29 ext3_xattr_security_get(struct inode *inode, const char *name,
30 void *buffer, size_t size)
32 if (strcmp(name, "") == 0)
33 return -EINVAL;
34 return ext3_xattr_get(inode, EXT3_XATTR_INDEX_SECURITY, name,
35 buffer, size);
38 static int
39 ext3_xattr_security_set(struct inode *inode, const char *name,
40 const void *value, size_t size, int flags)
42 if (strcmp(name, "") == 0)
43 return -EINVAL;
44 return ext3_xattr_set(inode, EXT3_XATTR_INDEX_SECURITY, name,
45 value, size, flags);
48 struct ext3_xattr_handler ext3_xattr_security_handler = {
49 .prefix = XATTR_SECURITY_PREFIX,
50 .list = ext3_xattr_security_list,
51 .get = ext3_xattr_security_get,
52 .set = ext3_xattr_security_set,