From: Jens Axboe Date: Wed, 8 Jun 2016 16:58:07 +0000 (-0600) Subject: parse: add support for unsupported options X-Git-Tag: fio-2.12~7 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=75e6bcba7e5824b8852590fa54963db64f05c70d parse: add support for unsupported options Some options are only available if fio is built with a certain set of libraries. This can confuse the user. Add support for listing an unsupported option, so fio can print some related help for that option. Signed-off-by: Jens Axboe --- diff --git a/options.c b/options.c index 7a22fe4d..26356ffd 100644 --- a/options.c +++ b/options.c @@ -4277,7 +4277,8 @@ static void show_closest_option(const char *opt) i++; } - if (best_option != -1 && string_distance_ok(name, best_distance)) + if (best_option != -1 && string_distance_ok(name, best_distance) && + fio_options[best_option].type != FIO_OPT_UNSUPPORTED) log_err("Did you mean %s?\n", fio_options[best_option].name); free(name); diff --git a/options.h b/options.h index 4727bac2..539a6366 100644 --- a/options.h +++ b/options.h @@ -47,19 +47,8 @@ static inline bool o_match(struct fio_option *o, const char *opt) return false; } -static inline struct fio_option *find_option(struct fio_option *options, - const char *opt) -{ - struct fio_option *o; - - for (o = &options[0]; o->name; o++) - if (o_match(o, opt)) - return o; - - return NULL; -} - -extern struct fio_option *fio_option_find(const char *name); +extern struct fio_option *find_option(struct fio_option *, const char *); +extern struct fio_option *fio_option_find(const char *); extern unsigned int fio_get_kb_base(void *); #endif diff --git a/parse.c b/parse.c index 963f1f8c..bb16bc16 100644 --- a/parse.c +++ b/parse.c @@ -906,6 +906,25 @@ static int handle_option(struct fio_option *o, const char *__ptr, void *data) return ret; } +struct fio_option *find_option(struct fio_option *options, const char *opt) +{ + struct fio_option *o; + + for (o = &options[0]; o->name; o++) { + if (!o_match(o, opt)) + continue; + if (o->type == FIO_OPT_UNSUPPORTED) { + log_err("Option <%s>: %s\n", o->name, o->help); + continue; + } + + return o; + } + + return NULL; +} + + static struct fio_option *get_option(char *opt, struct fio_option *options, char **post) { @@ -1232,7 +1251,7 @@ void fill_default_options(void *data, struct fio_option *options) void option_init(struct fio_option *o) { - if (o->type == FIO_OPT_DEPRECATED) + if (o->type == FIO_OPT_DEPRECATED || o->type == FIO_OPT_UNSUPPORTED) return; if (o->name && !o->lname) log_err("Option %s: missing long option name\n", o->name); diff --git a/parse.h b/parse.h index 77450ef5..aa00a679 100644 --- a/parse.h +++ b/parse.h @@ -20,6 +20,7 @@ enum fio_opt_type { FIO_OPT_FLOAT_LIST, FIO_OPT_STR_SET, FIO_OPT_DEPRECATED, + FIO_OPT_UNSUPPORTED, }; /*