ASoC: hdac_hdmi: Fix to warn instead of err for no connected nids
[linux-2.6/btrfs-unstable.git] / fs / ext2 / xattr_trusted.c
blob3150dd3a78595084d0a6bfd5916f86272e68303a
1 /*
2 * linux/fs/ext2/xattr_trusted.c
3 * Handler for trusted extended attributes.
5 * Copyright (C) 2003 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
6 */
8 #include "ext2.h"
9 #include "xattr.h"
11 static size_t
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))
20 return 0;
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';
27 return total_len;
30 static int
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)
36 return -EINVAL;
37 return ext2_xattr_get(d_inode(dentry), EXT2_XATTR_INDEX_TRUSTED, name,
38 buffer, size);
41 static int
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)
47 return -EINVAL;
48 return ext2_xattr_set(d_inode(dentry), EXT2_XATTR_INDEX_TRUSTED, name,
49 value, size, flags);
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,