Lines Matching full:opt

262 int bch2_opt_validate(const struct bch_option *opt, u64 v, struct printbuf *err)  in bch2_opt_validate()  argument
264 if (v < opt->min) { in bch2_opt_validate()
267 opt->attr.name, opt->min); in bch2_opt_validate()
271 if (opt->max && v >= opt->max) { in bch2_opt_validate()
274 opt->attr.name, opt->max); in bch2_opt_validate()
278 if ((opt->flags & OPT_SB_FIELD_SECTORS) && (v & 511)) { in bch2_opt_validate()
281 opt->attr.name); in bch2_opt_validate()
285 if ((opt->flags & OPT_MUST_BE_POW_2) && !is_power_of_2(v)) { in bch2_opt_validate()
288 opt->attr.name); in bch2_opt_validate()
292 if (opt->fn.validate) in bch2_opt_validate()
293 return opt->fn.validate(v, err); in bch2_opt_validate()
299 const struct bch_option *opt, in bch2_opt_parse() argument
305 switch (opt->type) { in bch2_opt_parse()
316 prt_printf(err, "%s: must be bool", opt->attr.name); in bch2_opt_parse()
323 opt->attr.name); in bch2_opt_parse()
327 ret = opt->flags & OPT_HUMAN_READABLE in bch2_opt_parse()
333 opt->attr.name); in bch2_opt_parse()
340 opt->attr.name); in bch2_opt_parse()
344 ret = match_string(opt->choices, -1, val); in bch2_opt_parse()
348 opt->attr.name); in bch2_opt_parse()
355 ret = opt->fn.parse(c, val, res, err); in bch2_opt_parse()
359 opt->attr.name); in bch2_opt_parse()
364 return bch2_opt_validate(opt, *res, err); in bch2_opt_parse()
369 const struct bch_option *opt, u64 v, in bch2_opt_to_text() argument
373 if (opt->type == BCH_OPT_BOOL) { in bch2_opt_to_text()
376 opt->attr.name); in bch2_opt_to_text()
380 prt_printf(out, "%s=", opt->attr.name); in bch2_opt_to_text()
383 switch (opt->type) { in bch2_opt_to_text()
386 if (opt->flags & OPT_HUMAN_READABLE) in bch2_opt_to_text()
393 prt_string_option(out, opt->choices, v); in bch2_opt_to_text()
395 prt_str(out, opt->choices[v]); in bch2_opt_to_text()
398 opt->fn.to_text(out, c, sb, v); in bch2_opt_to_text()
442 char *opt, *name, *val; in bch2_parse_mount_opts() local
462 while ((opt = strsep(&copied_opts, ",")) != NULL) { in bch2_parse_mount_opts()
463 name = strsep(&opt, "="); in bch2_parse_mount_opts()
464 val = opt; in bch2_parse_mount_opts()
468 /* Check for the form "noopt", negation of a boolean opt: */ in bch2_parse_mount_opts()
518 const struct bch_option *opt = bch2_opt_table + id; in bch2_opt_from_sb() local
521 v = opt->get_sb(sb); in bch2_opt_from_sb()
523 if (opt->flags & OPT_SB_FIELD_ILOG2) in bch2_opt_from_sb()
526 if (opt->flags & OPT_SB_FIELD_SECTORS) in bch2_opt_from_sb()
541 const struct bch_option *opt = bch2_opt_table + id; in bch2_opts_from_sb() local
543 if (opt->get_sb == BCH2_NO_SB_OPT) in bch2_opts_from_sb()
552 void __bch2_opt_set_sb(struct bch_sb *sb, const struct bch_option *opt, u64 v) in __bch2_opt_set_sb() argument
554 if (opt->set_sb == SET_BCH2_NO_SB_OPT) in __bch2_opt_set_sb()
557 if (opt->flags & OPT_SB_FIELD_SECTORS) in __bch2_opt_set_sb()
560 if (opt->flags & OPT_SB_FIELD_ILOG2) in __bch2_opt_set_sb()
563 opt->set_sb(sb, v); in __bch2_opt_set_sb()
566 void bch2_opt_set_sb(struct bch_fs *c, const struct bch_option *opt, u64 v) in bch2_opt_set_sb() argument
568 if (opt->set_sb == SET_BCH2_NO_SB_OPT) in bch2_opt_set_sb()
572 __bch2_opt_set_sb(c->disk_sb.sb, opt, v); in bch2_opt_set_sb()