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, \
22 struct bch_inode_info;
24 unsigned bch2_dirent_name_bytes(struct bkey_s_c_dirent);
26 static inline unsigned dirent_val_u64s(unsigned len)
28 return DIV_ROUND_UP(offsetof(struct bch_dirent, d_name) + len,
32 int bch2_dirent_read_target(struct btree_trans *, subvol_inum,
33 struct bkey_s_c_dirent, subvol_inum *);
35 int bch2_dirent_create(struct btree_trans *, subvol_inum,
36 const struct bch_hash_info *, u8,
37 const struct qstr *, u64, u64 *, int);
39 static inline unsigned vfs_d_type(unsigned type)
41 return type == DT_SUBVOL ? DT_DIR : type;
44 enum bch_rename_mode {
50 int bch2_dirent_rename(struct btree_trans *,
51 subvol_inum, struct bch_hash_info *,
52 subvol_inum, struct bch_hash_info *,
53 const struct qstr *, subvol_inum *, u64 *,
54 const struct qstr *, subvol_inum *, u64 *,
55 enum bch_rename_mode);
57 int __bch2_dirent_lookup_trans(struct btree_trans *, struct btree_iter *,
58 subvol_inum, const struct bch_hash_info *,
59 const struct qstr *, subvol_inum *, unsigned);
60 u64 bch2_dirent_lookup(struct bch_fs *, subvol_inum,
61 const struct bch_hash_info *,
62 const struct qstr *, subvol_inum *);
64 int bch2_empty_dir_trans(struct btree_trans *, subvol_inum);
65 int bch2_readdir(struct bch_fs *, subvol_inum, struct dir_context *);
67 #endif /* _BCACHEFS_DIRENT_H */