]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/dirent.h
Update bcachefs sources to 400f275d46 bcachefs: Fix check_overlapping_extents()
[bcachefs-tools-debian] / libbcachefs / dirent.h
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 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);
11
12 #define bch2_bkey_ops_dirent ((struct bkey_ops) {       \
13         .key_invalid    = bch2_dirent_invalid,          \
14         .val_to_text    = bch2_dirent_to_text,          \
15         .min_val_size   = 16,                           \
16 })
17
18 struct qstr;
19 struct file;
20 struct dir_context;
21 struct bch_fs;
22 struct bch_hash_info;
23 struct bch_inode_info;
24
25 unsigned bch2_dirent_name_bytes(struct bkey_s_c_dirent);
26
27 static inline unsigned dirent_val_u64s(unsigned len)
28 {
29         return DIV_ROUND_UP(offsetof(struct bch_dirent, d_name) + len,
30                             sizeof(u64));
31 }
32
33 int bch2_dirent_read_target(struct btree_trans *, subvol_inum,
34                             struct bkey_s_c_dirent, subvol_inum *);
35
36 int bch2_dirent_create(struct btree_trans *, subvol_inum,
37                        const struct bch_hash_info *, u8,
38                        const struct qstr *, u64, u64 *, int);
39
40 static inline unsigned vfs_d_type(unsigned type)
41 {
42         return type == DT_SUBVOL ? DT_DIR : type;
43 }
44
45 enum bch_rename_mode {
46         BCH_RENAME,
47         BCH_RENAME_OVERWRITE,
48         BCH_RENAME_EXCHANGE,
49 };
50
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);
57
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 *);
64
65 int bch2_empty_dir_trans(struct btree_trans *, subvol_inum);
66 int bch2_readdir(struct bch_fs *, subvol_inum, struct dir_context *);
67
68 #endif /* _BCACHEFS_DIRENT_H */