#include "super-io.h"
#include "util.h"
-#include <linux/pretty-printers.h>
-
#define x(t, n) [n] = #t,
const char * const bch2_metadata_versions[] = {
case BCH_OPT_BOOL:
ret = kstrtou64(val, 10, res);
if (ret < 0 || (*res != 0 && *res != 1)) {
- prt_printf(err, "%s: must be bool",
- opt->attr.name);
+ if (err)
+ prt_printf(err, "%s: must be bool",
+ opt->attr.name);
return ret;
}
break;
if (ret < 0) {
if (err)
prt_printf(err, "%s: must be a number",
- opt->attr.name);
+ opt->attr.name);
return ret;
}
break;
if (ret < 0) {
if (err)
prt_printf(err, "%s: invalid selection",
- opt->attr.name);
+ opt->attr.name);
return ret;
}
if (ret < 0) {
if (err)
prt_printf(err, "%s: parse error",
- opt->attr.name);
+ opt->attr.name);
return ret;
}
}
struct bch_io_opts bch2_opts_to_inode_opts(struct bch_opts src)
{
- struct bch_io_opts ret = { 0 };
-#define x(_name, _bits) \
- if (opt_defined(src, _name)) \
- opt_set(ret, _name, src._name);
- BCH_INODE_OPTS()
-#undef x
- return ret;
-}
-
-struct bch_opts bch2_inode_opts_to_opts(struct bch_io_opts src)
-{
- struct bch_opts ret = { 0 };
-#define x(_name, _bits) \
- if (opt_defined(src, _name)) \
- opt_set(ret, _name, src._name);
- BCH_INODE_OPTS()
-#undef x
- return ret;
-}
-
-void bch2_io_opts_apply(struct bch_io_opts *dst, struct bch_io_opts src)
-{
-#define x(_name, _bits) \
- if (opt_defined(src, _name)) \
- opt_set(*dst, _name, src._name);
+ return (struct bch_io_opts) {
+#define x(_name, _bits) ._name = src._name,
BCH_INODE_OPTS()
#undef x
+ };
}
bool bch2_opt_is_inode_opt(enum bch_opt_id id)