1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BCACHEFS_DIRENT_H
3 #define _BCACHEFS_DIRENT_H
7 extern const struct bch_hash_desc bch2_dirent_hash_desc;
9 int bch2_dirent_invalid(const struct bch_fs *, struct bkey_s_c, unsigned, struct printbuf *);
10 void bch2_dirent_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
12 #define bch2_bkey_ops_dirent ((struct bkey_ops) { \
13 .key_invalid = bch2_dirent_invalid, \
14 .val_to_text = bch2_dirent_to_text, \
23 struct bch_inode_info;
25 unsigned bch2_dirent_name_bytes(struct bkey_s_c_dirent);
27 static inline unsigned dirent_val_u64s(unsigned len)
29 return DIV_ROUND_UP(offsetof(struct bch_dirent, d_name) + len,
33 int bch2_dirent_read_target(struct btree_trans *, subvol_inum,
34 struct bkey_s_c_dirent, subvol_inum *);
36 int bch2_dirent_create(struct btree_trans *, subvol_inum,
37 const struct bch_hash_info *, u8,
38 const struct qstr *, u64, u64 *, int);
40 static inline unsigned vfs_d_type(unsigned type)
42 return type == DT_SUBVOL ? DT_DIR : type;
45 enum bch_rename_mode {
51 int bch2_dirent_rename(struct btree_trans *,
52 subvol_inum, struct bch_hash_info *,
53 subvol_inum, struct bch_hash_info *,
54 const struct qstr *, subvol_inum *, u64 *,
55 const struct qstr *, subvol_inum *, u64 *,
56 enum bch_rename_mode);
58 int __bch2_dirent_lookup_trans(struct btree_trans *, struct btree_iter *,
59 subvol_inum, const struct bch_hash_info *,
60 const struct qstr *, subvol_inum *, unsigned);
61 u64 bch2_dirent_lookup(struct bch_fs *, subvol_inum,
62 const struct bch_hash_info *,
63 const struct qstr *, subvol_inum *);
65 int bch2_empty_dir_trans(struct btree_trans *, subvol_inum);
66 int bch2_readdir(struct bch_fs *, subvol_inum, struct dir_context *);
68 #endif /* _BCACHEFS_DIRENT_H */