Loading...
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * linux/fs/ext2/xattr_trusted.c
4 * Handler for trusted extended attributes.
5 *
6 * Copyright (C) 2003 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
7 */
8
9#include "ext2.h"
10#include "xattr.h"
11
12static bool
13ext2_xattr_trusted_list(struct dentry *dentry)
14{
15 return capable(CAP_SYS_ADMIN);
16}
17
18static int
19ext2_xattr_trusted_get(const struct xattr_handler *handler,
20 struct dentry *unused, struct inode *inode,
21 const char *name, void *buffer, size_t size)
22{
23 return ext2_xattr_get(inode, EXT2_XATTR_INDEX_TRUSTED, name,
24 buffer, size);
25}
26
27static int
28ext2_xattr_trusted_set(const struct xattr_handler *handler,
29 struct dentry *unused, struct inode *inode,
30 const char *name, const void *value,
31 size_t size, int flags)
32{
33 return ext2_xattr_set(inode, EXT2_XATTR_INDEX_TRUSTED, name,
34 value, size, flags);
35}
36
37const struct xattr_handler ext2_xattr_trusted_handler = {
38 .prefix = XATTR_TRUSTED_PREFIX,
39 .list = ext2_xattr_trusted_list,
40 .get = ext2_xattr_trusted_get,
41 .set = ext2_xattr_trusted_set,
42};
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
8#include "ext2.h"
9#include "xattr.h"
10
11static bool
12ext2_xattr_trusted_list(struct dentry *dentry)
13{
14 return capable(CAP_SYS_ADMIN);
15}
16
17static int
18ext2_xattr_trusted_get(const struct xattr_handler *handler,
19 struct dentry *dentry, const char *name,
20 void *buffer, size_t size)
21{
22 return ext2_xattr_get(d_inode(dentry), EXT2_XATTR_INDEX_TRUSTED, name,
23 buffer, size);
24}
25
26static int
27ext2_xattr_trusted_set(const struct xattr_handler *handler,
28 struct dentry *dentry, const char *name,
29 const void *value, size_t size, int flags)
30{
31 return ext2_xattr_set(d_inode(dentry), EXT2_XATTR_INDEX_TRUSTED, name,
32 value, size, flags);
33}
34
35const struct xattr_handler ext2_xattr_trusted_handler = {
36 .prefix = XATTR_TRUSTED_PREFIX,
37 .list = ext2_xattr_trusted_list,
38 .get = ext2_xattr_trusted_get,
39 .set = ext2_xattr_trusted_set,
40};