1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | #ifndef _BCACHEFS_XATTR_H |
3 | #define _BCACHEFS_XATTR_H |
4 | |
5 | #include "str_hash.h" |
6 | |
7 | extern const struct bch_hash_desc bch2_xattr_hash_desc; |
8 | |
9 | int bch2_xattr_invalid(struct bch_fs *, struct bkey_s_c, |
10 | enum bkey_invalid_flags, struct printbuf *); |
11 | void bch2_xattr_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c); |
12 | |
13 | #define bch2_bkey_ops_xattr ((struct bkey_ops) { \ |
14 | .key_invalid = bch2_xattr_invalid, \ |
15 | .val_to_text = bch2_xattr_to_text, \ |
16 | .min_val_size = 8, \ |
17 | }) |
18 | |
19 | static inline unsigned xattr_val_u64s(unsigned name_len, unsigned val_len) |
20 | { |
21 | return DIV_ROUND_UP(offsetof(struct bch_xattr, x_name) + |
22 | name_len + val_len, sizeof(u64)); |
23 | } |
24 | |
25 | #define xattr_val(_xattr) \ |
26 | ((void *) (_xattr)->x_name + (_xattr)->x_name_len) |
27 | |
28 | struct xattr_search_key { |
29 | u8 type; |
30 | struct qstr name; |
31 | }; |
32 | |
33 | #define X_SEARCH(_type, _name, _len) ((struct xattr_search_key) \ |
34 | { .type = _type, .name = QSTR_INIT(_name, _len) }) |
35 | |
36 | struct dentry; |
37 | struct xattr_handler; |
38 | struct bch_hash_info; |
39 | struct bch_inode_info; |
40 | |
41 | /* Exported for cmd_migrate.c in tools: */ |
42 | int bch2_xattr_set(struct btree_trans *, subvol_inum, |
43 | struct bch_inode_unpacked *, const struct bch_hash_info *, |
44 | const char *, const void *, size_t, int, int); |
45 | |
46 | ssize_t bch2_xattr_list(struct dentry *, char *, size_t); |
47 | |
48 | extern const struct xattr_handler *bch2_xattr_handlers[]; |
49 | |
50 | #endif /* _BCACHEFS_XATTR_H */ |
51 | |