X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=libbcachefs%2Fxattr.h;h=1337f31a5c492c8401eefefdcd56c4a450d73514;hb=e773e86495534ede8efc0f3059cf0939c374a925;hp=9bc5376fa77154bda4cc857f3fb94517eaa10004;hpb=819f2dde79241915a6edda2c20bb4ca5d4017030;p=bcachefs-tools-debian diff --git a/libbcachefs/xattr.h b/libbcachefs/xattr.h index 9bc5376..1337f31 100644 --- a/libbcachefs/xattr.h +++ b/libbcachefs/xattr.h @@ -1,23 +1,50 @@ -#ifndef _BCACHE_XATTR_H -#define _BCACHE_XATTR_H +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _BCACHEFS_XATTR_H +#define _BCACHEFS_XATTR_H #include "str_hash.h" extern const struct bch_hash_desc bch2_xattr_hash_desc; -extern const struct bkey_ops bch2_bkey_xattr_ops; + +int bch2_xattr_invalid(struct bch_fs *, struct bkey_s_c, + enum bkey_invalid_flags, struct printbuf *); +void bch2_xattr_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c); + +#define bch2_bkey_ops_xattr ((struct bkey_ops) { \ + .key_invalid = bch2_xattr_invalid, \ + .val_to_text = bch2_xattr_to_text, \ + .min_val_size = 8, \ +}) + +static inline unsigned xattr_val_u64s(unsigned name_len, unsigned val_len) +{ + return DIV_ROUND_UP(offsetof(struct bch_xattr, x_name) + + name_len + val_len, sizeof(u64)); +} + +#define xattr_val(_xattr) \ + ((void *) (_xattr)->x_name + (_xattr)->x_name_len) + +struct xattr_search_key { + u8 type; + struct qstr name; +}; + +#define X_SEARCH(_type, _name, _len) ((struct xattr_search_key) \ + { .type = _type, .name = QSTR_INIT(_name, _len) }) struct dentry; struct xattr_handler; struct bch_hash_info; +struct bch_inode_info; + +/* Exported for cmd_migrate.c in tools: */ +int bch2_xattr_set(struct btree_trans *, subvol_inum, + struct bch_inode_unpacked *, const struct bch_hash_info *, + const char *, const void *, size_t, int, int); -int bch2_xattr_get(struct bch_fs *, struct inode *, - const char *, void *, size_t, int); -int __bch2_xattr_set(struct bch_fs *, u64, const struct bch_hash_info *, - const char *, const void *, size_t, int, int, u64 *); -int bch2_xattr_set(struct bch_fs *, struct inode *, - const char *, const void *, size_t, int, int); ssize_t bch2_xattr_list(struct dentry *, char *, size_t); extern const struct xattr_handler *bch2_xattr_handlers[]; -#endif /* _BCACHE_XATTR_H */ +#endif /* _BCACHEFS_XATTR_H */