diff options
Diffstat (limited to 'fs/bcachefs/opts.c')
-rw-r--r-- | fs/bcachefs/opts.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/fs/bcachefs/opts.c b/fs/bcachefs/opts.c index d4d16cb8475f..b07f3dcfe354 100644 --- a/fs/bcachefs/opts.c +++ b/fs/bcachefs/opts.c @@ -9,6 +9,8 @@ #include "super-io.h" #include "util.h" +#include <linux/pretty-printers.h> + #define x(t, n) [n] = #t, const char * const bch2_metadata_versions[] = { @@ -228,28 +230,28 @@ int bch2_opt_validate(const struct bch_option *opt, u64 v, struct printbuf *err) { if (v < opt->min) { if (err) - pr_buf(err, "%s: too small (min %llu)", + prt_printf(err, "%s: too small (min %llu)", opt->attr.name, opt->min); return -ERANGE; } if (opt->max && v >= opt->max) { if (err) - pr_buf(err, "%s: too big (max %llu)", + prt_printf(err, "%s: too big (max %llu)", opt->attr.name, opt->max); return -ERANGE; } if ((opt->flags & OPT_SB_FIELD_SECTORS) && (v & 511)) { if (err) - pr_buf(err, "%s: not a multiple of 512", + prt_printf(err, "%s: not a multiple of 512", opt->attr.name); return -EINVAL; } if ((opt->flags & OPT_MUST_BE_POW_2) && !is_power_of_2(v)) { if (err) - pr_buf(err, "%s: must be a power of two", + prt_printf(err, "%s: must be a power of two", opt->attr.name); return -EINVAL; } @@ -268,7 +270,7 @@ int bch2_opt_parse(struct bch_fs *c, case BCH_OPT_BOOL: ret = kstrtou64(val, 10, res); if (ret < 0 || (*res != 0 && *res != 1)) { - pr_buf(err, "%s: must be bool", + prt_printf(err, "%s: must be bool", opt->attr.name); return ret; } @@ -279,7 +281,7 @@ int bch2_opt_parse(struct bch_fs *c, : kstrtou64(val, 10, res); if (ret < 0) { if (err) - pr_buf(err, "%s: must be a number", + prt_printf(err, "%s: must be a number", opt->attr.name); return ret; } @@ -288,7 +290,7 @@ int bch2_opt_parse(struct bch_fs *c, ret = match_string(opt->choices, -1, val); if (ret < 0) { if (err) - pr_buf(err, "%s: invalid selection", + prt_printf(err, "%s: invalid selection", opt->attr.name); return ret; } @@ -302,7 +304,7 @@ int bch2_opt_parse(struct bch_fs *c, ret = opt->parse(c, val, res); if (ret < 0) { if (err) - pr_buf(err, "%s: parse error", + prt_printf(err, "%s: parse error", opt->attr.name); return ret; } @@ -318,28 +320,28 @@ void bch2_opt_to_text(struct printbuf *out, { if (flags & OPT_SHOW_MOUNT_STYLE) { if (opt->type == BCH_OPT_BOOL) { - pr_buf(out, "%s%s", + prt_printf(out, "%s%s", v ? "" : "no", opt->attr.name); return; } - pr_buf(out, "%s=", opt->attr.name); + prt_printf(out, "%s=", opt->attr.name); } switch (opt->type) { case BCH_OPT_BOOL: case BCH_OPT_UINT: if (opt->flags & OPT_HUMAN_READABLE) - bch2_hprint(out, v); + prt_human_readable_u64(out, v); else - pr_buf(out, "%lli", v); + prt_printf(out, "%lli", v); break; case BCH_OPT_STR: if (flags & OPT_SHOW_FULL_LIST) - bch2_string_opt_to_text(out, opt->choices, v); + prt_string_option(out, opt->choices, v); else - pr_buf(out, "%s", opt->choices[v]); + prt_printf(out, "%s", opt->choices[v]); break; case BCH_OPT_FN: opt->to_text(out, c, sb, v); |