diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2018-11-09 01:24:07 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:11 -0400 |
commit | 319f9ac38eaba628d69b6ddbf402b35487315fc1 (patch) | |
tree | 01daddd4881b1f09bb4d50087e8b8803e59fea35 /fs/bcachefs/opts.c | |
parent | 75369d4ec3d2dfc52af18a2d20cd0af14c935ac9 (diff) | |
download | linux-stable-319f9ac38eaba628d69b6ddbf402b35487315fc1.tar.gz linux-stable-319f9ac38eaba628d69b6ddbf402b35487315fc1.tar.bz2 linux-stable-319f9ac38eaba628d69b6ddbf402b35487315fc1.zip |
bcachefs: revamp to_text methods
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/opts.c')
-rw-r--r-- | fs/bcachefs/opts.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/fs/bcachefs/opts.c b/fs/bcachefs/opts.c index 9351caeb6630..c12af1a86f0b 100644 --- a/fs/bcachefs/opts.c +++ b/fs/bcachefs/opts.c @@ -145,7 +145,7 @@ const struct bch_option bch2_opt_table[] = { #define OPT_STR(_choices) .type = BCH_OPT_STR, .choices = _choices #define OPT_FN(_fn) .type = BCH_OPT_FN, \ .parse = _fn##_parse, \ - .print = _fn##_print + .to_text = _fn##_to_text #define BCH_OPT(_name, _bits, _mode, _type, _sb_opt, _default) \ [Opt_##_name] = { \ @@ -235,38 +235,38 @@ int bch2_opt_parse(struct bch_fs *c, const struct bch_option *opt, return 0; } -int bch2_opt_to_text(struct bch_fs *c, char *buf, size_t len, - const struct bch_option *opt, u64 v, - unsigned flags) +void bch2_opt_to_text(struct printbuf *out, struct bch_fs *c, + const struct bch_option *opt, u64 v, + unsigned flags) { - char *out = buf, *end = buf + len; - if (flags & OPT_SHOW_MOUNT_STYLE) { - if (opt->type == BCH_OPT_BOOL) - return scnprintf(out, end - out, "%s%s", - v ? "" : "no", - opt->attr.name); + if (opt->type == BCH_OPT_BOOL) { + pr_buf(out, "%s%s", + v ? "" : "no", + opt->attr.name); + return; + } - out += scnprintf(out, end - out, "%s=", opt->attr.name); + pr_buf(out, "%s=", opt->attr.name); } switch (opt->type) { case BCH_OPT_BOOL: case BCH_OPT_UINT: - out += scnprintf(out, end - out, "%lli", v); + pr_buf(out, "%lli", v); break; case BCH_OPT_STR: - out += (flags & OPT_SHOW_FULL_LIST) - ? bch2_scnprint_string_list(out, end - out, opt->choices, v) - : scnprintf(out, end - out, opt->choices[v]); + if (flags & OPT_SHOW_FULL_LIST) + bch2_string_opt_to_text(out, opt->choices, v); + else + pr_buf(out, opt->choices[v]); break; case BCH_OPT_FN: - return opt->print(c, out, end - out, v); + opt->to_text(out, c, v); + break; default: BUG(); } - - return out - buf; } int bch2_parse_mount_opts(struct bch_opts *opts, char *options) |