Skip to content

Commit

Permalink
xattr handlers: Pass handler to operations instead of flags
Browse files Browse the repository at this point in the history
The xattr_handler operations are currently all passed a file system
specific flags value which the operations can use to disambiguate between
different handlers; some file systems use that to distinguish the xattr
namespace, for example.  In some oprations, it would be useful to also have
access to the handler prefix.  To allow that, pass a pointer to the handler
to operations instead of the flags value alone.

Signed-off-by: Andreas Gruenbacher <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Andreas Gruenbacher authored and Al Viro committed Nov 14, 2015
1 parent bf78171 commit d9a82a0
Show file tree
Hide file tree
Showing 32 changed files with 306 additions and 226 deletions.
18 changes: 10 additions & 8 deletions fs/9p/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,13 @@ static int v9fs_remote_get_acl(struct dentry *dentry, const char *name,
return v9fs_xattr_get(dentry, full_name, buffer, size);
}

static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name,
void *buffer, size_t size, int type)
static int v9fs_xattr_get_acl(const struct xattr_handler *handler,
struct dentry *dentry, const char *name,
void *buffer, size_t size)
{
struct v9fs_session_info *v9ses;
struct posix_acl *acl;
int type = handler->flags;
int error;

if (strcmp(name, "") != 0)
Expand Down Expand Up @@ -278,9 +280,9 @@ static int v9fs_remote_set_acl(struct dentry *dentry, const char *name,
}


static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
const void *value, size_t size,
int flags, int type)
static int v9fs_xattr_set_acl(const struct xattr_handler *handler,
struct dentry *dentry, const char *name,
const void *value, size_t size, int flags)
{
int retval;
struct posix_acl *acl;
Expand All @@ -297,7 +299,7 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
*/
if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT)
return v9fs_remote_set_acl(dentry, name,
value, size, flags, type);
value, size, flags, handler->flags);

if (S_ISLNK(inode->i_mode))
return -EOPNOTSUPP;
Expand All @@ -316,7 +318,7 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
} else
acl = NULL;

