]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/xattr.h
Update bcachefs sources to 940d6ca657 bcachefs: acl code improvements
[bcachefs-tools-debian] / libbcachefs / xattr.h
1 #ifndef _BCACHEFS_XATTR_H
2 #define _BCACHEFS_XATTR_H
3
4 #include "str_hash.h"
5
6 extern const struct bch_hash_desc bch2_xattr_hash_desc;
7
8 const char *bch2_xattr_invalid(const struct bch_fs *, struct bkey_s_c);
9 void bch2_xattr_to_text(struct bch_fs *, char *, size_t, struct bkey_s_c);
10
11 #define bch2_bkey_xattr_ops (struct bkey_ops) {         \
12         .key_invalid    = bch2_xattr_invalid,           \
13         .val_to_text    = bch2_xattr_to_text,           \
14 }
15
16 static inline unsigned xattr_val_u64s(unsigned name_len, unsigned val_len)
17 {
18         return DIV_ROUND_UP(offsetof(struct bch_xattr, x_name) +
19                             name_len + val_len, sizeof(u64));
20 }
21
22 #define xattr_val(_xattr)                                       \
23         ((void *) (_xattr)->x_name + (_xattr)->x_name_len)
24
25 struct xattr_search_key {
26         u8              type;
27         struct qstr     name;
28 };
29
30 #define X_SEARCH(_type, _name, _len) ((struct xattr_search_key) \
31         { .type = _type, .name = QSTR_INIT(_name, _len) })
32
33 struct dentry;
34 struct xattr_handler;
35 struct bch_hash_info;
36 struct bch_inode_info;
37
38 struct bkey_s_c bch2_xattr_get_iter(struct bch_fs *,
39                                     struct btree_iter *,
40                                     struct bch_inode_info *,
41                                     const char *, int);
42 int bch2_xattr_get(struct bch_fs *, struct bch_inode_info *,
43                   const char *, void *, size_t, int);
44
45 int bch2_xattr_set(struct bch_fs *, u64, const struct bch_hash_info *,
46                    const char *, const void *, size_t, int, int, u64 *);
47 ssize_t bch2_xattr_list(struct dentry *, char *, size_t);
48
49 extern const struct xattr_handler *bch2_xattr_handlers[];
50
51 #endif /* _BCACHEFS_XATTR_H */