reiserfs: switch to generic_{get,set,remove}xattr()
reiserfs_xattr_[sg]et() will fail with -EOPNOTSUPP for V1 inodes anyway, and all reiserfs instances of ->[sg]et() call it and so does ->set_acl(). Checks for name length in the instances had been bogus; they should've been "bugger off if it's _exactly_ the prefix" (as generic would do on its own) and not "bugger off if it's shorter than the prefix" - that can't happen. xattr_full_name() is needed to adjust for the fact that generic instances will skip the prefix in the name passed to ->[gs]et(); reiserfs homegrown analogues didn't. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Родитель
5fdccfef48
Коммит
79a628d14e
|
@ -260,10 +260,10 @@ const struct file_operations reiserfs_file_operations = {
|
|||
|
||||
const struct inode_operations reiserfs_file_inode_operations = {
|
||||
.setattr = reiserfs_setattr,
|
||||
.setxattr = reiserfs_setxattr,
|
||||
.getxattr = reiserfs_getxattr,
|
||||
.setxattr = generic_setxattr,
|
||||
.getxattr = generic_getxattr,
|
||||
.listxattr = reiserfs_listxattr,
|
||||
.removexattr = reiserfs_removexattr,
|
||||
.removexattr = generic_removexattr,
|
||||
.permission = reiserfs_permission,
|
||||
.get_acl = reiserfs_get_acl,
|
||||
.set_acl = reiserfs_set_acl,
|
||||
|
|
|
@ -1650,10 +1650,10 @@ const struct inode_operations reiserfs_dir_inode_operations = {
|
|||
.mknod = reiserfs_mknod,
|
||||
.rename = reiserfs_rename,
|
||||
.setattr = reiserfs_setattr,
|
||||
.setxattr = reiserfs_setxattr,
|
||||
.getxattr = reiserfs_getxattr,
|
||||
.setxattr = generic_setxattr,
|
||||
.getxattr = generic_getxattr,
|
||||
.listxattr = reiserfs_listxattr,
|
||||
.removexattr = reiserfs_removexattr,
|
||||
.removexattr = generic_removexattr,
|
||||
.permission = reiserfs_permission,
|
||||
.get_acl = reiserfs_get_acl,
|
||||
.set_acl = reiserfs_set_acl,
|
||||
|
@ -1667,10 +1667,10 @@ const struct inode_operations reiserfs_symlink_inode_operations = {
|
|||
.readlink = generic_readlink,
|
||||
.get_link = page_get_link,
|
||||
.setattr = reiserfs_setattr,
|
||||
.setxattr = reiserfs_setxattr,
|
||||
.getxattr = reiserfs_getxattr,
|
||||
.setxattr = generic_setxattr,
|
||||
.getxattr = generic_getxattr,
|
||||
.listxattr = reiserfs_listxattr,
|
||||
.removexattr = reiserfs_removexattr,
|
||||
.removexattr = generic_removexattr,
|
||||
.permission = reiserfs_permission,
|
||||
};
|
||||
|
||||
|
@ -1679,10 +1679,10 @@ const struct inode_operations reiserfs_symlink_inode_operations = {
|
|||
*/
|
||||
const struct inode_operations reiserfs_special_inode_operations = {
|
||||
.setattr = reiserfs_setattr,
|
||||
.setxattr = reiserfs_setxattr,
|
||||
.getxattr = reiserfs_getxattr,
|
||||
.setxattr = generic_setxattr,
|
||||
.getxattr = generic_getxattr,
|
||||
.listxattr = reiserfs_listxattr,
|
||||
.removexattr = reiserfs_removexattr,
|
||||
.removexattr = generic_removexattr,
|
||||
.permission = reiserfs_permission,
|
||||
.get_acl = reiserfs_get_acl,
|
||||
.set_acl = reiserfs_set_acl,
|
||||
|
|
|
@ -764,60 +764,6 @@ find_xattr_handler_prefix(const struct xattr_handler **handlers,
|
|||
return xah;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Inode operation getxattr()
|
||||
*/
|
||||
ssize_t
|
||||
reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer,
|
||||
size_t size)
|
||||
{
|
||||
const struct xattr_handler *handler;
|
||||
|
||||
handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name);
|
||||
|
||||
if (!handler || get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
return handler->get(handler, dentry, name, buffer, size);
|
||||
}
|
||||
|
||||
/*
|
||||
* Inode operation setxattr()
|
||||
*
|
||||
* d_inode(dentry)->i_mutex down
|
||||
*/
|
||||
int
|
||||
reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value,
|
||||
size_t size, int flags)
|
||||
{
|
||||
const struct xattr_handler *handler;
|
||||
|
||||
handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name);
|
||||
|
||||
if (!handler || get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
return handler->set(handler, dentry, name, value, size, flags);
|
||||
}
|
||||
|
||||
/*
|
||||
* Inode operation removexattr()
|
||||
*
|
||||
* d_inode(dentry)->i_mutex down
|
||||
*/
|
||||
int reiserfs_removexattr(struct dentry *dentry, const char *name)
|
||||
{
|
||||
const struct xattr_handler *handler;
|
||||
|
||||
handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name);
|
||||
|
||||
if (!handler || get_inode_sd_version(d_inode(dentry)) == STAT_DATA_V1)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
return handler->set(handler, dentry, name, NULL, 0, XATTR_REPLACE);
|
||||
}
|
||||
|
||||
struct listxattr_buf {
|
||||
struct dir_context ctx;
|
||||
size_t size;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <linux/init.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/rwsem.h>
|
||||
#include <linux/xattr.h>
|
||||
|
||||
struct inode;
|
||||
struct dentry;
|
||||
|
@ -18,12 +19,7 @@ int reiserfs_permission(struct inode *inode, int mask);
|
|||
|
||||
#ifdef CONFIG_REISERFS_FS_XATTR
|
||||
#define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir)
|
||||
ssize_t reiserfs_getxattr(struct dentry *dentry, const char *name,
|
||||
void *buffer, size_t size);
|
||||
int reiserfs_setxattr(struct dentry *dentry, const char *name,
|
||||
const void *value, size_t size, int flags);
|
||||
ssize_t reiserfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
|
||||
int reiserfs_removexattr(struct dentry *dentry, const char *name);
|
||||
|
||||
int reiserfs_xattr_get(struct inode *, const char *, void *, size_t);
|
||||
int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int);
|
||||
|
@ -92,10 +88,7 @@ static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
|
|||
|
||||
#else
|
||||
|
||||
#define reiserfs_getxattr NULL
|
||||
#define reiserfs_setxattr NULL
|
||||
#define reiserfs_listxattr NULL
|
||||
#define reiserfs_removexattr NULL
|
||||
|
||||
static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
|
||||
{
|
||||
|
|
|
@ -12,26 +12,24 @@ static int
|
|||
security_get(const struct xattr_handler *handler, struct dentry *dentry,
|
||||
const char *name, void *buffer, size_t size)
|
||||
{
|
||||
if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
|
||||
return -EINVAL;
|
||||
|
||||
if (IS_PRIVATE(d_inode(dentry)))
|
||||
return -EPERM;
|
||||
|
||||
return reiserfs_xattr_get(d_inode(dentry), name, buffer, size);
|
||||
return reiserfs_xattr_get(d_inode(dentry),
|
||||
xattr_full_name(handler, name),
|
||||
buffer, size);
|
||||
}
|
||||
|
||||
static int
|
||||
security_set(const struct xattr_handler *handler, struct dentry *dentry,
|
||||
const char *name, const void *buffer, size_t size, int flags)
|
||||
{
|
||||
if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
|
||||
return -EINVAL;
|
||||
|
||||
if (IS_PRIVATE(d_inode(dentry)))
|
||||
return -EPERM;
|
||||
|
||||
return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags);
|
||||
return reiserfs_xattr_set(d_inode(dentry),
|
||||
xattr_full_name(handler, name),
|
||||
buffer, size, flags);
|
||||
}
|
||||
|
||||
static bool security_list(struct dentry *dentry)
|
||||
|
|
|
@ -11,26 +11,24 @@ static int
|
|||
trusted_get(const struct xattr_handler *handler, struct dentry *dentry,
|
||||
const char *name, void *buffer, size_t size)
|
||||
{
|
||||
if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
|
||||
return -EINVAL;
|
||||
|
||||
if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(d_inode(dentry)))
|
||||
return -EPERM;
|
||||
|
||||
return reiserfs_xattr_get(d_inode(dentry), name, buffer, size);
|
||||
return reiserfs_xattr_get(d_inode(dentry),
|
||||
xattr_full_name(handler, name),
|
||||
buffer, size);
|
||||
}
|
||||
|
||||
static int
|
||||
trusted_set(const struct xattr_handler *handler, struct dentry *dentry,
|
||||
const char *name, const void *buffer, size_t size, int flags)
|
||||
{
|
||||
if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
|
||||
return -EINVAL;
|
||||
|
||||
if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(d_inode(dentry)))
|
||||
return -EPERM;
|
||||
|
||||
return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags);
|
||||
return reiserfs_xattr_set(d_inode(dentry),
|
||||
xattr_full_name(handler, name),
|
||||
buffer, size, flags);
|
||||
}
|
||||
|
||||
static bool trusted_list(struct dentry *dentry)
|
||||
|
|
|
@ -10,24 +10,22 @@ static int
|
|||
user_get(const struct xattr_handler *handler, struct dentry *dentry,
|
||||
const char *name, void *buffer, size_t size)
|
||||
{
|
||||
|
||||
if (strlen(name) < sizeof(XATTR_USER_PREFIX))
|
||||
return -EINVAL;
|
||||
if (!reiserfs_xattrs_user(dentry->d_sb))
|
||||
return -EOPNOTSUPP;
|
||||
return reiserfs_xattr_get(d_inode(dentry), name, buffer, size);
|
||||
return reiserfs_xattr_get(d_inode(dentry),
|
||||
xattr_full_name(handler, name),
|
||||
buffer, size);
|
||||
}
|
||||
|
||||
static int
|
||||
user_set(const struct xattr_handler *handler, struct dentry *dentry,
|
||||
const char *name, const void *buffer, size_t size, int flags)
|
||||
{
|
||||
if (strlen(name) < sizeof(XATTR_USER_PREFIX))
|
||||
return -EINVAL;
|
||||
|
||||
if (!reiserfs_xattrs_user(dentry->d_sb))
|
||||
return -EOPNOTSUPP;
|
||||
return reiserfs_xattr_set(d_inode(dentry), name, buffer, size, flags);
|
||||
return reiserfs_xattr_set(d_inode(dentry),
|
||||
xattr_full_name(handler, name),
|
||||
buffer, size, flags);
|
||||
}
|
||||
|
||||
static bool user_list(struct dentry *dentry)
|
||||
|
|
Загрузка…
Ссылка в новой задаче