xfs_xattr.c (5a3930e27ef95893f039b9ec127a48139fcc8ca5) xfs_xattr.c (d5f0f49a9bdd4206e941282dfd323c436331659b)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2008 Christoph Hellwig.
4 * Portions Copyright (C) 2000-2008 Silicon Graphics, Inc.
5 */
6
7#include "xfs.h"
8#include "xfs_shared.h"
9#include "xfs_format.h"
10#include "xfs_log_format.h"
11#include "xfs_da_format.h"
12#include "xfs_inode.h"
13#include "xfs_attr.h"
14#include "xfs_acl.h"
15#include "xfs_da_format.h"
16#include "xfs_da_btree.h"
17
18#include <linux/posix_acl_xattr.h>
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2008 Christoph Hellwig.
4 * Portions Copyright (C) 2000-2008 Silicon Graphics, Inc.
5 */
6
7#include "xfs.h"
8#include "xfs_shared.h"
9#include "xfs_format.h"
10#include "xfs_log_format.h"
11#include "xfs_da_format.h"
12#include "xfs_inode.h"
13#include "xfs_attr.h"
14#include "xfs_acl.h"
15#include "xfs_da_format.h"
16#include "xfs_da_btree.h"
17
18#include <linux/posix_acl_xattr.h>
19#include <linux/xattr.h>
20
21
22static int
23xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused,
24 struct inode *inode, const char *name, void *value, size_t size)
25{
26 struct xfs_da_args args = {
27 .dp = XFS_I(inode),
19
20
21static int
22xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused,
23 struct inode *inode, const char *name, void *value, size_t size)
24{
25 struct xfs_da_args args = {
26 .dp = XFS_I(inode),
28 .flags = handler->flags,
27 .attr_filter = handler->flags,
29 .name = name,
30 .namelen = strlen(name),
31 .value = value,
32 .valuelen = size,
33 };
34 int error;
35
36 error = xfs_attr_get(&args);

--- 4 unchanged lines hidden (view full) ---

41
42static int
43xfs_xattr_set(const struct xattr_handler *handler, struct dentry *unused,
44 struct inode *inode, const char *name, const void *value,
45 size_t size, int flags)
46{
47 struct xfs_da_args args = {
48 .dp = XFS_I(inode),
28 .name = name,
29 .namelen = strlen(name),
30 .value = value,
31 .valuelen = size,
32 };
33 int error;
34
35 error = xfs_attr_get(&args);

--- 4 unchanged lines hidden (view full) ---

40
41static int
42xfs_xattr_set(const struct xattr_handler *handler, struct dentry *unused,
43 struct inode *inode, const char *name, const void *value,
44 size_t size, int flags)
45{
46 struct xfs_da_args args = {
47 .dp = XFS_I(inode),
49 .flags = handler->flags,
48 .attr_filter = handler->flags,
49 .attr_flags = flags,
50 .name = name,
51 .namelen = strlen(name),
52 .value = (void *)value,
53 .valuelen = size,
54 };
55 int error;
56
50 .name = name,
51 .namelen = strlen(name),
52 .value = (void *)value,
53 .valuelen = size,
54 };
55 int error;
56
57 /* Convert Linux syscall to XFS internal ATTR flags */
58 if (flags & XATTR_CREATE)
59 args.flags |= ATTR_CREATE;
60 if (flags & XATTR_REPLACE)
61 args.flags |= ATTR_REPLACE;
62
63 error = xfs_attr_set(&args);
57 error = xfs_attr_set(&args);
64 if (!error && (handler->flags & ATTR_ROOT))
58 if (!error && (handler->flags & XFS_ATTR_ROOT))
65 xfs_forget_acl(inode, name);
66 return error;
67}
68
69static const struct xattr_handler xfs_xattr_user_handler = {
70 .prefix = XATTR_USER_PREFIX,
71 .flags = 0, /* no flags implies user namespace */
72 .get = xfs_xattr_get,
73 .set = xfs_xattr_set,
74};
75
76static const struct xattr_handler xfs_xattr_trusted_handler = {
77 .prefix = XATTR_TRUSTED_PREFIX,
59 xfs_forget_acl(inode, name);
60 return error;
61}
62
63static const struct xattr_handler xfs_xattr_user_handler = {
64 .prefix = XATTR_USER_PREFIX,
65 .flags = 0, /* no flags implies user namespace */
66 .get = xfs_xattr_get,
67 .set = xfs_xattr_set,
68};
69
70static const struct xattr_handler xfs_xattr_trusted_handler = {
71 .prefix = XATTR_TRUSTED_PREFIX,
78 .flags = ATTR_ROOT,
72 .flags = XFS_ATTR_ROOT,
79 .get = xfs_xattr_get,
80 .set = xfs_xattr_set,
81};
82
83static const struct xattr_handler xfs_xattr_security_handler = {
84 .prefix = XATTR_SECURITY_PREFIX,
73 .get = xfs_xattr_get,
74 .set = xfs_xattr_set,
75};
76
77static const struct xattr_handler xfs_xattr_security_handler = {
78 .prefix = XATTR_SECURITY_PREFIX,
85 .flags = ATTR_SECURE,
79 .flags = XFS_ATTR_SECURE,
86 .get = xfs_xattr_get,
87 .set = xfs_xattr_set,
88};
89
90const struct xattr_handler *xfs_xattr_handlers[] = {
91 &xfs_xattr_user_handler,
92 &xfs_xattr_trusted_handler,
93 &xfs_xattr_security_handler,

--- 129 unchanged lines hidden ---
80 .get = xfs_xattr_get,
81 .set = xfs_xattr_set,
82};
83
84const struct xattr_handler *xfs_xattr_handlers[] = {
85 &xfs_xattr_user_handler,
86 &xfs_xattr_trusted_handler,
87 &xfs_xattr_security_handler,

--- 129 unchanged lines hidden ---