Lines Matching +full:name +full:- +full:prefix

1 // SPDX-License-Identifier: GPL-2.0
25 bch2_str_hash_update(&ctx, info, &key->type, sizeof(key->type)); in bch2_xattr_hash()
26 bch2_str_hash_update(&ctx, info, key->name.name, key->name.len); in bch2_xattr_hash()
41 &X_SEARCH(x.v->x_type, x.v->x_name, x.v->x_name_len)); in xattr_hash_bkey()
49 return l.v->x_type != r->type || in xattr_cmp_key()
50 l.v->x_name_len != r->name.len || in xattr_cmp_key()
51 memcmp(l.v->x_name, r->name.name, r->name.len); in xattr_cmp_key()
59 return l.v->x_type != r.v->x_type || in xattr_cmp_bkey()
60 l.v->x_name_len != r.v->x_name_len || in xattr_cmp_bkey()
61 memcmp(l.v->x_name, r.v->x_name, r.v->x_name_len); in xattr_cmp_bkey()
77 unsigned val_u64s = xattr_val_u64s(xattr.v->x_name_len, in bch2_xattr_validate()
78 le16_to_cpu(xattr.v->x_val_len)); in bch2_xattr_validate()
87 val_u64s = xattr_val_u64s(xattr.v->x_name_len, in bch2_xattr_validate()
88 le16_to_cpu(xattr.v->x_val_len) + 4); in bch2_xattr_validate()
95 bkey_fsck_err_on(!bch2_xattr_type_to_handler(xattr.v->x_type), in bch2_xattr_validate()
97 "invalid type (%u)", xattr.v->x_type); in bch2_xattr_validate()
99 bkey_fsck_err_on(memchr(xattr.v->x_name, '\0', xattr.v->x_name_len), in bch2_xattr_validate()
101 "xattr name has invalid characters"); in bch2_xattr_validate()
112 handler = bch2_xattr_type_to_handler(xattr.v->x_type); in bch2_xattr_to_text()
113 if (handler && handler->prefix) in bch2_xattr_to_text()
114 prt_printf(out, "%s", handler->prefix); in bch2_xattr_to_text()
116 prt_printf(out, "(type %u)", xattr.v->x_type); in bch2_xattr_to_text()
118 prt_printf(out, "(unknown type %u)", xattr.v->x_type); in bch2_xattr_to_text()
120 unsigned name_len = xattr.v->x_name_len; in bch2_xattr_to_text()
121 unsigned val_len = le16_to_cpu(xattr.v->x_val_len); in bch2_xattr_to_text()
122 unsigned max_name_val_bytes = bkey_val_bytes(xattr.k) - in bch2_xattr_to_text()
125 val_len = min_t(int, val_len, max_name_val_bytes - name_len); in bch2_xattr_to_text()
129 name_len, xattr.v->x_name, in bch2_xattr_to_text()
132 if (xattr.v->x_type == KEY_TYPE_XATTR_INDEX_POSIX_ACL_ACCESS || in bch2_xattr_to_text()
133 xattr.v->x_type == KEY_TYPE_XATTR_INDEX_POSIX_ACL_DEFAULT) { in bch2_xattr_to_text()
136 le16_to_cpu(xattr.v->x_val_len)); in bch2_xattr_to_text()
141 const char *name, void *buffer, size_t size, int type) in bch2_xattr_get_trans() argument
143 struct bch_hash_info hash = bch2_hash_info_init(trans->c, &inode->ei_inode); in bch2_xattr_get_trans()
144 struct xattr_search_key search = X_SEARCH(type, name, strlen(name)); in bch2_xattr_get_trans()
153 ret = le16_to_cpu(xattr.v->x_val_len); in bch2_xattr_get_trans()
156 ret = -ERANGE; in bch2_xattr_get_trans()
167 const char *name, const void *value, size_t size, in bch2_xattr_set() argument
170 struct bch_fs *c = trans->c; in bch2_xattr_set()
179 inode_u->bi_ctime = bch2_current_time(c); in bch2_xattr_set()
189 unsigned namelen = strlen(name); in bch2_xattr_set()
194 return -ERANGE; in bch2_xattr_set()
200 bkey_xattr_init(&xattr->k_i); in bch2_xattr_set()
201 xattr->k.u64s = u64s; in bch2_xattr_set()
202 xattr->v.x_type = type; in bch2_xattr_set()
203 xattr->v.x_name_len = namelen; in bch2_xattr_set()
204 xattr->v.x_val_len = cpu_to_le16(size); in bch2_xattr_set()
205 memcpy(xattr->v.x_name, name, namelen); in bch2_xattr_set()
206 memcpy(xattr_val(&xattr->v), value, size); in bch2_xattr_set()
209 inum, &xattr->k_i, in bch2_xattr_set()
214 X_SEARCH(type, name, strlen(name)); in bch2_xattr_set()
221 ret = flags & XATTR_REPLACE ? -ENODATA : 0; in bch2_xattr_set()
232 static int __bch2_xattr_emit(const char *prefix, in __bch2_xattr_emit() argument
233 const char *name, size_t name_len, in __bch2_xattr_emit() argument
236 const size_t prefix_len = strlen(prefix); in __bch2_xattr_emit()
239 if (buf->buf) { in __bch2_xattr_emit()
240 if (buf->used + total_len > buf->len) in __bch2_xattr_emit()
241 return -ERANGE; in __bch2_xattr_emit()
243 memcpy(buf->buf + buf->used, prefix, prefix_len); in __bch2_xattr_emit()
244 memcpy(buf->buf + buf->used + prefix_len, in __bch2_xattr_emit()
245 name, name_len); in __bch2_xattr_emit()
246 buf->buf[buf->used + prefix_len + name_len] = '\0'; in __bch2_xattr_emit()
249 buf->used += total_len; in __bch2_xattr_emit()
267 const char *prefix; in bch2_xattr_emit() local
269 prefix = bch2_xattr_prefix(xattr->x_type, dentry); in bch2_xattr_emit()
270 if (!prefix) in bch2_xattr_emit()
273 return __bch2_xattr_emit(prefix, xattr->x_name, xattr->x_name_len, buf); in bch2_xattr_emit()
281 const char *prefix = all ? "bcachefs_effective." : "bcachefs."; in bch2_xattr_list_bcachefs() local
292 !(inode->bi_fields_set & (1 << id))) in bch2_xattr_list_bcachefs()
295 ret = __bch2_xattr_emit(prefix, bch2_inode_opts[id], in bch2_xattr_list_bcachefs()
306 struct bch_fs *c = dentry->d_sb->s_fs_info; in bch2_xattr_list()
307 struct bch_inode_info *inode = to_bch_ei(dentry->d_inode); in bch2_xattr_list()
309 u64 offset = 0, inum = inode->ei_inode.bi_inum; in bch2_xattr_list()
315 inode->ei_inum.subvol, 0, k, ({ in bch2_xattr_list()
316 if (k.k->type != KEY_TYPE_xattr) in bch2_xattr_list()
321 bch2_xattr_list_bcachefs(c, &inode->ei_inode, &buf, false) ?: in bch2_xattr_list()
322 bch2_xattr_list_bcachefs(c, &inode->ei_inode, &buf, true); in bch2_xattr_list()
329 const char *name, void *buffer, size_t size) in bch2_xattr_get_handler() argument
332 struct bch_fs *c = inode->v.i_sb->s_fs_info; in bch2_xattr_get_handler()
334 bch2_xattr_get_trans(trans, inode, name, buffer, size, handler->flags)); in bch2_xattr_get_handler()
337 ret = -ENODATA; in bch2_xattr_get_handler()
345 const char *name, const void *value, in bch2_xattr_set_handler() argument
349 struct bch_fs *c = inode->v.i_sb->s_fs_info; in bch2_xattr_set_handler()
350 struct bch_hash_info hash = bch2_hash_info_init(c, &inode->ei_inode); in bch2_xattr_set_handler()
357 &hash, name, value, size, in bch2_xattr_set_handler()
358 handler->flags, flags)) ?: in bch2_xattr_set_handler()
365 .prefix = XATTR_USER_PREFIX,
377 .prefix = XATTR_TRUSTED_PREFIX,
385 .prefix = XATTR_SECURITY_PREFIX,
396 #define x(name, ...) \ in opt_to_inode_opt() argument
397 case Opt_##name: return Inode_opt_##name; in opt_to_inode_opt()
401 return -1; in opt_to_inode_opt()
407 const char *name, void *buffer, size_t size, in __bch2_xattr_bcachefs_get() argument
411 struct bch_fs *c = inode->v.i_sb->s_fs_info; in __bch2_xattr_bcachefs_get()
413 bch2_inode_opts_to_opts(&inode->ei_inode); in __bch2_xattr_bcachefs_get()
420 id = bch2_opt_lookup(name); in __bch2_xattr_bcachefs_get()
422 return -EINVAL; in __bch2_xattr_bcachefs_get()
426 return -EINVAL; in __bch2_xattr_bcachefs_get()
431 return -ENODATA; in __bch2_xattr_bcachefs_get()
434 !(inode->ei_inode.bi_fields_set & (1 << inode_opt_id))) in __bch2_xattr_bcachefs_get()
435 return -ENODATA; in __bch2_xattr_bcachefs_get()
438 bch2_opt_to_text(&out, c, c->disk_sb.sb, opt, v, 0); in __bch2_xattr_bcachefs_get()
443 ret = -ENOMEM; in __bch2_xattr_bcachefs_get()
446 ret = -ERANGE; in __bch2_xattr_bcachefs_get()
457 const char *name, void *buffer, size_t size) in bch2_xattr_bcachefs_get() argument
460 name, buffer, size, false); in bch2_xattr_bcachefs_get()
476 if (s->defined) in inode_opt_set_fn()
477 bi->bi_fields_set |= 1U << s->id; in inode_opt_set_fn()
479 bi->bi_fields_set &= ~(1U << s->id); in inode_opt_set_fn()
481 bch2_inode_opt_set(bi, s->id, s->v); in inode_opt_set_fn()
489 const char *name, const void *value, in bch2_xattr_bcachefs_set() argument
493 struct bch_fs *c = inode->v.i_sb->s_fs_info; in bch2_xattr_bcachefs_set()
499 opt_id = bch2_opt_lookup(name); in bch2_xattr_bcachefs_set()
501 return -EINVAL; in bch2_xattr_bcachefs_set()
507 return -EINVAL; in bch2_xattr_bcachefs_set()
516 return -ENOMEM; in bch2_xattr_bcachefs_set()
534 * Check if this option was set on the parent - if so, switched in bch2_xattr_bcachefs_set()
538 * to date - see bch2_reinherit_attrs() in bch2_xattr_bcachefs_set()
540 spin_lock(&dentry->d_lock); in bch2_xattr_bcachefs_set()
543 to_bch_ei(d_inode(dentry->d_parent)); in bch2_xattr_bcachefs_set()
545 s.v = bch2_inode_opt_get(&dir->ei_inode, inode_opt_id); in bch2_xattr_bcachefs_set()
549 spin_unlock(&dentry->d_lock); in bch2_xattr_bcachefs_set()
554 mutex_lock(&inode->ei_update_lock); in bch2_xattr_bcachefs_set()
560 ret = bch2_set_projid(c, inode, s.v ? s.v - 1 : 0); in bch2_xattr_bcachefs_set()
567 mutex_unlock(&inode->ei_update_lock); in bch2_xattr_bcachefs_set()
573 .prefix = "bcachefs.",
581 const char *name, void *buffer, size_t size) in bch2_xattr_bcachefs_get_effective() argument
584 name, buffer, size, true); in bch2_xattr_bcachefs_get_effective()
587 /* Noop - xattrs in the bcachefs_effective namespace are inherited */
591 const char *name, const void *value, in bch2_xattr_bcachefs_set_effective() argument
598 .prefix = "bcachefs_effective.",