]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/opts.c
New upstream release
[bcachefs-tools-debian] / libbcachefs / opts.c
index 960bb247f3a0ab8b84c64e8f439738ffdf76b3b6..8dd4046cca41ef23b061f4aeac1892f82a504d65 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,14 +265,14 @@ 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)) {
@@ -290,6 +289,9 @@ int bch2_opt_validate(const struct bch_option *opt, u64 v, struct printbuf *err)
                return -EINVAL;
        }
 
+       if (opt->fn.validate)
+               return opt->fn.validate(v, err);
+
        return 0;
 }
 
@@ -471,8 +473,9 @@ int bch2_parse_mount_opts(struct bch_fs *c, struct bch_opts *opts,
                        val = "0";
                }
 
+               /* Unknown options are ignored: */
                if (id < 0)
-                       goto bad_opt;
+                       continue;
 
                if (!(bch2_opt_table[id].flags & OPT_MOUNT))
                        goto bad_opt;