Skip to content

Commit d9a82a0

Browse files
Andreas GruenbacherAl Viro
Andreas Gruenbacher
authored and
Al Viro
committed
xattr handlers: Pass handler to operations instead of flags
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 <agruenba@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent bf78171 commit d9a82a0

32 files changed

+306
-226
lines changed

fs/9p/acl.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,13 @@ static int v9fs_remote_get_acl(struct dentry *dentry, const char *name,
230230
return v9fs_xattr_get(dentry, full_name, buffer, size);
231231
}
232232

233-
static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name,
234-
void *buffer, size_t size, int type)
233+
static int v9fs_xattr_get_acl(const struct xattr_handler *handler,
234+
struct dentry *dentry, const char *name,
235+
void *buffer, size_t size)
235236
{
236237
struct v9fs_session_info *v9ses;
237238
struct posix_acl *acl;
239+
int type = handler->flags;
238240
int error;
239241

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

280282

281-
static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
282-
const void *value, size_t size,
283-
int flags, int type)
283+
static int v9fs_xattr_set_acl(const struct xattr_handler *handler,
284+
struct dentry *dentry, const char *name,
285+
const void *value, size_t size, int flags)
284286
{
285287
int retval;
286288
struct posix_acl *acl;
@@ -297,7 +299,7 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
297299
*/
298300
if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT)
299301
return v9fs_remote_set_acl(dentry, name,
300-
value, size, flags, type);
302+
value, size, flags, handler->flags);
301303

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

