]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs.h
build: require explicit include paths for libbcachefs/
[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 "libbcachefs/bcachefs_format.h"
8 #include "tools-util.h"
9 #include "libbcachefs/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         unsigned        encoded_extent_max;
20
21         unsigned        meta_replicas;
22         unsigned        data_replicas;
23
24         unsigned        meta_replicas_required;
25         unsigned        data_replicas_required;
26
27         unsigned        meta_csum_type;
28         unsigned        data_csum_type;
29         unsigned        compression_type;
30
31         bool            encrypted;
32         char            *passphrase;
33 };
34
35 static inline struct format_opts format_opts_default()
36 {
37         return (struct format_opts) {
38                 .on_error_action        = BCH_ON_ERROR_RO,
39                 .encoded_extent_max     = 128,
40                 .meta_csum_type         = BCH_CSUM_CRC32C,
41                 .data_csum_type         = BCH_CSUM_CRC32C,
42                 .meta_replicas          = 1,
43                 .data_replicas          = 1,
44                 .meta_replicas_required = 1,
45                 .data_replicas_required = 1,
46         };
47 }
48
49 struct dev_opts {
50         int             fd;
51         char            *path;
52         u64             size; /* 512 byte sectors */
53         unsigned        bucket_size;
54         unsigned        tier;
55         unsigned        data_allowed;
56         bool            discard;
57
58         u64             nbuckets;
59
60         u64             sb_offset;
61         u64             sb_end;
62 };
63
64 static inline struct dev_opts dev_opts_default()
65 {
66         return (struct dev_opts) {
67                 .data_allowed           = ~0U << 2,
68         };
69 }
70
71 void bch2_pick_bucket_size(struct format_opts, struct dev_opts *);
72 struct bch_sb *bch2_format(struct format_opts, struct dev_opts *, size_t);
73
74 void bch2_super_write(int, struct bch_sb *);
75 struct bch_sb *__bch2_super_read(int, u64);
76
77 void bch2_super_print(struct bch_sb *, int);
78
79 #endif /* _LIBBCACHE_H */