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