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 | |
| 9 | #ifdef CONFIG_REISERFS_FS_POSIX_ACL |
| 10 | # include <linux/reiserfs_acl.h> |
| 11 | #endif |
| 12 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | static int |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 14 | 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] | 15 | { |
| 16 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 17 | if (strlen(name) < sizeof(XATTR_USER_PREFIX)) |
| 18 | return -EINVAL; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 19 | if (!reiserfs_xattrs_user(inode->i_sb)) |
| 20 | return -EOPNOTSUPP; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 21 | return reiserfs_xattr_get(inode, name, buffer, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | static int |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 25 | user_set(struct inode *inode, const char *name, const void *buffer, |
| 26 | size_t size, int flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | { |
| 28 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 29 | if (strlen(name) < sizeof(XATTR_USER_PREFIX)) |
| 30 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 32 | if (!reiserfs_xattrs_user(inode->i_sb)) |
| 33 | return -EOPNOTSUPP; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 34 | return reiserfs_xattr_set(inode, name, buffer, size, flags); |
| 35 | } |
| 36 | |
| 37 | static int user_del(struct inode *inode, const char *name) |
| 38 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 39 | if (strlen(name) < sizeof(XATTR_USER_PREFIX)) |
| 40 | return -EINVAL; |
| 41 | |
| 42 | if (!reiserfs_xattrs_user(inode->i_sb)) |
| 43 | return -EOPNOTSUPP; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 44 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | static int |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 48 | user_list(struct inode *inode, const char *name, int namelen, char *out) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 50 | int len = namelen; |
| 51 | if (!reiserfs_xattrs_user(inode->i_sb)) |
| 52 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 54 | if (out) |
| 55 | memcpy(out, name, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 57 | return len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | struct reiserfs_xattr_handler user_handler = { |
| 61 | .prefix = XATTR_USER_PREFIX, |
| 62 | .get = user_get, |
| 63 | .set = user_set, |
| 64 | .del = user_del, |
| 65 | .list = user_list, |
| 66 | }; |