]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs.h
Update bcachefs sources to 7e42539c80 bcachefs: Don't overflow stack in bch2_extent_m...
[bcachefs-tools-debian] / libbcachefs.h
index d27b4e8f3cd353a8a0eea44d41ef3c1e03ff27dd..d6b8548d65f4b33c29698ab6b9182883e26ace1c 100644 (file)
@@ -6,33 +6,33 @@
 
 #include "libbcachefs/bcachefs_format.h"
 #include "libbcachefs/bcachefs_ioctl.h"
-#include "tools-util.h"
+#include "libbcachefs/opts.h"
 #include "libbcachefs/vstructs.h"
+#include "tools-util.h"
+
+/* option parsing */
+
+struct bch_opt_strs {
+union {
+       char                    *by_id[bch2_opts_nr];
+struct {
+#define x(_name, ...)  char    *_name;
+       BCH_OPTS()
+#undef x
+};
+};
+};
+
+struct bch_opt_strs bch2_cmdline_opts_get(int *, char *[], unsigned);
+struct bch_opts bch2_parse_opts(struct bch_opt_strs);
+void bch2_opts_usage(unsigned);
 
 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;
-
-       const char      *foreground_target;
-       const char      *background_target;
-       const char      *promote_target;
-
-       unsigned        meta_csum_type;
-       unsigned        data_csum_type;
-       unsigned        compression_type;
-
        bool            encrypted;
        char            *passphrase;
 };
@@ -40,14 +40,7 @@ struct format_opts {
 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_OPT_CRC32C,
-               .data_csum_type         = BCH_CSUM_OPT_CRC32C,
-               .meta_replicas          = 1,
-               .data_replicas          = 1,
-               .meta_replicas_required = 1,
-               .data_replicas_required = 1,
        };
 }
 
@@ -58,6 +51,7 @@ struct dev_opts {
        unsigned        bucket_size;
        const char      *group;
        unsigned        data_allowed;
+       unsigned        durability;
        bool            discard;
 
        u64             nbuckets;
@@ -70,11 +64,14 @@ static inline struct dev_opts dev_opts_default()
 {
        return (struct dev_opts) {
                .data_allowed           = ~0U << 2,
+               .durability             = 1,
        };
 }
 
-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_pick_bucket_size(struct bch_opts, struct dev_opts *);
+struct bch_sb *bch2_format(struct bch_opt_strs,
+                          struct bch_opts,
+                          struct format_opts, struct dev_opts *, size_t);
 
 void bch2_super_write(int, struct bch_sb *);
 struct bch_sb *__bch2_super_read(int, u64);
@@ -97,7 +94,7 @@ struct bchfs_handle bchu_fs_open_by_dev(const char *, unsigned *);
 
 static inline void bchu_disk_add(struct bchfs_handle fs, char *dev)
 {
-       struct bch_ioctl_disk i = { .dev = (__u64) dev, };
+       struct bch_ioctl_disk i = { .dev = (unsigned long) dev, };
 
        xioctl(fs.ioctl_fd, BCH_IOCTL_DISK_ADD, &i);
 }
@@ -115,7 +112,7 @@ static inline void bchu_disk_remove(struct bchfs_handle fs, unsigned dev_idx,
 
 static inline void bchu_disk_online(struct bchfs_handle fs, char *dev)
 {
-       struct bch_ioctl_disk i = { .dev = (__u64) dev, };
+       struct bch_ioctl_disk i = { .dev = (unsigned long) dev, };
 
        xioctl(fs.ioctl_fd, BCH_IOCTL_DISK_ONLINE, &i);
 }
@@ -170,7 +167,7 @@ static inline struct bch_sb *bchu_read_super(struct bchfs_handle fs, unsigned id
                sb = xrealloc(sb, size);
                struct bch_ioctl_read_super i = {
                        .size   = size,
-                       .sb     = (u64) sb,
+                       .sb     = (unsigned long) sb,
                };
 
                if (idx != -1) {