2 * linux/fs/ext2/xattr_trusted.c
3 * Handler for trusted extended attributes.
5 * Copyright (C) 2003 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
8 #include <linux/module.h>
9 #include <linux/string.h>
11 #include <linux/smp_lock.h>
12 #include <linux/ext2_fs.h>
15 #define XATTR_TRUSTED_PREFIX "trusted."
18 ext2_xattr_trusted_list(char *list, struct inode *inode,
19 const char *name, int name_len)
21 const int prefix_len = sizeof(XATTR_TRUSTED_PREFIX)-1;
23 if (!capable(CAP_SYS_ADMIN))
27 memcpy(list, XATTR_TRUSTED_PREFIX, prefix_len);
28 memcpy(list+prefix_len, name, name_len);
29 list[prefix_len + name_len] = '\0';
31 return prefix_len + name_len + 1;
35 ext2_xattr_trusted_get(struct inode *inode, const char *name,
36 void *buffer, size_t size)
38 if (strcmp(name, "") == 0)
40 if (!capable(CAP_SYS_ADMIN))
42 return ext2_xattr_get(inode, EXT2_XATTR_INDEX_TRUSTED, name,
47 ext2_xattr_trusted_set(struct inode *inode, const char *name,
48 const void *value, size_t size, int flags)
50 if (strcmp(name, "") == 0)
52 if (!capable(CAP_SYS_ADMIN))
54 return ext2_xattr_set(inode, EXT2_XATTR_INDEX_TRUSTED, name,
58 struct ext2_xattr_handler ext2_xattr_trusted_handler = {
59 .prefix = XATTR_TRUSTED_PREFIX,
60 .list = ext2_xattr_trusted_list,
61 .get = ext2_xattr_trusted_get,
62 .set = ext2_xattr_trusted_set,