2017-03-16 23:18:50 -07:00
|
|
|
/* 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;
|
|
|
|
|
2024-08-12 18:31:25 -07:00
|
|
|
int bch2_xattr_validate(struct bch_fs *, struct bkey_s_c, enum bch_validate_flags);
|
2018-11-08 23:24:07 -07:00
|
|
|
void bch2_xattr_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
|
2017-03-16 23:18:50 -07:00
|
|
|
|
2022-10-22 12:59:53 -07:00
|
|
|
#define bch2_bkey_ops_xattr ((struct bkey_ops) { \
|
2024-08-12 18:31:25 -07:00
|
|
|
.key_validate = bch2_xattr_validate, \
|
2017-03-16 23:18:50 -07:00
|
|
|
.val_to_text = bch2_xattr_to_text, \
|
2023-04-29 10:24:18 -07:00
|
|
|
.min_val_size = 8, \
|
2022-10-22 12:59:53 -07:00
|
|
|
})
|
2017-03-16 23:18:50 -07:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2023-07-09 11:12:58 -07:00
|
|
|
/* Exported for cmd_migrate.c in tools: */
|
2021-03-15 21:28:17 -07:00
|
|
|
int bch2_xattr_set(struct btree_trans *, subvol_inum,
|
2023-07-09 11:18:28 -07:00
|
|
|
struct bch_inode_unpacked *, const struct bch_hash_info *,
|
2017-03-16 23:18:50 -07:00
|
|
|
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 /* _BCACHEFS_XATTR_H */
|