xref: /openbmc/linux/fs/ext2/xattr_trusted.c (revision 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e)
1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  * linux/fs/ext2/xattr_trusted.c
41da177e4SLinus Torvalds  * Handler for trusted extended attributes.
51da177e4SLinus Torvalds  *
61da177e4SLinus Torvalds  * Copyright (C) 2003 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
71da177e4SLinus Torvalds  */
81da177e4SLinus Torvalds 
9f7699f2bSAl Viro #include "ext2.h"
101da177e4SLinus Torvalds #include "xattr.h"
111da177e4SLinus Torvalds 
12764a5c6bSAndreas Gruenbacher static bool
ext2_xattr_trusted_list(struct dentry * dentry)13764a5c6bSAndreas Gruenbacher ext2_xattr_trusted_list(struct dentry *dentry)
141da177e4SLinus Torvalds {
15764a5c6bSAndreas Gruenbacher 	return capable(CAP_SYS_ADMIN);
161da177e4SLinus Torvalds }
171da177e4SLinus Torvalds 
181da177e4SLinus Torvalds static int
ext2_xattr_trusted_get(const struct xattr_handler * handler,struct dentry * unused,struct inode * inode,const char * name,void * buffer,size_t size)19d9a82a04SAndreas Gruenbacher ext2_xattr_trusted_get(const struct xattr_handler *handler,
20b296821aSAl Viro 		       struct dentry *unused, struct inode *inode,
21b296821aSAl Viro 		       const char *name, void *buffer, size_t size)
221da177e4SLinus Torvalds {
23b296821aSAl Viro 	return ext2_xattr_get(inode, EXT2_XATTR_INDEX_TRUSTED, name,
241da177e4SLinus Torvalds 			      buffer, size);
251da177e4SLinus Torvalds }
261da177e4SLinus Torvalds 
271da177e4SLinus Torvalds static int
ext2_xattr_trusted_set(const struct xattr_handler * handler,struct mnt_idmap * idmap,struct dentry * unused,struct inode * inode,const char * name,const void * value,size_t size,int flags)28d9a82a04SAndreas Gruenbacher ext2_xattr_trusted_set(const struct xattr_handler *handler,
29*39f60c1cSChristian Brauner 		       struct mnt_idmap *idmap,
3059301226SAl Viro 		       struct dentry *unused, struct inode *inode,
3159301226SAl Viro 		       const char *name, const void *value,
3259301226SAl Viro 		       size_t size, int flags)
331da177e4SLinus Torvalds {
3459301226SAl Viro 	return ext2_xattr_set(inode, EXT2_XATTR_INDEX_TRUSTED, name,
351da177e4SLinus Torvalds 			      value, size, flags);
361da177e4SLinus Torvalds }
371da177e4SLinus Torvalds 
38749c72efSStephen Hemminger const struct xattr_handler ext2_xattr_trusted_handler = {
391da177e4SLinus Torvalds 	.prefix	= XATTR_TRUSTED_PREFIX,
401da177e4SLinus Torvalds 	.list	= ext2_xattr_trusted_list,
411da177e4SLinus Torvalds 	.get	= ext2_xattr_trusted_get,
421da177e4SLinus Torvalds 	.set	= ext2_xattr_trusted_set,
431da177e4SLinus Torvalds };
44