blob: 65049b71af137d7f75f162f81ebd808b5fc3c0d0 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Al Virof7699f22012-03-23 16:45:51 -04008#include "ext2.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include "xattr.h"
10
Andreas Gruenbacher764a5c62015-12-02 14:44:43 +010011static bool
12ext2_xattr_trusted_list(struct dentry *dentry)
Linus Torvalds1da177e2005-04-16 15:20:36 -070013{
Andreas Gruenbacher764a5c62015-12-02 14:44:43 +010014 return capable(CAP_SYS_ADMIN);
Linus Torvalds1da177e2005-04-16 15:20:36 -070015}
16
17static int
Andreas Gruenbacherd9a82a02015-10-04 19:18:51 +020018ext2_xattr_trusted_get(const struct xattr_handler *handler,
Al Virob2968212016-04-10 20:48:24 -040019 struct dentry *unused, struct inode *inode,
20 const char *name, void *buffer, size_t size)
Linus Torvalds1da177e2005-04-16 15:20:36 -070021{
Al Virob2968212016-04-10 20:48:24 -040022 return ext2_xattr_get(inode, EXT2_XATTR_INDEX_TRUSTED, name,
Linus Torvalds1da177e2005-04-16 15:20:36 -070023 buffer, size);
24}
25
26static int
Andreas Gruenbacherd9a82a02015-10-04 19:18:51 +020027ext2_xattr_trusted_set(const struct xattr_handler *handler,
Al Viro59301222016-05-27 10:19:30 -040028 struct dentry *unused, struct inode *inode,
29 const char *name, const void *value,
30 size_t size, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -070031{
Al Viro59301222016-05-27 10:19:30 -040032 return ext2_xattr_set(inode, EXT2_XATTR_INDEX_TRUSTED, name,
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 value, size, flags);
34}
35
Stephen Hemminger749c72ef2010-05-13 17:53:16 -070036const struct xattr_handler ext2_xattr_trusted_handler = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 .prefix = XATTR_TRUSTED_PREFIX,
38 .list = ext2_xattr_trusted_list,
39 .get = ext2_xattr_trusted_get,
40 .set = ext2_xattr_trusted_set,
41};