Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #include <linux/reiserfs_fs.h> |
| 2 | #include <linux/errno.h> |
| 3 | #include <linux/fs.h> |
| 4 | #include <linux/pagemap.h> |
| 5 | #include <linux/xattr.h> |
| 6 | #include <linux/reiserfs_xattr.h> |
| 7 | #include <asm/uaccess.h> |
| 8 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | static int |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 10 | user_get(struct inode *inode, const char *name, void *buffer, size_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | { |
| 12 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 13 | if (strlen(name) < sizeof(XATTR_USER_PREFIX)) |
| 14 | return -EINVAL; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 15 | if (!reiserfs_xattrs_user(inode->i_sb)) |
| 16 | return -EOPNOTSUPP; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 17 | return reiserfs_xattr_get(inode, name, buffer, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | static int |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 21 | user_set(struct inode *inode, const char *name, const void *buffer, |
| 22 | size_t size, int flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 24 | if (strlen(name) < sizeof(XATTR_USER_PREFIX)) |
| 25 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 27 | if (!reiserfs_xattrs_user(inode->i_sb)) |
| 28 | return -EOPNOTSUPP; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 29 | return reiserfs_xattr_set(inode, name, buffer, size, flags); |
| 30 | } |
| 31 | |
Jeff Mahoney | 48b32a3 | 2009-03-30 14:02:38 -0400 | [diff] [blame] | 32 | static size_t user_list(struct inode *inode, char *list, size_t list_size, |
| 33 | const char *name, size_t name_len) |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 34 | { |
Jeff Mahoney | 48b32a3 | 2009-03-30 14:02:38 -0400 | [diff] [blame] | 35 | const size_t len = name_len + 1; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 36 | |
| 37 | if (!reiserfs_xattrs_user(inode->i_sb)) |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 38 | return 0; |
Jeff Mahoney | 48b32a3 | 2009-03-30 14:02:38 -0400 | [diff] [blame] | 39 | if (list && len <= list_size) { |
| 40 | memcpy(list, name, name_len); |
| 41 | list[name_len] = '\0'; |
| 42 | } |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 43 | return len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | } |
| 45 | |
Jeff Mahoney | 48b32a3 | 2009-03-30 14:02:38 -0400 | [diff] [blame] | 46 | struct xattr_handler reiserfs_xattr_user_handler = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | .prefix = XATTR_USER_PREFIX, |
| 48 | .get = user_get, |
| 49 | .set = user_set, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | .list = user_list, |
| 51 | }; |