On Thu, Jul 18, 2024 at 02:28:36PM GMT, Integral wrote:
> Currently, when using bcachefs-tools to set options, bool-type options can
> only accept 1 or 0. Add support for accepting true/false and yes/no for
> these options.
this needs to be against the kernel repo, fs/bcachefs/; tools is
imported from there
>
> ---
> libbcachefs/opts.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/libbcachefs/opts.c b/libbcachefs/opts.c
> index 0770aebe..2c0113fb 100644
> --- a/libbcachefs/opts.c
> +++ b/libbcachefs/opts.c
> @@ -332,6 +332,11 @@ int bch2_opt_parse(struct bch_fs *c,
> switch (opt->type) {
> case BCH_OPT_BOOL:
> if (val) {
> + if (!strcmp(val, "true") || !strcmp(val, "yes"))
> + val = "1";
> + else if (!strcmp(val, "false") || !strcmp(val, "no"))
> + val = "0";
> +
> ret = kstrtou64(val, 10, res);
> } else {
> ret = 0;
> --
> 2.45.2
>