2 * linux/fs/ext2/xattr_trusted.c
3 * Handler for trusted extended attributes.
5 * Copyright (C) 2003 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
12 ext2_xattr_trusted_list(const struct xattr_handler
*handler
,
13 struct dentry
*dentry
, char *list
, size_t list_size
,
14 const char *name
, size_t name_len
)
16 const int prefix_len
= XATTR_TRUSTED_PREFIX_LEN
;
17 const size_t total_len
= prefix_len
+ name_len
+ 1;
19 if (!capable(CAP_SYS_ADMIN
))
22 if (list
&& total_len
<= list_size
) {
23 memcpy(list
, XATTR_TRUSTED_PREFIX
, prefix_len
);
24 memcpy(list
+prefix_len
, name
, name_len
);
25 list
[prefix_len
+ name_len
] = '\0';
31 ext2_xattr_trusted_get(const struct xattr_handler
*handler
,
32 struct dentry
*dentry
, const char *name
,
33 void *buffer
, size_t size
)
35 if (strcmp(name
, "") == 0)
37 return ext2_xattr_get(d_inode(dentry
), EXT2_XATTR_INDEX_TRUSTED
, name
,
42 ext2_xattr_trusted_set(const struct xattr_handler
*handler
,
43 struct dentry
*dentry
, const char *name
,
44 const void *value
, size_t size
, int flags
)
46 if (strcmp(name
, "") == 0)
48 return ext2_xattr_set(d_inode(dentry
), EXT2_XATTR_INDEX_TRUSTED
, name
,
52 const struct xattr_handler ext2_xattr_trusted_handler
= {
53 .prefix
= XATTR_TRUSTED_PREFIX
,
54 .list
= ext2_xattr_trusted_list
,
55 .get
= ext2_xattr_trusted_get
,
56 .set
= ext2_xattr_trusted_set
,