Al Viro | f466c6f | 2012-03-17 01:16:43 -0400 | [diff] [blame] | 1 | #include "reiserfs.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | #include <linux/errno.h> |
| 3 | #include <linux/fs.h> |
| 4 | #include <linux/pagemap.h> |
| 5 | #include <linux/xattr.h> |
Al Viro | c45ac88 | 2012-03-17 00:59:06 -0400 | [diff] [blame] | 6 | #include "xattr.h" |
Fabian Frederick | 17093991 | 2014-08-08 14:21:12 -0700 | [diff] [blame] | 7 | #include <linux/uaccess.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | static int |
Al Viro | b296821 | 2016-04-10 20:48:24 -0400 | [diff] [blame^] | 10 | user_get(const struct xattr_handler *handler, struct dentry *unused, |
| 11 | struct inode *inode, const char *name, void *buffer, size_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | { |
Al Viro | b296821 | 2016-04-10 20:48:24 -0400 | [diff] [blame^] | 13 | if (!reiserfs_xattrs_user(inode->i_sb)) |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 14 | return -EOPNOTSUPP; |
Al Viro | b296821 | 2016-04-10 20:48:24 -0400 | [diff] [blame^] | 15 | return reiserfs_xattr_get(inode, xattr_full_name(handler, name), |
Al Viro | 79a628d | 2016-04-10 18:50:48 -0400 | [diff] [blame] | 16 | buffer, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | static int |
Andreas Gruenbacher | d9a82a0 | 2015-10-04 19:18:51 +0200 | [diff] [blame] | 20 | user_set(const struct xattr_handler *handler, struct dentry *dentry, |
| 21 | const char *name, const void *buffer, size_t size, int flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | { |
Christoph Hellwig | 431547b | 2009-11-13 09:52:56 +0000 | [diff] [blame] | 23 | if (!reiserfs_xattrs_user(dentry->d_sb)) |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 24 | return -EOPNOTSUPP; |
Al Viro | 79a628d | 2016-04-10 18:50:48 -0400 | [diff] [blame] | 25 | return reiserfs_xattr_set(d_inode(dentry), |
| 26 | xattr_full_name(handler, name), |
| 27 | buffer, size, flags); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 28 | } |
| 29 | |
Andreas Gruenbacher | 764a5c6 | 2015-12-02 14:44:43 +0100 | [diff] [blame] | 30 | static bool user_list(struct dentry *dentry) |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 31 | { |
Andreas Gruenbacher | 764a5c6 | 2015-12-02 14:44:43 +0100 | [diff] [blame] | 32 | return reiserfs_xattrs_user(dentry->d_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | } |
| 34 | |
Stephen Hemminger | 94d09a9 | 2010-05-13 17:53:19 -0700 | [diff] [blame] | 35 | const struct xattr_handler reiserfs_xattr_user_handler = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | .prefix = XATTR_USER_PREFIX, |
| 37 | .get = user_get, |
| 38 | .set = user_set, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | .list = user_list, |
| 40 | }; |