switch (type) {
switch (handler->flags) {
case ACL_TYPE_ACCESS:
name = POSIX_ACL_XATTR_ACCESS;
if (acl) {
Expand Down Expand Up @@ -360,7 +362,7 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
}
retval = v9fs_xattr_set(dentry, name, value, size, flags);
if (!retval)
set_cached_acl(inode, type, acl);
set_cached_acl(inode, handler->flags, acl);
err_out:
posix_acl_release(acl);
return retval;
Expand Down
10 changes: 6 additions & 4 deletions fs/9p/xattr_security.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
#include <linux/slab.h>
#include "xattr.h"

static int v9fs_xattr_security_get(struct dentry *dentry, const char *name,
void *buffer, size_t size, int type)
static int v9fs_xattr_security_get(const struct xattr_handler *handler,
struct dentry *dentry, const char *name,
void *buffer, size_t size)
{
int retval;
char *full_name;
Expand All @@ -46,8 +47,9 @@ static int v9fs_xattr_security_get(struct dentry *dentry, const char *name,
return retval;
}

static int v9fs_xattr_security_set(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags, int type)
static int v9fs_xattr_security_set(const struct xattr_handler *handler,
struct dentry *dentry, const char *name,
const void *value, size_t size, int flags)
{
int retval;
char *full_name;
Expand Down
10 changes: 6 additions & 4 deletions fs/9p/xattr_trusted.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
#include <linux/slab.h>
#include "xattr.h"

static int v9fs_xattr_trusted_get(struct dentry *dentry, const char *name,
void *buffer, size_t size, int type)
static int v9fs_xattr_trusted_get(const struct xattr_handler *handler,
struct dentry *dentry, const char *name,
void *buffer, size_t size)
{
int retval;
char *full_name;
Expand All @@ -46,8 +47,9 @@ static int v9fs_xattr_trusted_get(struct dentry *dentry, const char *name,
return retval;
}

static int v9fs_xattr_trusted_set(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags, int type)
static int v9fs_xattr_trusted_set(const struct xattr_handler *handler,
struct dentry *dentry, const char *name,
const void *value, size_t size, int flags)
{
int retval;
char *full_name;
Expand Down
10 changes: 6 additions & 4 deletions fs/9p/xattr_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
#include <linux/slab.h>
#include "xattr.h"

static int v9fs_xattr_user_get(struct dentry *dentry, const char *name,
void *buffer, size_t size, int type)
static int v9fs_xattr_user_get(const struct xattr_handler *handler,
struct dentry *dentry, const char *name,
void *buffer, size_t size)
{
int retval;
char *full_name;
Expand All @@ -46,8 +47,9 @@ static int v9fs_xattr_user_get(struct dentry *dentry, const char *name,
return retval;
}

static int v9fs_xattr_user_set(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags, int type)
static int v9fs_xattr_user_set(const struct xattr_handler *handler,
struct dentry *dentry, const char *name,
const void *value, size_t size, int flags)
{
int retval;
char *full_name;
Expand Down
7 changes: 3 additions & 4 deletions fs/ext2/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,9 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
ext2_xattr_handler(entry->e_name_index);

if (handler) {
size_t size = handler->list(dentry, buffer, rest,
entry->e_name,
entry->e_name_len,
handler->flags);
size_t size = handler->list(handler, dentry, buffer,
rest, entry->e_name,
entry->e_name_len);
if (buffer) {
if (size > rest) {
error = -ERANGE;
Expand Down
15 changes: 9 additions & 6 deletions fs/ext2/xattr_security.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
#include "xattr.h"

static size_t
ext2_xattr_security_list(struct dentry *dentry, char *list, size_t list_size,
const char *name, size_t name_len, int type)
ext2_xattr_security_list(const struct xattr_handler *handler,
struct dentry *dentry, char *list, size_t list_size,
const char *name, size_t name_len)
{
const int prefix_len = XATTR_SECURITY_PREFIX_LEN;
const size_t total_len = prefix_len + name_len + 1;
Expand All @@ -23,8 +24,9 @@ ext2_xattr_security_list(struct dentry *dentry, char *list, size_t list_size,
}

static int
ext2_xattr_security_get(struct dentry *dentry, const char *name,
void *buffer, size_t size, int type)
ext2_xattr_security_get(const struct xattr_handler *handler,
struct dentry *dentry, const char *name,
void *buffer, size_t size)
{
if (strcmp(name, "") == 0)
return -EINVAL;
Expand All @@ -33,8 +35,9 @@ ext2_xattr_security_get(struct dentry *dentry, const char *name,
}

static int
ext2_xattr_security_set(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags, int type)
ext2_xattr_security_set(const struct xattr_handler *handler,
struct dentry *dentry, const char *name,
const void *value, size_t size, int flags)
{
if (strcmp(name, "") == 0)
return -EINVAL;
Expand Down
15 changes: 9 additions & 6 deletions fs/ext2/xattr_trusted.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#include "xattr.h"

static size_t
ext2_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size,
const char *name, size_t name_len, int type)
ext2_xattr_trusted_list(const struct xattr_handler *handler,
struct dentry *dentry, char *list, size_t list_size,
const char *name, size_t name_len)
{
const int prefix_len = XATTR_TRUSTED_PREFIX_LEN;
const size_t total_len = prefix_len + name_len + 1;
Expand All @@ -27,8 +28,9 @@ ext2_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size,
}

static int
ext2_xattr_trusted_get(struct dentry *dentry, const char *name,
void *buffer, size_t size, int type)
ext2_xattr_trusted_get(const struct xattr_handler *handler,
struct dentry *dentry, const char *name,
void *buffer, size_t size)
{
if (strcmp(name, "") == 0)
return -EINVAL;
Expand All @@ -37,8 +39,9 @@ ext2_xattr_trusted_get(struct dentry *dentry, const char *name,
}

static int
ext2_xattr_trusted_set(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags, int type)
ext2_xattr_trusted_set(const struct xattr_handler *handler,
struct dentry *dentry, const char *name,
const void *value, size_t size, int flags)
{
if (strcmp(name, "") == 0)
return -EINVAL;
Expand Down
15 changes: 9 additions & 6 deletions fs/ext2/xattr_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
#include "xattr.h"

static size_t
ext2_xattr_user_list(struct dentry *dentry, char *list, size_t list_size,
const char *name, size_t name_len, int type)
ext2_xattr_user_list(const struct xattr_handler *handler,
struct dentry *dentry, char *list, size_t list_size,
const char *name, size_t name_len)
{
const size_t prefix_len = XATTR_USER_PREFIX_LEN;
const size_t total_len = prefix_len + name_len + 1;
Expand All @@ -29,8 +30,9 @@ ext2_xattr_user_list(struct dentry *dentry, char *list, size_t list_size,
}

static int
ext2_xattr_user_get(struct dentry *dentry, const char *name,
void *buffer, size_t size, int type)
ext2_xattr_user_get(const struct xattr_handler *handler,
struct dentry *dentry, const char *name,
void *buffer, size_t size)
{
if (strcmp(name, "") == 0)
return -EINVAL;
Expand All @@ -41,8 +43,9 @@ ext2_xattr_user_get(struct dentry *dentry, const char *name,
}

static int
ext2_xattr_user_set(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags, int type)
ext2_xattr_user_set(const struct xattr_handler *handler,
struct dentry *dentry, const char *name,
const void *value, size_t size, int flags)
{
if (strcmp(name, "") == 0)
return -EINVAL;
Expand Down
7 changes: 3 additions & 4 deletions fs/ext4/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,9 @@ ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
ext4_xattr_handler(entry->e_name_index);

if (handler) {
size_t size = handler->list(dentry, buffer, rest,
entry->e_name,
entry->e_name_len,
handler->flags);
size_t size = handler->list(handler, dentry, buffer,
rest, entry->e_name,
entry->e_name_len);
if (buffer) {
if (size > rest)
return -ERANGE;
Expand Down
15 changes: 9 additions & 6 deletions fs/ext4/xattr_security.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
#include "xattr.h"

static size_t
ext4_xattr_security_list(struct dentry *dentry, char *list, size_t list_size,
const char *name, size_t name_len, int type)
ext4_xattr_security_list(const struct xattr_handler *handler,
struct dentry *dentry, char *list, size_t list_size,
const char *name, size_t name_len)
{
const size_t prefix_len = sizeof(XATTR_SECURITY_PREFIX)-1;
const size_t total_len = prefix_len + name_len + 1;
Expand All @@ -28,8 +29,9 @@ ext4_xattr_security_list(struct dentry *dentry, char *list, size_t list_size,
}

static int
ext4_xattr_security_get(struct dentry *dentry, const char *name,
void *buffer, size_t size, int type)
ext4_xattr_security_get(const struct xattr_handler *handler,
struct dentry *dentry, const char *name,
void *buffer, size_t size)
{
if (strcmp(name, "") == 0)
return -EINVAL;
Expand All @@ -38,8 +40,9 @@ ext4_xattr_security_get(struct dentry *dentry, const char *name,
}

static int
ext4_xattr_security_set(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags, int type)
ext4_xattr_security_set(const struct xattr_handler *handler,
struct dentry *dentry, const char *name,
const void *value, size_t size, int flags)
{
if (strcmp(name, "") == 0)
return -EINVAL;
Expand Down
15 changes: 9 additions & 6 deletions fs/ext4/xattr_trusted.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
#include "xattr.h"

static size_t
ext4_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size,
const char *name, size_t name_len, int type)
ext4_xattr_trusted_list(const struct xattr_handler *handler,
struct dentry *dentry, char *list, size_t list_size,
const char *name, size_t name_len)
{
const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN;
const size_t total_len = prefix_len + name_len + 1;
Expand All @@ -31,8 +32,9 @@ ext4_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size,
}

static int
ext4_xattr_trusted_get(struct dentry *dentry, const char *name, void *buffer,
size_t size, int type)
ext4_xattr_trusted_get(const struct xattr_handler *handler,
struct dentry *dentry, const char *name, void *buffer,
size_t size)
{
if (strcmp(name, "") == 0)
return -EINVAL;
Expand All @@ -41,8 +43,9 @@ ext4_xattr_trusted_get(struct dentry *dentry, const char *name, void *buffer,
}

static int
ext4_xattr_trusted_set(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags, int type)
ext4_xattr_trusted_set(const struct xattr_handler *handler,
struct dentry *dentry, const char *name,
const void *value, size_t size, int flags)
{
if (strcmp(name, "") == 0)
return -EINVAL;
Expand Down
15 changes: 9 additions & 6 deletions fs/ext4/xattr_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
#include "xattr.h"

static size_t
ext4_xattr_user_list(struct dentry *dentry, char *list, size_t list_size,
const char *name, size_t name_len, int type)
ext4_xattr_user_list(const struct xattr_handler *handler,
struct dentry *dentry, char *list, size_t list_size,
const char *name, size_t name_len)
{
const size_t prefix_len = XATTR_USER_PREFIX_LEN;
const size_t total_len = prefix_len + name_len + 1;
Expand All @@ -30,8 +31,9 @@ ext4_xattr_user_list(struct dentry *dentry, char *list, size_t list_size,
}

static int
ext4_xattr_user_get(struct dentry *dentry, const char *name,
void *buffer, size_t size, int type)
ext4_xattr_user_get(const struct xattr_handler *handler,
struct dentry *dentry, const char *name,
void *buffer, size_t size)
{
if (strcmp(name, "") == 0)
return -EINVAL;
Expand All @@ -42,8 +44,9 @@ ext4_xattr_user_get(struct dentry *dentry, const char *name,
}

static int
ext4_xattr_user_set(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags, int type)
ext4_xattr_user_set(const struct xattr_handler *handler,
struct dentry *dentry, const char *name,
const void *value, size_t size, int flags)
{
if (strcmp(name, "") == 0)
return -EINVAL;
Expand Down
Loading

0 comments on commit d9a82a0

Please sign in to comment.