Lines Matching +full:attr +full:- +full:max +full:- +full:name

1 // SPDX-License-Identifier: GPL-2.0
10 #include "super-io.h"
103 int ret = match_string(bch2_fsck_fix_opts, -1, val); in bch2_opt_fix_errors_parse()
179 return opts->_name; in bch2_opt_get_by_id()
202 #define OPT_BOOL() .type = BCH_OPT_BOOL, .min = 0, .max = 2
204 .min = _min, .max = _max
206 .min = 0, .max = ARRAY_SIZE(_choices), \
212 .attr = { \
213 .name = #_name, \
228 int bch2_opt_lookup(const char *name) in bch2_opt_lookup() argument
235 if (!strcmp(name, i->attr.name)) in bch2_opt_lookup()
236 return i - bch2_opt_table; in bch2_opt_lookup()
238 return -1; in bch2_opt_lookup()
249 static int bch2_mount_opt_lookup(const char *name) in bch2_mount_opt_lookup() argument
256 if (!strcmp(name, i->s1)) in bch2_mount_opt_lookup()
257 name = i->s2; in bch2_mount_opt_lookup()
259 return bch2_opt_lookup(name); in bch2_mount_opt_lookup()
264 if (v < opt->min) { in bch2_opt_validate()
267 opt->attr.name, opt->min); in bch2_opt_validate()
268 return -BCH_ERR_ERANGE_option_too_small; in bch2_opt_validate()
271 if (opt->max && v >= opt->max) { in bch2_opt_validate()
273 prt_printf(err, "%s: too big (max %llu)", in bch2_opt_validate()
274 opt->attr.name, opt->max); in bch2_opt_validate()
275 return -BCH_ERR_ERANGE_option_too_big; 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()
282 return -BCH_ERR_opt_parse_error; 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()
289 return -BCH_ERR_opt_parse_error; in bch2_opt_validate()
292 if (opt->fn.validate) in bch2_opt_validate()
293 return opt->fn.validate(v, err); in bch2_opt_validate()
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()
324 return -EINVAL; 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()
341 return -EINVAL; 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()
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()
430 bch2_opt_get_by_id(&c->opts, i)); in bch2_opts_check_may_set()
442 char *opt, *name, *val; in bch2_parse_mount_opts() local
452 * starting with a comma - weird. in bch2_parse_mount_opts()
459 return -1; in bch2_parse_mount_opts()
463 name = strsep(&opt, "="); in bch2_parse_mount_opts()
466 id = bch2_mount_opt_lookup(name); in bch2_parse_mount_opts()
471 !strncmp("no", name, 2)) { in bch2_parse_mount_opts()
472 id = bch2_mount_opt_lookup(name + 2); in bch2_parse_mount_opts()
503 pr_err("Bad mount option %s", name); in bch2_parse_mount_opts()
504 ret = -1; in bch2_parse_mount_opts()
508 ret = -1; in bch2_parse_mount_opts()
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()
533 * Initial options from superblock - here we don't want any options undefined,
543 if (opt->get_sb == BCH2_NO_SB_OPT) in bch2_opts_from_sb()
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()
568 if (opt->set_sb == SET_BCH2_NO_SB_OPT) in bch2_opt_set_sb()
571 mutex_lock(&c->sb_lock); in bch2_opt_set_sb()
572 __bch2_opt_set_sb(c->disk_sb.sb, opt, v); in bch2_opt_set_sb()
574 mutex_unlock(&c->sb_lock); in bch2_opt_set_sb()