blob: 073f39364b1136dcd9cbb808f5820b3e5581ff58 [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
13#define XATTR_USER_PREFIX "user."
14
15static int
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070016user_get(struct inode *inode, const char *name, void *buffer, size_t size)
Linus Torvalds1da177e2005-04-16 15:20:36 -070017{
18
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070019 if (strlen(name) < sizeof(XATTR_USER_PREFIX))
20 return -EINVAL;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070021 if (!reiserfs_xattrs_user(inode->i_sb))
22 return -EOPNOTSUPP;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070023 return reiserfs_xattr_get(inode, name, buffer, size);
Linus Torvalds1da177e2005-04-16 15:20:36 -070024}
25
26static int
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070027user_set(struct inode *inode, const char *name, const void *buffer,
28 size_t size, int flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -070029{
30
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070031 if (strlen(name) < sizeof(XATTR_USER_PREFIX))
32 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070034 if (!reiserfs_xattrs_user(inode->i_sb))
35 return -EOPNOTSUPP;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070036 return reiserfs_xattr_set(inode, name, buffer, size, flags);
37}
38
39static int user_del(struct inode *inode, const char *name)
40{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070041 if (strlen(name) < sizeof(XATTR_USER_PREFIX))
42 return -EINVAL;
43
44 if (!reiserfs_xattrs_user(inode->i_sb))
45 return -EOPNOTSUPP;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070046 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070047}
48
49static int
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070050user_list(struct inode *inode, const char *name, int namelen, char *out)
Linus Torvalds1da177e2005-04-16 15:20:36 -070051{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070052 int len = namelen;
53 if (!reiserfs_xattrs_user(inode->i_sb))
54 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070056 if (out)
57 memcpy(out, name, len);
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070059 return len;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060}
61
62struct 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};