parse: add support for unsupported options
authorJens Axboe <axboe@fb.com>
Wed, 8 Jun 2016 16:58:07 +0000 (10:58 -0600)
committerJens Axboe <axboe@fb.com>
Wed, 8 Jun 2016 16:58:07 +0000 (10:58 -0600)
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 <axboe@fb.com>
options.c
options.h
parse.c
parse.h

index 7a22fe4de7352a3e78c7813d97c24e2583adfbb1..26356ffdf12c9b4ca78dc99f08edbe040c53ac23 100644 (file)
--- 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);
index 4727bac222ce33169b5f3dd213b5c931365c8f80..539a63667afb505ad6b61a8bc9b299297a8ed9dd 100644 (file)
--- 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 963f1f8cdc1f25f26a77a4471aa04a7c617fa43f..bb16bc166af3696030ba0bef436487364901b29b 100644 (file)
--- 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 77450ef582403776ef32a93a645468f2e5b941b3..aa00a679ef4fd918f0260b25d0e32b38ae83ad7b 100644 (file)
--- 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,
 };
 
 /*