blob: e3238dc4f3db941ebf3108d347402fbc9a8281df [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#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 Torvalds1da177e2005-04-16 15:20:36 -07009static int
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070010user_get(struct inode *inode, const char *name, void *buffer, size_t size)
Linus Torvalds1da177e2005-04-16 15:20:36 -070011{
12
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070013 if (strlen(name) < sizeof(XATTR_USER_PREFIX))
14 return -EINVAL;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070015 if (!reiserfs_xattrs_user(inode->i_sb))
16 return -EOPNOTSUPP;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070017 return reiserfs_xattr_get(inode, name, buffer, size);
Linus Torvalds1da177e2005-04-16 15:20:36 -070018}
19
20static int
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070021user_set(struct inode *inode, const char *name, const void *buffer,
22 size_t size, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -070023{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070024 if (strlen(name) < sizeof(XATTR_USER_PREFIX))
25 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070027 if (!reiserfs_xattrs_user(inode->i_sb))
28 return -EOPNOTSUPP;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070029 return reiserfs_xattr_set(inode, name, buffer, size, flags);
30}
31
Jeff Mahoney48b32a32009-03-30 14:02:38 -040032static size_t user_list(struct inode *inode, char *list, size_t list_size,
33 const char *name, size_t name_len)
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070034{
Jeff Mahoney48b32a32009-03-30 14:02:38 -040035 const size_t len = name_len + 1;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070036
37 if (!reiserfs_xattrs_user(inode->i_sb))
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070038 return 0;
Jeff Mahoney48b32a32009-03-30 14:02:38 -040039 if (list && len <= list_size) {
40 memcpy(list, name, name_len);
41 list[name_len] = '\0';
42 }
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070043 return len;
Linus Torvalds1da177e2005-04-16 15:20:36 -070044}
45
Jeff Mahoney48b32a32009-03-30 14:02:38 -040046struct xattr_handler reiserfs_xattr_user_handler = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 .prefix = XATTR_USER_PREFIX,
48 .get = user_get,
49 .set = user_set,
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 .list = user_list,
51};