2012-03-17 06:16:43 +01:00
|
|
|
#include "reiserfs.h"
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/pagemap.h>
|
|
|
|
#include <linux/xattr.h>
|
2012-03-17 05:59:06 +01:00
|
|
|
#include "xattr.h"
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <asm/uaccess.h>
|
|
|
|
|
|
|
|
static int
|
2009-11-13 10:52:56 +01:00
|
|
|
user_get(struct dentry *dentry, const char *name, void *buffer, size_t size,
|
|
|
|
int handler_flags)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
|
2005-07-13 05:21:28 +02:00
|
|
|
if (strlen(name) < sizeof(XATTR_USER_PREFIX))
|
|
|
|
return -EINVAL;
|
2009-11-13 10:52:56 +01:00
|
|
|
if (!reiserfs_xattrs_user(dentry->d_sb))
|
2005-07-13 05:21:28 +02:00
|
|
|
return -EOPNOTSUPP;
|
2009-11-13 10:52:56 +01:00
|
|
|
return reiserfs_xattr_get(dentry->d_inode, name, buffer, size);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-11-13 10:52:56 +01:00
|
|
|
user_set(struct dentry *dentry, const char *name, const void *buffer,
|
|
|
|
size_t size, int flags, int handler_flags)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2005-07-13 05:21:28 +02:00
|
|
|
if (strlen(name) < sizeof(XATTR_USER_PREFIX))
|
|
|
|
return -EINVAL;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2009-11-13 10:52:56 +01:00
|
|
|
if (!reiserfs_xattrs_user(dentry->d_sb))
|
2005-07-13 05:21:28 +02:00
|
|
|
return -EOPNOTSUPP;
|
2009-11-13 10:52:56 +01:00
|
|
|
return reiserfs_xattr_set(dentry->d_inode, name, buffer, size, flags);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2009-11-13 10:52:56 +01:00
|
|
|
static size_t user_list(struct dentry *dentry, char *list, size_t list_size,
|
|
|
|
const char *name, size_t name_len, int handler_flags)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2009-03-30 20:02:38 +02:00
|
|
|
const size_t len = name_len + 1;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2009-11-13 10:52:56 +01:00
|
|
|
if (!reiserfs_xattrs_user(dentry->d_sb))
|
2005-07-13 05:21:28 +02:00
|
|
|
return 0;
|
2009-03-30 20:02:38 +02:00
|
|
|
if (list && len <= list_size) {
|
|
|
|
memcpy(list, name, name_len);
|
|
|
|
list[name_len] = '\0';
|
|
|
|
}
|
2005-07-13 05:21:28 +02:00
|
|
|
return len;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2010-05-14 02:53:19 +02:00
|
|
|
const struct xattr_handler reiserfs_xattr_user_handler = {
|
2005-04-17 00:20:36 +02:00
|
|
|
.prefix = XATTR_USER_PREFIX,
|
|
|
|
.get = user_get,
|
|
|
|
.set = user_set,
|
|
|
|
.list = user_list,
|
|
|
|
};
|