^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #include "reiserfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/pagemap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/xattr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include "xattr.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) user_get(const struct xattr_handler *handler, struct dentry *unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) struct inode *inode, const char *name, void *buffer, size_t size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) if (!reiserfs_xattrs_user(inode->i_sb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) return reiserfs_xattr_get(inode, xattr_full_name(handler, name),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) buffer, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) user_set(const struct xattr_handler *handler, struct dentry *unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct inode *inode, const char *name, const void *buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) size_t size, int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) if (!reiserfs_xattrs_user(inode->i_sb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) return reiserfs_xattr_set(inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) xattr_full_name(handler, name),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) buffer, size, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) static bool user_list(struct dentry *dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) return reiserfs_xattrs_user(dentry->d_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) const struct xattr_handler reiserfs_xattr_user_handler = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) .prefix = XATTR_USER_PREFIX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) .get = user_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) .set = user_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) .list = user_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) };