319-
switch (type) {
321+
switch (handler->flags) {
320322
case ACL_TYPE_ACCESS:
321323
name = POSIX_ACL_XATTR_ACCESS;
322324
if (acl) {
@@ -360,7 +362,7 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
360362
}
361363
retval = v9fs_xattr_set(dentry, name, value, size, flags);
362364
if (!retval)
363-
set_cached_acl(inode, type, acl);
365+
set_cached_acl(inode, handler->flags, acl);
364366
err_out:
365367
posix_acl_release(acl);
366368
return retval;

fs/9p/xattr_security.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
#include <linux/slab.h>
2020
#include "xattr.h"
2121

22-
static int v9fs_xattr_security_get(struct dentry *dentry, const char *name,
23-
void *buffer, size_t size, int type)
22+
static int v9fs_xattr_security_get(const struct xattr_handler *handler,
23+
struct dentry *dentry, const char *name,
24+
void *buffer, size_t size)
2425
{
2526
int retval;
2627
char *full_name;
@@ -46,8 +47,9 @@ static int v9fs_xattr_security_get(struct dentry *dentry, const char *name,
4647
return retval;
4748
}
4849

49-
static int v9fs_xattr_security_set(struct dentry *dentry, const char *name,
50-
const void *value, size_t size, int flags, int type)
50+
static int v9fs_xattr_security_set(const struct xattr_handler *handler,
51+
struct dentry *dentry, const char *name,
52+
const void *value, size_t size, int flags)
5153
{
5254
int retval;
5355
char *full_name;

fs/9p/xattr_trusted.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
#include <linux/slab.h>
2020
#include "xattr.h"
2121

22-
static int v9fs_xattr_trusted_get(struct dentry *dentry, const char *name,
23-
void *buffer, size_t size, int type)
22+
static int v9fs_xattr_trusted_get(const struct xattr_handler *handler,
23+
struct dentry *dentry, const char *name,
24+
void *buffer, size_t size)
2425
{
2526
int retval;
2627
char *full_name;
@@ -46,8 +47,9 @@ static int v9fs_xattr_trusted_get(struct dentry *dentry, const char *name,
4647
return retval;
4748
}
4849

49-
static int v9fs_xattr_trusted_set(struct dentry *dentry, const char *name,
50-
const void *value, size_t size, int flags, int type)
50+
static int v9fs_xattr_trusted_set(const struct xattr_handler *handler,
51+
struct dentry *dentry, const char *name,
52+
const void *value, size_t size, int flags)
5153
{
5254
int retval;
5355
char *full_name;

fs/9p/xattr_user.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
#include <linux/slab.h>
2020
#include "xattr.h"
2121

22-
static int v9fs_xattr_user_get(struct dentry *dentry, const char *name,
23-
void *buffer, size_t size, int type)
22+
static int v9fs_xattr_user_get(const struct xattr_handler *handler,
23+
struct dentry *dentry, const char *name,
24+
void *buffer, size_t size)
2425
{
2526
int retval;
2627
char *full_name;
@@ -46,8 +47,9 @@ static int v9fs_xattr_user_get(struct dentry *dentry, const char *name,
4647
return retval;
4748
}
4849

49-
static int v9fs_xattr_user_set(struct dentry *dentry, const char *name,
50-
const void *value, size_t size, int flags, int type)
50+
static int v9fs_xattr_user_set(const struct xattr_handler *handler,
51+
struct dentry *dentry, const char *name,
52+
const void *value, size_t size, int flags)
5153
{
5254
int retval;
5355
char *full_name;

fs/ext2/xattr.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,9 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
293293
ext2_xattr_handler(entry->e_name_index);
294294

295295
if (handler) {
296-
size_t size = handler->list(dentry, buffer, rest,
297-
entry->e_name,
298-
entry->e_name_len,
299-
handler->flags);
296+
size_t size = handler->list(handler, dentry, buffer,
297+
rest, entry->e_name,
298+
entry->e_name_len);
300299
if (buffer) {
301300
if (size > rest) {
302301
error = -ERANGE;

fs/ext2/xattr_security.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
#include "xattr.h"
99

1010
static size_t
11-
ext2_xattr_security_list(struct dentry *dentry, char *list, size_t list_size,
12-
const char *name, size_t name_len, int type)
11+
ext2_xattr_security_list(const struct xattr_handler *handler,
12+
struct dentry *dentry, char *list, size_t list_size,
13+
const char *name, size_t name_len)
1314
{
1415
const int prefix_len = XATTR_SECURITY_PREFIX_LEN;
1516
const size_t total_len = prefix_len + name_len + 1;
@@ -23,8 +24,9 @@ ext2_xattr_security_list(struct dentry *dentry, char *list, size_t list_size,
2324
}
2425

2526
static int
26-
ext2_xattr_security_get(struct dentry *dentry, const char *name,
27-
void *buffer, size_t size, int type)
27+
ext2_xattr_security_get(const struct xattr_handler *handler,
28+
struct dentry *dentry, const char *name,
29+
void *buffer, size_t size)
2830
{
2931
if (strcmp(name, "") == 0)
3032
return -EINVAL;
@@ -33,8 +35,9 @@ ext2_xattr_security_get(struct dentry *dentry, const char *name,
3335
}
3436

3537
static int
36-
ext2_xattr_security_set(struct dentry *dentry, const char *name,
37-
const void *value, size_t size, int flags, int type)
38+
ext2_xattr_security_set(const struct xattr_handler *handler,
39+
struct dentry *dentry, const char *name,
40+
const void *value, size_t size, int flags)
3841
{
3942
if (strcmp(name, "") == 0)
4043
return -EINVAL;

fs/ext2/xattr_trusted.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
#include "xattr.h"
1010

1111
static size_t
12-
ext2_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size,
13-
const char *name, size_t name_len, int type)
12+
ext2_xattr_trusted_list(const struct xattr_handler *handler,
13+
struct dentry *dentry, char *list, size_t list_size,
14+
const char *name, size_t name_len)
1415
{
1516
const int prefix_len = XATTR_TRUSTED_PREFIX_LEN;
1617
const size_t total_len = prefix_len + name_len + 1;
@@ -27,8 +28,9 @@ ext2_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size,
2728
}
2829

2930
static int
30-
ext2_xattr_trusted_get(struct dentry *dentry, const char *name,
31-
void *buffer, size_t size, int type)
31+
ext2_xattr_trusted_get(const struct xattr_handler *handler,
32+
struct dentry *dentry, const char *name,
33+
void *buffer, size_t size)
3234
{
3335
if (strcmp(name, "") == 0)
3436
return -EINVAL;
@@ -37,8 +39,9 @@ ext2_xattr_trusted_get(struct dentry *dentry, const char *name,
3739
}
3840

3941
static int
40-
ext2_xattr_trusted_set(struct dentry *dentry, const char *name,
41-
const void *value, size_t size, int flags, int type)
42+
ext2_xattr_trusted_set(const struct xattr_handler *handler,
43+
struct dentry *dentry, const char *name,
44+
const void *value, size_t size, int flags)
4245
{
4346
if (strcmp(name, "") == 0)
4447
return -EINVAL;

fs/ext2/xattr_user.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
#include "xattr.h"
1212

1313
static size_t
14-
ext2_xattr_user_list(struct dentry *dentry, char *list, size_t list_size,
15-
const char *name, size_t name_len, int type)
14+
ext2_xattr_user_list(const struct xattr_handler *handler,
15+
struct dentry *dentry, char *list, size_t list_size,
16+
const char *name, size_t name_len)
1617
{
1718
const size_t prefix_len = XATTR_USER_PREFIX_LEN;
1819
const size_t total_len = prefix_len + name_len + 1;
@@ -29,8 +30,9 @@ ext2_xattr_user_list(struct dentry *dentry, char *list, size_t list_size,
2930
}
3031

3132
static int
32-
ext2_xattr_user_get(struct dentry *dentry, const char *name,
33-
void *buffer, size_t size, int type)
33+
ext2_xattr_user_get(const struct xattr_handler *handler,
34+
struct dentry *dentry, const char *name,
35+
void *buffer, size_t size)
3436
{
3537
if (strcmp(name, "") == 0)
3638
return -EINVAL;
@@ -41,8 +43,9 @@ ext2_xattr_user_get(struct dentry *dentry, const char *name,
4143
}
4244

4345
static int
44-
ext2_xattr_user_set(struct dentry *dentry, const char *name,
45-
const void *value, size_t size, int flags, int type)
46+
ext2_xattr_user_set(const struct xattr_handler *handler,
47+
struct dentry *dentry, const char *name,
48+
const void *value, size_t size, int flags)
4649
{
4750
if (strcmp(name, "") == 0)
4851
return -EINVAL;

fs/ext4/xattr.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,10 +405,9 @@ ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
405405
ext4_xattr_handler(entry->e_name_index);
406406

407407
if (handler) {
408-
size_t size = handler->list(dentry, buffer, rest,
409-
entry->e_name,
410-
entry->e_name_len,
411-
handler->flags);
408+
size_t size = handler->list(handler, dentry, buffer,
409+
rest, entry->e_name,
410+
entry->e_name_len);
412411
if (buffer) {
413412
if (size > rest)
414413
return -ERANGE;

fs/ext4/xattr_security.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
#include "xattr.h"
1313

1414
static size_t
15-
ext4_xattr_security_list(struct dentry *dentry, char *list, size_t list_size,
16-
const char *name, size_t name_len, int type)
15+
ext4_xattr_security_list(const struct xattr_handler *handler,
16+
struct dentry *dentry, char *list, size_t list_size,
17+
const char *name, size_t name_len)
1718
{
1819
const size_t prefix_len = sizeof(XATTR_SECURITY_PREFIX)-1;
1920
const size_t total_len = prefix_len + name_len + 1;
@@ -28,8 +29,9 @@ ext4_xattr_security_list(struct dentry *dentry, char *list, size_t list_size,
2829
}
2930

3031
static int
31-
ext4_xattr_security_get(struct dentry *dentry, const char *name,
32-
void *buffer, size_t size, int type)
32+
ext4_xattr_security_get(const struct xattr_handler *handler,
33+
struct dentry *dentry, const char *name,
34+
void *buffer, size_t size)
3335
{
3436
if (strcmp(name, "") == 0)
3537
return -EINVAL;
@@ -38,8 +40,9 @@ ext4_xattr_security_get(struct dentry *dentry, const char *name,
3840
}
3941

4042
static int
41-
ext4_xattr_security_set(struct dentry *dentry, const char *name,
42-
const void *value, size_t size, int flags, int type)
43+
ext4_xattr_security_set(const struct xattr_handler *handler,
44+
struct dentry *dentry, const char *name,
45+
const void *value, size_t size, int flags)
4346
{
4447
if (strcmp(name, "") == 0)
4548
return -EINVAL;

fs/ext4/xattr_trusted.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
#include "xattr.h"
1414

1515
static size_t
16-
ext4_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size,
17-
const char *name, size_t name_len, int type)
16+
ext4_xattr_trusted_list(const struct xattr_handler *handler,
17+
struct dentry *dentry, char *list, size_t list_size,
18+
const char *name, size_t name_len)
1819
{
1920
const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN;
2021
const size_t total_len = prefix_len + name_len + 1;
@@ -31,8 +32,9 @@ ext4_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size,
3132
}
3233

3334
static int
34-
ext4_xattr_trusted_get(struct dentry *dentry, const char *name, void *buffer,
35-
size_t size, int type)
35+
ext4_xattr_trusted_get(const struct xattr_handler *handler,
36+
struct dentry *dentry, const char *name, void *buffer,
37+
size_t size)
3638
{
3739
if (strcmp(name, "") == 0)
3840
return -EINVAL;
@@ -41,8 +43,9 @@ ext4_xattr_trusted_get(struct dentry *dentry, const char *name, void *buffer,
4143
}
4244

4345
static int
44-
ext4_xattr_trusted_set(struct dentry *dentry, const char *name,
45-
const void *value, size_t size, int flags, int type)
46+
ext4_xattr_trusted_set(const struct xattr_handler *handler,
47+
struct dentry *dentry, const char *name,
48+
const void *value, size_t size, int flags)
4649
{
4750
if (strcmp(name, "") == 0)
4851
return -EINVAL;

fs/ext4/xattr_user.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
#include "xattr.h"
1313

1414
static size_t
15-
ext4_xattr_user_list(struct dentry *dentry, char *list, size_t list_size,
16-
const char *name, size_t name_len, int type)
15+
ext4_xattr_user_list(const struct xattr_handler *handler,
16+
struct dentry *dentry, char *list, size_t list_size,
17+
const char *name, size_t name_len)
1718
{
1819
const size_t prefix_len = XATTR_USER_PREFIX_LEN;
1920
const size_t total_len = prefix_len + name_len + 1;
@@ -30,8 +31,9 @@ ext4_xattr_user_list(struct dentry *dentry, char *list, size_t list_size,
3031
}
3132

3233
static int
33-
ext4_xattr_user_get(struct dentry *dentry, const char *name,
34-
void *buffer, size_t size, int type)
34+
ext4_xattr_user_get(const struct xattr_handler *handler,
35+
struct dentry *dentry, const char *name,
36+
void *buffer, size_t size)
3537
{
3638
if (strcmp(name, "") == 0)
3739
return -EINVAL;
@@ -42,8 +44,9 @@ ext4_xattr_user_get(struct dentry *dentry, const char *name,
4244
}
4345

4446
static int
45-
ext4_xattr_user_set(struct dentry *dentry, const char *name,
46-
const void *value, size_t size, int flags, int type)
47+
ext4_xattr_user_set(const struct xattr_handler *handler,
48+
struct dentry *dentry, const char *name,
49+
const void *value, size_t size, int flags)
4750
{
4851
if (strcmp(name, "") == 0)
4952
return -EINVAL;

0 commit comments

Comments
 (0)