2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/reiserfs_fs.h>
|
2006-01-12 03:17:46 +07:00
|
|
|
#include <linux/capability.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/pagemap.h>
|
|
|
|
#include <linux/xattr.h>
|
|
|
|
#include <linux/reiserfs_xattr.h>
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
|
|
|
|
#define XATTR_TRUSTED_PREFIX "trusted."
|
|
|
|
|
|
|
|
static int
|
2005-07-13 10:21:28 +07:00
|
|
|
trusted_get(struct inode *inode, const char *name, void *buffer, size_t size)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2005-07-13 10:21:28 +07:00
|
|
|
if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
|
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-07-13 10:21:28 +07:00
|
|
|
if (!reiserfs_xattrs(inode->i_sb))
|
|
|
|
return -EOPNOTSUPP;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-07-13 10:21:28 +07:00
|
|
|
if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
|
|
|
|
return -EPERM;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-07-13 10:21:28 +07:00
|
|
|
return reiserfs_xattr_get(inode, name, buffer, size);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2005-07-13 10:21:28 +07:00
|
|
|
trusted_set(struct inode *inode, const char *name, const void *buffer,
|
|
|
|
size_t size, int flags)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2005-07-13 10:21:28 +07:00
|
|
|
if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
|
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-07-13 10:21:28 +07:00
|
|
|
if (!reiserfs_xattrs(inode->i_sb))
|
|
|
|
return -EOPNOTSUPP;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-07-13 10:21:28 +07:00
|
|
|
if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
|
|
|
|
return -EPERM;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-07-13 10:21:28 +07:00
|
|
|
return reiserfs_xattr_set(inode, name, buffer, size, flags);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2005-07-13 10:21:28 +07:00
|
|
|
static int trusted_del(struct inode *inode, const char *name)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2005-07-13 10:21:28 +07:00
|
|
|
if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
|
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-07-13 10:21:28 +07:00
|
|
|
if (!reiserfs_xattrs(inode->i_sb))
|
|
|
|
return -EOPNOTSUPP;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-07-13 10:21:28 +07:00
|
|
|
if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
|
|
|
|
return -EPERM;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-07-13 10:21:28 +07:00
|
|
|
return 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2005-07-13 10:21:28 +07:00
|
|
|
trusted_list(struct inode *inode, const char *name, int namelen, char *out)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2005-07-13 10:21:28 +07:00
|
|
|
int len = namelen;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-07-13 10:21:28 +07:00
|
|
|
if (!reiserfs_xattrs(inode->i_sb))
|
|
|
|
return 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-07-13 10:21:28 +07:00
|
|
|
if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
|
|
|
|
return 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-07-13 10:21:28 +07:00
|
|
|
if (out)
|
|
|
|
memcpy(out, name, len);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-07-13 10:21:28 +07:00
|
|
|
return len;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
struct reiserfs_xattr_handler trusted_handler = {
|
|
|
|
.prefix = XATTR_TRUSTED_PREFIX,
|
|
|
|
.get = trusted_get,
|
|
|
|
.set = trusted_set,
|
|
|
|
.del = trusted_del,
|
|
|
|
.list = trusted_list,
|
|
|
|
};
|