]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/opts.c
Update bcachefs sources to 5264e9f4d0c0 bcachefs: fix setting version_upgrade_complete
[bcachefs-tools-debian] / libbcachefs / opts.c
index 739a2ef80945b095a19aae195084888db817cd46..8e6f230eac38155bf5d048367d6ebde35a4a15bd 100644 (file)
@@ -37,9 +37,8 @@ const char * const bch2_sb_compat[] = {
        NULL
 };
 
-const char * const bch2_btree_ids[] = {
+const char * const __bch2_btree_ids[] = {
        BCH_BTREE_IDS()
-       "interior btree node",
        NULL
 };
 
@@ -266,30 +265,33 @@ int bch2_opt_validate(const struct bch_option *opt, u64 v, struct printbuf *err)
                if (err)
                        prt_printf(err, "%s: too small (min %llu)",
                               opt->attr.name, opt->min);
-               return -ERANGE;
+               return -BCH_ERR_ERANGE_option_too_small;
        }
 
        if (opt->max && v >= opt->max) {
                if (err)
                        prt_printf(err, "%s: too big (max %llu)",
                               opt->attr.name, opt->max);
-               return -ERANGE;
+               return -BCH_ERR_ERANGE_option_too_big;
        }
 
        if ((opt->flags & OPT_SB_FIELD_SECTORS) && (v & 511)) {
                if (err)
                        prt_printf(err, "%s: not a multiple of 512",
                               opt->attr.name);
-               return -EINVAL;
+               return -BCH_ERR_opt_parse_error;
        }
 
        if ((opt->flags & OPT_MUST_BE_POW_2) && !is_power_of_2(v)) {
                if (err)
                        prt_printf(err, "%s: must be a power of two",
                               opt->attr.name);
-               return -EINVAL;
+               return -BCH_ERR_opt_parse_error;
        }
 
+       if (opt->fn.validate)
+               return opt->fn.validate(v, err);
+
        return 0;
 }