Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * linux/fs/ext4/xattr_trusted.c
0004  * Handler for trusted extended attributes.
0005  *
0006  * Copyright (C) 2003 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
0007  */
0008 
0009 #include <linux/string.h>
0010 #include <linux/capability.h>
0011 #include <linux/fs.h>
0012 #include "ext4_jbd2.h"
0013 #include "ext4.h"
0014 #include "xattr.h"
0015 
0016 static bool
0017 ext4_xattr_trusted_list(struct dentry *dentry)
0018 {
0019     return capable(CAP_SYS_ADMIN);
0020 }
0021 
0022 static int
0023 ext4_xattr_trusted_get(const struct xattr_handler *handler,
0024                struct dentry *unused, struct inode *inode,
0025                const char *name, void *buffer, size_t size)
0026 {
0027     return ext4_xattr_get(inode, EXT4_XATTR_INDEX_TRUSTED,
0028                   name, buffer, size);
0029 }
0030 
0031 static int
0032 ext4_xattr_trusted_set(const struct xattr_handler *handler,
0033                struct user_namespace *mnt_userns,
0034                struct dentry *unused, struct inode *inode,
0035                const char *name, const void *value,
0036                size_t size, int flags)
0037 {
0038     return ext4_xattr_set(inode, EXT4_XATTR_INDEX_TRUSTED,
0039                   name, value, size, flags);
0040 }
0041 
0042 const struct xattr_handler ext4_xattr_trusted_handler = {
0043     .prefix = XATTR_TRUSTED_PREFIX,
0044     .list   = ext4_xattr_trusted_list,
0045     .get    = ext4_xattr_trusted_get,
0046     .set    = ext4_xattr_trusted_set,
0047 };