| .. | .. |
|---|
| 5 | 5 | */ |
|---|
| 6 | 6 | |
|---|
| 7 | 7 | #include "xfs.h" |
|---|
| 8 | +#include "xfs_shared.h" |
|---|
| 8 | 9 | #include "xfs_format.h" |
|---|
| 9 | 10 | #include "xfs_log_format.h" |
|---|
| 10 | | -#include "xfs_trans_resv.h" |
|---|
| 11 | | -#include "xfs_mount.h" |
|---|
| 12 | 11 | #include "xfs_da_format.h" |
|---|
| 13 | 12 | #include "xfs_inode.h" |
|---|
| 14 | 13 | #include "xfs_attr.h" |
|---|
| 15 | | -#include "xfs_attr_leaf.h" |
|---|
| 16 | 14 | #include "xfs_acl.h" |
|---|
| 15 | +#include "xfs_da_btree.h" |
|---|
| 17 | 16 | |
|---|
| 18 | 17 | #include <linux/posix_acl_xattr.h> |
|---|
| 19 | | -#include <linux/xattr.h> |
|---|
| 20 | 18 | |
|---|
| 21 | 19 | |
|---|
| 22 | 20 | static int |
|---|
| 23 | 21 | 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) |
|---|
| 25 | 24 | { |
|---|
| 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; |
|---|
| 29 | 34 | |
|---|
| 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); |
|---|
| 37 | 36 | if (error) |
|---|
| 38 | 37 | 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; |
|---|
| 62 | 39 | } |
|---|
| 63 | 40 | |
|---|
| 64 | 41 | static int |
|---|
| .. | .. |
|---|
| 66 | 43 | struct inode *inode, const char *name, const void *value, |
|---|
| 67 | 44 | size_t size, int flags) |
|---|
| 68 | 45 | { |
|---|
| 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 | + }; |
|---|
| 71 | 55 | int error; |
|---|
| 72 | 56 | |
|---|
| 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); |
|---|
| 86 | 60 | return error; |
|---|
| 87 | 61 | } |
|---|
| 88 | 62 | |
|---|
| .. | .. |
|---|
| 95 | 69 | |
|---|
| 96 | 70 | static const struct xattr_handler xfs_xattr_trusted_handler = { |
|---|
| 97 | 71 | .prefix = XATTR_TRUSTED_PREFIX, |
|---|
| 98 | | - .flags = ATTR_ROOT, |
|---|
| 72 | + .flags = XFS_ATTR_ROOT, |
|---|
| 99 | 73 | .get = xfs_xattr_get, |
|---|
| 100 | 74 | .set = xfs_xattr_set, |
|---|
| 101 | 75 | }; |
|---|
| 102 | 76 | |
|---|
| 103 | 77 | static const struct xattr_handler xfs_xattr_security_handler = { |
|---|
| 104 | 78 | .prefix = XATTR_SECURITY_PREFIX, |
|---|
| 105 | | - .flags = ATTR_SECURE, |
|---|
| 79 | + .flags = XFS_ATTR_SECURE, |
|---|
| 106 | 80 | .get = xfs_xattr_get, |
|---|
| 107 | 81 | .set = xfs_xattr_set, |
|---|
| 108 | 82 | }; |
|---|
| .. | .. |
|---|
| 132 | 106 | if (context->count < 0 || context->seen_enough) |
|---|
| 133 | 107 | return; |
|---|
| 134 | 108 | |
|---|
| 135 | | - if (!context->alist) |
|---|
| 109 | + if (!context->buffer) |
|---|
| 136 | 110 | goto compute_size; |
|---|
| 137 | 111 | |
|---|
| 138 | 112 | arraytop = context->count + prefix_len + namelen + 1; |
|---|
| .. | .. |
|---|
| 141 | 115 | context->seen_enough = 1; |
|---|
| 142 | 116 | return; |
|---|
| 143 | 117 | } |
|---|
| 144 | | - offset = (char *)context->alist + context->count; |
|---|
| 118 | + offset = context->buffer + context->count; |
|---|
| 145 | 119 | strncpy(offset, prefix, prefix_len); |
|---|
| 146 | 120 | offset += prefix_len; |
|---|
| 147 | 121 | strncpy(offset, (char *)name, namelen); /* real name */ |
|---|
| .. | .. |
|---|
| 216 | 190 | size_t size) |
|---|
| 217 | 191 | { |
|---|
| 218 | 192 | struct xfs_attr_list_context context; |
|---|
| 219 | | - struct attrlist_cursor_kern cursor = { 0 }; |
|---|
| 220 | 193 | struct inode *inode = d_inode(dentry); |
|---|
| 221 | 194 | int error; |
|---|
| 222 | 195 | |
|---|
| .. | .. |
|---|
| 225 | 198 | */ |
|---|
| 226 | 199 | memset(&context, 0, sizeof(context)); |
|---|
| 227 | 200 | context.dp = XFS_I(inode); |
|---|
| 228 | | - context.cursor = &cursor; |
|---|
| 229 | 201 | context.resynch = 1; |
|---|
| 230 | | - context.alist = size ? data : NULL; |
|---|
| 202 | + context.buffer = size ? data : NULL; |
|---|
| 231 | 203 | context.bufsize = size; |
|---|
| 232 | 204 | context.firstu = context.bufsize; |
|---|
| 233 | 205 | context.put_listent = xfs_xattr_put_listent; |
|---|
| 234 | 206 | |
|---|
| 235 | | - error = xfs_attr_list_int(&context); |
|---|
| 207 | + error = xfs_attr_list(&context); |
|---|
| 236 | 208 | if (error) |
|---|
| 237 | 209 | return error; |
|---|
| 238 | 210 | if (context.count < 0) |
|---|