Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Al Viro | f7699f2 | 2012-03-23 16:45:51 -0400 | [diff] [blame] | 8 | #include "ext2.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #include "xattr.h" |
| 10 | |
Andreas Gruenbacher | 764a5c6 | 2015-12-02 14:44:43 +0100 | [diff] [blame] | 11 | static bool |
| 12 | ext2_xattr_trusted_list(struct dentry *dentry) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | { |
Andreas Gruenbacher | 764a5c6 | 2015-12-02 14:44:43 +0100 | [diff] [blame] | 14 | return capable(CAP_SYS_ADMIN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | } |
| 16 | |
| 17 | static int |
Andreas Gruenbacher | d9a82a0 | 2015-10-04 19:18:51 +0200 | [diff] [blame] | 18 | ext2_xattr_trusted_get(const struct xattr_handler *handler, |
Al Viro | b296821 | 2016-04-10 20:48:24 -0400 | [diff] [blame] | 19 | struct dentry *unused, struct inode *inode, |
| 20 | const char *name, void *buffer, size_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | { |
Al Viro | b296821 | 2016-04-10 20:48:24 -0400 | [diff] [blame] | 22 | return ext2_xattr_get(inode, EXT2_XATTR_INDEX_TRUSTED, name, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | buffer, size); |
| 24 | } |
| 25 | |
| 26 | static int |
Andreas Gruenbacher | d9a82a0 | 2015-10-04 19:18:51 +0200 | [diff] [blame] | 27 | ext2_xattr_trusted_set(const struct xattr_handler *handler, |
Al Viro | 5930122 | 2016-05-27 10:19:30 -0400 | [diff] [blame] | 28 | struct dentry *unused, struct inode *inode, |
| 29 | const char *name, const void *value, |
| 30 | size_t size, int flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | { |
Al Viro | 5930122 | 2016-05-27 10:19:30 -0400 | [diff] [blame] | 32 | return ext2_xattr_set(inode, EXT2_XATTR_INDEX_TRUSTED, name, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | value, size, flags); |
| 34 | } |
| 35 | |
Stephen Hemminger | 749c72ef | 2010-05-13 17:53:16 -0700 | [diff] [blame] | 36 | const struct xattr_handler ext2_xattr_trusted_handler = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | .prefix = XATTR_TRUSTED_PREFIX, |
| 38 | .list = ext2_xattr_trusted_list, |
| 39 | .get = ext2_xattr_trusted_get, |
| 40 | .set = ext2_xattr_trusted_set, |
| 41 | }; |