NFSv4: Fix a compile warning about no prototype for nfs4_ioctl()
[deliverable/linux.git] / fs / ext2 / xattr_trusted.c
CommitLineData
1da177e4
LT
1/*
2 * linux/fs/ext2/xattr_trusted.c
3 * Handler for trusted extended attributes.
4 *
5 * Copyright (C) 2003 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
6 */
7
f7699f2b 8#include "ext2.h"
1da177e4
LT
9#include "xattr.h"
10
1da177e4 11static size_t
d9a82a04
AG
12ext2_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)
1da177e4 15{
f905f06f 16 const int prefix_len = XATTR_TRUSTED_PREFIX_LEN;
1da177e4
LT
17 const size_t total_len = prefix_len + name_len + 1;
18
19 if (!capable(CAP_SYS_ADMIN))
20 return 0;
21
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';
26 }
27 return total_len;
28}
29
30static int
d9a82a04
AG
31ext2_xattr_trusted_get(const struct xattr_handler *handler,
32 struct dentry *dentry, const char *name,
33 void *buffer, size_t size)
1da177e4
LT
34{
35 if (strcmp(name, "") == 0)
36 return -EINVAL;
2b0143b5 37 return ext2_xattr_get(d_inode(dentry), EXT2_XATTR_INDEX_TRUSTED, name,
1da177e4
LT
38 buffer, size);
39}
40
41static int
d9a82a04
AG
42ext2_xattr_trusted_set(const struct xattr_handler *handler,
43 struct dentry *dentry, const char *name,
44 const void *value, size_t size, int flags)
1da177e4
LT
45{
46 if (strcmp(name, "") == 0)
47 return -EINVAL;
2b0143b5 48 return ext2_xattr_set(d_inode(dentry), EXT2_XATTR_INDEX_TRUSTED, name,
1da177e4
LT
49 value, size, flags);
50}
51
749c72ef 52const struct xattr_handler ext2_xattr_trusted_handler = {
1da177e4
LT
53 .prefix = XATTR_TRUSTED_PREFIX,
54 .list = ext2_xattr_trusted_list,
55 .get = ext2_xattr_trusted_get,
56 .set = ext2_xattr_trusted_set,
57};
This page took 0.814663 seconds and 5 git commands to generate.