mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-01-23 00:07:07 +03:00
997bb216aa
This removes the implicit `-I libbcachefs` argument to $(CC), which in turn requires a set of minor changes throughout the tools. There are two advantages to this setup: 1) It is (arguably) easier to read, since the location of bcachefs includes are easier to understand at a glance ("where does util.h live?") 2) It removes the need for a hack to include glibc's copy of dirent.h explicitly via '/usr/include/dirent.h', because libbcachefs/ *also* has a dirent.h file and the compiler cannot disambiguate them. This has some ramifications on systems where /usr/include may not exist, such as NixOS. Signed-off-by: Austin Seipp <aseipp@pobox.com>
80 lines
1.5 KiB
C
80 lines
1.5 KiB
C
#ifndef _LIBBCACHE_H
|
|
#define _LIBBCACHE_H
|
|
|
|
#include <linux/uuid.h>
|
|
#include <stdbool.h>
|
|
|
|
#include "libbcachefs/bcachefs_format.h"
|
|
#include "tools-util.h"
|
|
#include "libbcachefs/vstructs.h"
|
|
|
|
struct format_opts {
|
|
char *label;
|
|
uuid_le uuid;
|
|
|
|
unsigned on_error_action;
|
|
|
|
unsigned block_size;
|
|
unsigned btree_node_size;
|
|
unsigned encoded_extent_max;
|
|
|
|
unsigned meta_replicas;
|
|
unsigned data_replicas;
|
|
|
|
unsigned meta_replicas_required;
|
|
unsigned data_replicas_required;
|
|
|
|
unsigned meta_csum_type;
|
|
unsigned data_csum_type;
|
|
unsigned compression_type;
|
|
|
|
bool encrypted;
|
|
char *passphrase;
|
|
};
|
|
|
|
static inline struct format_opts format_opts_default()
|
|
{
|
|
return (struct format_opts) {
|
|
.on_error_action = BCH_ON_ERROR_RO,
|
|
.encoded_extent_max = 128,
|
|
.meta_csum_type = BCH_CSUM_CRC32C,
|
|
.data_csum_type = BCH_CSUM_CRC32C,
|
|
.meta_replicas = 1,
|
|
.data_replicas = 1,
|
|
.meta_replicas_required = 1,
|
|
.data_replicas_required = 1,
|
|
};
|
|
}
|
|
|
|
struct dev_opts {
|
|
int fd;
|
|
char *path;
|
|
u64 size; /* 512 byte sectors */
|
|
unsigned bucket_size;
|
|
unsigned tier;
|
|
unsigned data_allowed;
|
|
bool discard;
|
|
|
|
u64 nbuckets;
|
|
|
|
u64 sb_offset;
|
|
u64 sb_end;
|
|
};
|
|
|
|
static inline struct dev_opts dev_opts_default()
|
|
{
|
|
return (struct dev_opts) {
|
|
.data_allowed = ~0U << 2,
|
|
};
|
|
}
|
|
|
|
void bch2_pick_bucket_size(struct format_opts, struct dev_opts *);
|
|
struct bch_sb *bch2_format(struct format_opts, struct dev_opts *, size_t);
|
|
|
|
void bch2_super_write(int, struct bch_sb *);
|
|
struct bch_sb *__bch2_super_read(int, u64);
|
|
|
|
void bch2_super_print(struct bch_sb *, int);
|
|
|
|
#endif /* _LIBBCACHE_H */
|