18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * linux/fs/ext4/xattr_user.c 48c2ecf20Sopenharmony_ci * Handler for extended user attributes. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org> 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/string.h> 108c2ecf20Sopenharmony_ci#include <linux/fs.h> 118c2ecf20Sopenharmony_ci#include "ext4_jbd2.h" 128c2ecf20Sopenharmony_ci#include "ext4.h" 138c2ecf20Sopenharmony_ci#include "xattr.h" 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_cistatic bool 168c2ecf20Sopenharmony_ciext4_xattr_user_list(struct dentry *dentry) 178c2ecf20Sopenharmony_ci{ 188c2ecf20Sopenharmony_ci return test_opt(dentry->d_sb, XATTR_USER); 198c2ecf20Sopenharmony_ci} 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_cistatic int 228c2ecf20Sopenharmony_ciext4_xattr_user_get(const struct xattr_handler *handler, 238c2ecf20Sopenharmony_ci struct dentry *unused, struct inode *inode, 248c2ecf20Sopenharmony_ci const char *name, void *buffer, size_t size) 258c2ecf20Sopenharmony_ci{ 268c2ecf20Sopenharmony_ci if (!test_opt(inode->i_sb, XATTR_USER)) 278c2ecf20Sopenharmony_ci return -EOPNOTSUPP; 288c2ecf20Sopenharmony_ci return ext4_xattr_get(inode, EXT4_XATTR_INDEX_USER, 298c2ecf20Sopenharmony_ci name, buffer, size); 308c2ecf20Sopenharmony_ci} 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cistatic int 338c2ecf20Sopenharmony_ciext4_xattr_user_set(const struct xattr_handler *handler, 348c2ecf20Sopenharmony_ci struct dentry *unused, struct inode *inode, 358c2ecf20Sopenharmony_ci const char *name, const void *value, 368c2ecf20Sopenharmony_ci size_t size, int flags) 378c2ecf20Sopenharmony_ci{ 388c2ecf20Sopenharmony_ci if (!test_opt(inode->i_sb, XATTR_USER)) 398c2ecf20Sopenharmony_ci return -EOPNOTSUPP; 408c2ecf20Sopenharmony_ci return ext4_xattr_set(inode, EXT4_XATTR_INDEX_USER, 418c2ecf20Sopenharmony_ci name, value, size, flags); 428c2ecf20Sopenharmony_ci} 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ciconst struct xattr_handler ext4_xattr_user_handler = { 458c2ecf20Sopenharmony_ci .prefix = XATTR_USER_PREFIX, 468c2ecf20Sopenharmony_ci .list = ext4_xattr_user_list, 478c2ecf20Sopenharmony_ci .get = ext4_xattr_user_get, 488c2ecf20Sopenharmony_ci .set = ext4_xattr_user_set, 498c2ecf20Sopenharmony_ci}; 50