Commit a4a4ddc5 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] reiserfs: support trusted xattrs

From: Chris Mason <mason@suse.com>

From: jeffm@suse.com

reiserfs support for trusted xattrs
parent 0acef032
No related merge requests found
......@@ -10,7 +10,7 @@ reiserfs-objs := bitmap.o do_balan.o namei.o inode.o file.o dir.o fix_node.o \
item_ops.o ioctl.o procfs.o
ifeq ($(CONFIG_REISERFS_FS_XATTR),y)
reiserfs-objs += xattr.o xattr_user.o
reiserfs-objs += xattr.o xattr_user.o xattr_trusted.o
endif
ifeq ($(CONFIG_REISERFS_FS_POSIX_ACL),y)
......
......@@ -1176,6 +1176,7 @@ reiserfs_xattr_register_handlers (void)
/* Add the handlers */
list_add_tail (&user_handler.handlers, &xattr_handlers);
list_add_tail (&trusted_handler.handlers, &xattr_handlers);
#ifdef CONFIG_REISERFS_FS_POSIX_ACL
list_add_tail (&posix_acl_access_handler.handlers, &xattr_handlers);
list_add_tail (&posix_acl_default_handler.handlers, &xattr_handlers);
......
#include <linux/reiserfs_fs.h>
#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
trusted_get (struct inode *inode, const char *name, void *buffer, size_t size)
{
if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
return -EINVAL;
if (!reiserfs_xattrs (inode->i_sb))
return -EOPNOTSUPP;
if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
return -EPERM;
return reiserfs_xattr_get (inode, name, buffer, size);
}
static int
trusted_set (struct inode *inode, const char *name, const void *buffer,
size_t size, int flags)
{
if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
return -EINVAL;
if (!reiserfs_xattrs (inode->i_sb))
return -EOPNOTSUPP;
if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
return -EPERM;
return reiserfs_xattr_set (inode, name, buffer, size, flags);
}
static int
trusted_del (struct inode *inode, const char *name)
{
if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
return -EINVAL;
if (!reiserfs_xattrs (inode->i_sb))
return -EOPNOTSUPP;
if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
return -EPERM;
return 0;
}
static int
trusted_list (struct inode *inode, const char *name, int namelen, char *out)
{
int len = namelen;
if (!reiserfs_xattrs (inode->i_sb))
return 0;
if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
return 0;
if (out)
memcpy (out, name, len);
return len;
}
struct reiserfs_xattr_handler trusted_handler = {
prefix: XATTR_TRUSTED_PREFIX,
get: trusted_get,
set: trusted_set,
del: trusted_del,
list: trusted_list,
};
......@@ -50,6 +50,7 @@ int reiserfs_xattr_set (struct inode *, const char *, const void *,
size_t, int);
extern struct reiserfs_xattr_handler user_handler;
extern struct reiserfs_xattr_handler trusted_handler;
int reiserfs_xattr_register_handlers (void) __init;
void reiserfs_xattr_unregister_handlers (void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment