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, |
| 19 | struct dentry *dentry, const char *name, |
| 20 | void *buffer, size_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | { |
David Howells | 2b0143b | 2015-03-17 22:25:59 +0000 | [diff] [blame] | 22 | return ext2_xattr_get(d_inode(dentry), 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, |
| 28 | struct dentry *dentry, const char *name, |
| 29 | const void *value, size_t size, int flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | { |
David Howells | 2b0143b | 2015-03-17 22:25:59 +0000 | [diff] [blame] | 31 | return ext2_xattr_set(d_inode(dentry), EXT2_XATTR_INDEX_TRUSTED, name, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | value, size, flags); |
| 33 | } |
| 34 | |
Stephen Hemminger | 749c72ef | 2010-05-13 17:53:16 -0700 | [diff] [blame] | 35 | const struct xattr_handler ext2_xattr_trusted_handler = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | .prefix = XATTR_TRUSTED_PREFIX, |
| 37 | .list = ext2_xattr_trusted_list, |
| 38 | .get = ext2_xattr_trusted_get, |
| 39 | .set = ext2_xattr_trusted_set, |
| 40 | }; |