]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/dirent.h
4d92ffba144ee13b345513c2887a5f60e0f352d1
[bcachefs-tools-debian] / libbcachefs / dirent.h
1 #ifndef _BCACHEFS_DIRENT_H
2 #define _BCACHEFS_DIRENT_H
3
4 #include "str_hash.h"
5
6 extern const struct bch_hash_desc bch2_dirent_hash_desc;
7
8 const char *bch2_dirent_invalid(const struct bch_fs *, struct bkey_s_c);
9 void bch2_dirent_to_text(struct bch_fs *, char *, size_t, struct bkey_s_c);
10
11 #define bch2_bkey_dirent_ops (struct bkey_ops) {        \
12         .key_invalid    = bch2_dirent_invalid,          \
13         .val_to_text    = bch2_dirent_to_text,          \
14 }
15
16 struct qstr;
17 struct file;
18 struct dir_context;
19 struct bch_fs;
20 struct bch_hash_info;
21 struct bch_inode_info;
22
23 unsigned bch2_dirent_name_bytes(struct bkey_s_c_dirent);
24
25 int __bch2_dirent_create(struct btree_trans *, u64,
26                          const struct bch_hash_info *, u8,
27                          const struct qstr *, u64, int);
28 int bch2_dirent_create(struct bch_fs *c, u64, const struct bch_hash_info *,
29                        u8, const struct qstr *, u64, u64 *, int);
30
31 int __bch2_dirent_delete(struct btree_trans *, u64,
32                          const struct bch_hash_info *,
33                          const struct qstr *);
34 int bch2_dirent_delete(struct bch_fs *, u64, const struct bch_hash_info *,
35                        const struct qstr *, u64 *);
36
37 enum bch_rename_mode {
38         BCH_RENAME,
39         BCH_RENAME_OVERWRITE,
40         BCH_RENAME_EXCHANGE,
41 };
42
43 int bch2_dirent_rename(struct btree_trans *,
44                        struct bch_inode_info *, const struct qstr *,
45                        struct bch_inode_info *, const struct qstr *,
46                        enum bch_rename_mode);
47
48 u64 bch2_dirent_lookup(struct bch_fs *, u64, const struct bch_hash_info *,
49                        const struct qstr *);
50
51 int bch2_empty_dir(struct bch_fs *, u64);
52 int bch2_readdir(struct bch_fs *, struct file *, struct dir_context *);
53
54 #endif /* _BCACHEFS_DIRENT_H */