Commit | Line | Data |
---|---|---|
1c6fdbd8 KO |
1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | #ifndef _BCACHEFS_DIRENT_H | |
3 | #define _BCACHEFS_DIRENT_H | |
4 | ||
5 | #include "str_hash.h" | |
6 | ||
7 | extern const struct bch_hash_desc bch2_dirent_hash_desc; | |
8 | ||
9 | const char *bch2_dirent_invalid(const struct bch_fs *, struct bkey_s_c); | |
319f9ac3 | 10 | void bch2_dirent_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c); |
1c6fdbd8 | 11 | |
26609b61 | 12 | #define bch2_bkey_ops_dirent (struct bkey_ops) { \ |
1c6fdbd8 KO |
13 | .key_invalid = bch2_dirent_invalid, \ |
14 | .val_to_text = bch2_dirent_to_text, \ | |
15 | } | |
16 | ||
17 | struct qstr; | |
18 | struct file; | |
19 | struct dir_context; | |
20 | struct bch_fs; | |
21 | struct bch_hash_info; | |
22 | struct bch_inode_info; | |
23 | ||
24 | unsigned bch2_dirent_name_bytes(struct bkey_s_c_dirent); | |
25 | ||
741daa5b KO |
26 | static inline unsigned dirent_val_u64s(unsigned len) |
27 | { | |
28 | return DIV_ROUND_UP(offsetof(struct bch_dirent, d_name) + len, | |
29 | sizeof(u64)); | |
30 | } | |
31 | ||
96385742 KO |
32 | int bch2_dirent_create(struct btree_trans *, u64, |
33 | const struct bch_hash_info *, u8, | |
34 | const struct qstr *, u64, int); | |
35 | ||
36 | int bch2_dirent_delete_at(struct btree_trans *, | |
37 | const struct bch_hash_info *, | |
38 | struct btree_iter *); | |
1c6fdbd8 KO |
39 | |
40 | enum bch_rename_mode { | |
41 | BCH_RENAME, | |
42 | BCH_RENAME_OVERWRITE, | |
43 | BCH_RENAME_EXCHANGE, | |
44 | }; | |
45 | ||
46 | int bch2_dirent_rename(struct btree_trans *, | |
96385742 KO |
47 | u64, struct bch_hash_info *, |
48 | u64, struct bch_hash_info *, | |
49 | const struct qstr *, u64 *, | |
50 | const struct qstr *, u64 *, | |
1c6fdbd8 KO |
51 | enum bch_rename_mode); |
52 | ||
96385742 KO |
53 | struct btree_iter * |
54 | __bch2_dirent_lookup_trans(struct btree_trans *, u64, | |
55 | const struct bch_hash_info *, | |
63fbf458 | 56 | const struct qstr *, unsigned); |
1c6fdbd8 KO |
57 | u64 bch2_dirent_lookup(struct bch_fs *, u64, const struct bch_hash_info *, |
58 | const struct qstr *); | |
59 | ||
6bd13057 | 60 | int bch2_empty_dir_trans(struct btree_trans *, u64); |
96385742 | 61 | int bch2_readdir(struct bch_fs *, u64, struct dir_context *); |
1c6fdbd8 KO |
62 | |
63 | #endif /* _BCACHEFS_DIRENT_H */ |