blob: 1384efcb938e078d882587ee9e84e1de10090bb2 [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
9#ifdef CONFIG_REISERFS_FS_POSIX_ACL
10# include <linux/reiserfs_acl.h>
11#endif
12
Linus Torvalds1da177e2005-04-16 15:20:36 -070013static int
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070014user_get(struct inode *inode, const char *name, void *buffer, size_t size)
Linus Torvalds1da177e2005-04-16 15:20:36 -070015{
16
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070017 if (strlen(name) < sizeof(XATTR_USER_PREFIX))
18 return -EINVAL;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070019 if (!reiserfs_xattrs_user(inode->i_sb))
20 return -EOPNOTSUPP;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070021 return reiserfs_xattr_get(inode, name, buffer, size);
Linus Torvalds1da177e2005-04-16 15:20:36 -070022}
23
24static int
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070025user_set(struct inode *inode, const char *name, const void *buffer,
26 size_t size, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -070027{
28
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070029 if (strlen(name) < sizeof(XATTR_USER_PREFIX))
30 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070032 if (!reiserfs_xattrs_user(inode->i_sb))
33 return -EOPNOTSUPP;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070034 return reiserfs_xattr_set(inode, name, buffer, size, flags);
35}
36
37static int user_del(struct inode *inode, const char *name)
38{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070039 if (strlen(name) < sizeof(XATTR_USER_PREFIX))
40 return -EINVAL;
41
42 if (!reiserfs_xattrs_user(inode->i_sb))
43 return -EOPNOTSUPP;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070044 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070045}
46
47static int
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070048user_list(struct inode *inode, const char *name, int namelen, char *out)
Linus Torvalds1da177e2005-04-16 15:20:36 -070049{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070050 int len = namelen;
51 if (!reiserfs_xattrs_user(inode->i_sb))
52 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070054 if (out)
55 memcpy(out, name, len);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070057 return len;
Linus Torvalds1da177e2005-04-16 15:20:36 -070058}
59
60struct 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};