0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <linux/string.h>
0010 #include <linux/fs.h>
0011 #include "ext4_jbd2.h"
0012 #include "ext4.h"
0013 #include "xattr.h"
0014
0015 static bool
0016 ext4_xattr_user_list(struct dentry *dentry)
0017 {
0018 return test_opt(dentry->d_sb, XATTR_USER);
0019 }
0020
0021 static int
0022 ext4_xattr_user_get(const struct xattr_handler *handler,
0023 struct dentry *unused, struct inode *inode,
0024 const char *name, void *buffer, size_t size)
0025 {
0026 if (!test_opt(inode->i_sb, XATTR_USER))
0027 return -EOPNOTSUPP;
0028 return ext4_xattr_get(inode, EXT4_XATTR_INDEX_USER,
0029 name, buffer, size);
0030 }
0031
0032 static int
0033 ext4_xattr_user_set(const struct xattr_handler *handler,
0034 struct user_namespace *mnt_userns,
0035 struct dentry *unused, struct inode *inode,
0036 const char *name, const void *value,
0037 size_t size, int flags)
0038 {
0039 if (!test_opt(inode->i_sb, XATTR_USER))
0040 return -EOPNOTSUPP;
0041 return ext4_xattr_set(inode, EXT4_XATTR_INDEX_USER,
0042 name, value, size, flags);
0043 }
0044
0045 const struct xattr_handler ext4_xattr_user_handler = {
0046 .prefix = XATTR_USER_PREFIX,
0047 .list = ext4_xattr_user_list,
0048 .get = ext4_xattr_user_get,
0049 .set = ext4_xattr_user_set,
0050 };