hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/xfs/xfs_xattr.c
....@@ -5,60 +5,37 @@
55 */
66
77 #include "xfs.h"
8
+#include "xfs_shared.h"
89 #include "xfs_format.h"
910 #include "xfs_log_format.h"
10
-#include "xfs_trans_resv.h"
11
-#include "xfs_mount.h"
1211 #include "xfs_da_format.h"
1312 #include "xfs_inode.h"
1413 #include "xfs_attr.h"
15
-#include "xfs_attr_leaf.h"
1614 #include "xfs_acl.h"
15
+#include "xfs_da_btree.h"
1716
1817 #include <linux/posix_acl_xattr.h>
19
-#include <linux/xattr.h>
2018
2119
2220 static int
2321 xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused,
24
- struct inode *inode, const char *name, void *value, size_t size)
22
+ struct inode *inode, const char *name, void *value, size_t size,
23
+ int flags)
2524 {
26
- int xflags = handler->flags;
27
- struct xfs_inode *ip = XFS_I(inode);
28
- int error, asize = size;
25
+ struct xfs_da_args args = {
26
+ .dp = XFS_I(inode),
27
+ .attr_filter = handler->flags,
28
+ .name = name,
29
+ .namelen = strlen(name),
30
+ .value = value,
31
+ .valuelen = size,
32
+ };
33
+ int error;
2934
30
- /* Convert Linux syscall to XFS internal ATTR flags */
31
- if (!size) {
32
- xflags |= ATTR_KERNOVAL;
33
- value = NULL;
34
- }
35
-
36
- error = xfs_attr_get(ip, (unsigned char *)name, value, &asize, xflags);
35
+ error = xfs_attr_get(&args);
3736 if (error)
3837 return error;
39
- return asize;
40
-}
41
-
42
-void
43
-xfs_forget_acl(
44
- struct inode *inode,
45
- const char *name,
46
- int xflags)
47
-{
48
- /*
49
- * Invalidate any cached ACLs if the user has bypassed the ACL
50
- * interface. We don't validate the content whatsoever so it is caller
51
- * responsibility to provide data in valid format and ensure i_mode is
52
- * consistent.
53
- */
54
- if (xflags & ATTR_ROOT) {
55
-#ifdef CONFIG_XFS_POSIX_ACL
56
- if (!strcmp(name, SGI_ACL_FILE))
57
- forget_cached_acl(inode, ACL_TYPE_ACCESS);
58
- else if (!strcmp(name, SGI_ACL_DEFAULT))
59
- forget_cached_acl(inode, ACL_TYPE_DEFAULT);
60
-#endif
61
- }
38
+ return args.valuelen;
6239 }
6340
6441 static int
....@@ -66,23 +43,20 @@
6643 struct inode *inode, const char *name, const void *value,
6744 size_t size, int flags)
6845 {
69
- int xflags = handler->flags;
70
- struct xfs_inode *ip = XFS_I(inode);
46
+ struct xfs_da_args args = {
47
+ .dp = XFS_I(inode),
48
+ .attr_filter = handler->flags,
49
+ .attr_flags = flags,
50
+ .name = name,
51
+ .namelen = strlen(name),
52
+ .value = (void *)value,
53
+ .valuelen = size,
54
+ };
7155 int error;
7256
73
- /* Convert Linux syscall to XFS internal ATTR flags */
74
- if (flags & XATTR_CREATE)
75
- xflags |= ATTR_CREATE;
76
- if (flags & XATTR_REPLACE)
77
- xflags |= ATTR_REPLACE;
78
-
79
- if (!value)
80
- return xfs_attr_remove(ip, (unsigned char *)name, xflags);
81
- error = xfs_attr_set(ip, (unsigned char *)name,
82
- (void *)value, size, xflags);
83
- if (!error)
84
- xfs_forget_acl(inode, name, xflags);
85
-
57
+ error = xfs_attr_set(&args);
58
+ if (!error && (handler->flags & XFS_ATTR_ROOT))
59
+ xfs_forget_acl(inode, name);
8660 return error;
8761 }
8862
....@@ -95,14 +69,14 @@
9569
9670 static const struct xattr_handler xfs_xattr_trusted_handler = {
9771 .prefix = XATTR_TRUSTED_PREFIX,
98
- .flags = ATTR_ROOT,
72
+ .flags = XFS_ATTR_ROOT,
9973 .get = xfs_xattr_get,
10074 .set = xfs_xattr_set,
10175 };
10276
10377 static const struct xattr_handler xfs_xattr_security_handler = {
10478 .prefix = XATTR_SECURITY_PREFIX,
105
- .flags = ATTR_SECURE,
79
+ .flags = XFS_ATTR_SECURE,
10680 .get = xfs_xattr_get,
10781 .set = xfs_xattr_set,
10882 };
....@@ -132,7 +106,7 @@
132106 if (context->count < 0 || context->seen_enough)
133107 return;
134108
135
- if (!context->alist)
109
+ if (!context->buffer)
136110 goto compute_size;
137111
138112 arraytop = context->count + prefix_len + namelen + 1;
....@@ -141,7 +115,7 @@
141115 context->seen_enough = 1;
142116 return;
143117 }
144
- offset = (char *)context->alist + context->count;
118
+ offset = context->buffer + context->count;
145119 strncpy(offset, prefix, prefix_len);
146120 offset += prefix_len;
147121 strncpy(offset, (char *)name, namelen); /* real name */
....@@ -216,7 +190,6 @@
216190 size_t size)
217191 {
218192 struct xfs_attr_list_context context;
219
- struct attrlist_cursor_kern cursor = { 0 };
220193 struct inode *inode = d_inode(dentry);
221194 int error;
222195
....@@ -225,14 +198,13 @@
225198 */
226199 memset(&context, 0, sizeof(context));
227200 context.dp = XFS_I(inode);
228
- context.cursor = &cursor;
229201 context.resynch = 1;
230
- context.alist = size ? data : NULL;
202
+ context.buffer = size ? data : NULL;
231203 context.bufsize = size;
232204 context.firstu = context.bufsize;
233205 context.put_listent = xfs_xattr_put_listent;
234206
235
- error = xfs_attr_list_int(&context);
207
+ error = xfs_attr_list(&context);
236208 if (error)
237209 return error;
238210 if (context.count < 0)