]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs.h
f9cf8fe40350412063b14dc839c3b411a03730ca
[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 cache_sb;
12
13 enum fsck_err_opts {
14         FSCK_ERR_ASK,
15         FSCK_ERR_YES,
16         FSCK_ERR_NO,
17 };
18
19 extern enum fsck_err_opts fsck_err_opt;
20
21 struct format_opts {
22         char            *label;
23         uuid_le         uuid;
24
25         unsigned        on_error_action;
26         unsigned        max_journal_entry_size; /* will be removed */
27
28         unsigned        block_size;
29         unsigned        btree_node_size;
30
31         unsigned        meta_replicas;
32         unsigned        data_replicas;
33
34         unsigned        meta_replicas_required;
35         unsigned        data_replicas_required;
36
37         unsigned        meta_csum_type;
38         unsigned        data_csum_type;
39         unsigned        compression_type;
40
41         bool            encrypted;
42         char            *passphrase;
43 };
44
45 static inline struct format_opts format_opts_default()
46 {
47         return (struct format_opts) {
48                 .on_error_action        = BCH_ON_ERROR_RO,
49                 .meta_csum_type         = BCH_CSUM_CRC32C,
50                 .data_csum_type         = BCH_CSUM_CRC32C,
51                 .meta_replicas          = 1,
52                 .data_replicas          = 1,
53                 .meta_replicas_required = 1,
54                 .data_replicas_required = 1,
55         };
56 }
57
58 struct dev_opts {
59         int             fd;
60         char            *path;
61         u64             size; /* 512 byte sectors */
62         unsigned        bucket_size;
63         unsigned        tier;
64         bool            discard;
65
66         u64             nbuckets;
67
68         u64             sb_offset;
69         u64             sb_end;
70 };
71
72 struct bch_sb *bcache_format(struct format_opts, struct dev_opts *, size_t);
73
74 void bcache_super_write(int, struct bch_sb *);
75 struct bch_sb *__bcache_super_read(int, u64);
76 struct bch_sb *bcache_super_read(const char *);
77
78 void bcache_super_print(struct bch_sb *, int);
79
80 #endif /* _LIBBCACHE_H */