]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs.h
Update bcachefs sources to da037866e6
[bcachefs-tools-debian] / libbcachefs.h
1 #ifndef _LIBBCACHE_H
2 #define _LIBBCACHE_H
3
4 #include <linux/uuid.h>
5 #include <stdbool.h>
6
7 #include "bcachefs_format.h"
8 #include "tools-util.h"
9 #include "vstructs.h"
10
11 struct format_opts {
12         char            *label;
13         uuid_le         uuid;
14
15         unsigned        on_error_action;
16
17         unsigned        block_size;
18         unsigned        btree_node_size;
19
20         unsigned        meta_replicas;
21         unsigned        data_replicas;
22
23         unsigned        meta_replicas_required;
24         unsigned        data_replicas_required;
25
26         unsigned        meta_csum_type;
27         unsigned        data_csum_type;
28         unsigned        compression_type;
29
30         bool            encrypted;
31         char            *passphrase;
32 };
33
34 static inline struct format_opts format_opts_default()
35 {
36         return (struct format_opts) {
37                 .on_error_action        = BCH_ON_ERROR_RO,
38                 .meta_csum_type         = BCH_CSUM_CRC32C,
39                 .data_csum_type         = BCH_CSUM_CRC32C,
40                 .meta_replicas          = 1,
41                 .data_replicas          = 1,
42                 .meta_replicas_required = 1,
43                 .data_replicas_required = 1,
44         };
45 }
46
47 struct dev_opts {
48         int             fd;
49         char            *path;
50         u64             size; /* 512 byte sectors */
51         unsigned        bucket_size;
52         unsigned        tier;
53         bool            discard;
54
55         u64             nbuckets;
56
57         u64             sb_offset;
58         u64             sb_end;
59 };
60
61 void bch2_pick_bucket_size(struct format_opts, struct dev_opts *);
62 struct bch_sb *bch2_format(struct format_opts, struct dev_opts *, size_t);
63
64 void bch2_super_write(int, struct bch_sb *);
65 struct bch_sb *__bch2_super_read(int, u64);
66 struct bch_sb *bch2_super_read(const char *);
67
68 void bch2_super_print(struct bch_sb *, int);
69
70 #endif /* _LIBBCACHE_H */