blob: 0f85705ff519860b86e278a57152a9708d8d1d17 [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,
28 struct dentry *dentry, const char *name,
29 const void *value, size_t size, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -070030{
David Howells2b0143b2015-03-17 22:25:59 +000031 return ext2_xattr_set(d_inode(dentry), EXT2_XATTR_INDEX_TRUSTED, name,
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 value, size, flags);
33}
34
Stephen Hemminger749c72ef2010-05-13 17:53:16 -070035const struct xattr_handler ext2_xattr_trusted_handler = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 .prefix = XATTR_TRUSTED_PREFIX,
37 .list = ext2_xattr_trusted_list,
38 .get = ext2_xattr_trusted_get,
39 .set = ext2_xattr_trusted_set,
40};