[PATCH] Show allowed option values for string matching
authorJens Axboe <jens.axboe@oracle.com>
Wed, 10 Jan 2007 11:26:18 +0000 (12:26 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 10 Jan 2007 11:26:18 +0000 (12:26 +0100)
Helpful to avoid looking in the documentation.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
init.c
parse.c
parse.h

diff --git a/init.c b/init.c
index 37b84e68bb1ded485f828e4843bfeacbd3863e0c..11fd3e283f0c2f7026b68cca1e825515085d8b6a 100644 (file)
--- a/init.c
+++ b/init.c
@@ -63,29 +63,35 @@ static struct fio_option options[] = {
                .name   = "rw",
                .type   = FIO_OPT_STR,
                .cb     = str_rw_cb,
-               .help   = "IO direction (read, write, rw, etc)",
+               .help   = "IO direction",
                .def    = "read",
+               .posval = { "read", "write", "randwrite", "randread", "rw",
+                               "randrw", },
        },
        {
                .name   = "ioengine",
                .type   = FIO_OPT_STR,
                .cb     = str_ioengine_cb,
-               .help   = "IO engine to use (sync, aio, etc)",
+               .help   = "IO engine to use",
                .def    = "sync",
+               .posval = { "sync", "libaio", "posixaio", "mmap", "splice",
+                               "sg", "null", },
        },
        {
                .name   = "mem",
                .type   = FIO_OPT_STR,
                .cb     = str_mem_cb,
-               .help   = "Backing type for IO buffers (malloc, shm, etc)",
+               .help   = "Backing type for IO buffers",
                .def    = "malloc",
+               .posval =  { "malloc", "shm", "shmhuge", "mmap", "mmaphuge", },
        },
        {
                .name   = "verify",
                .type   = FIO_OPT_STR,
                .cb     = str_verify_cb,
-               .help   = "Verify sum function (md5 or crc32)",
+               .help   = "Verify sum function",
                .def    = "0",
+               .posval = { "crc32", "md5", },
        },
        {
                .name   = "write_iolog",
@@ -226,6 +232,7 @@ static struct fio_option options[] = {
                .type   = FIO_OPT_INT,
                .off1   = td_var_offset(nice),
                .help   = "Set job CPU nice value",
+               .minval = -19,
                .maxval = 20,
                .def    = "0",
        },
@@ -235,12 +242,16 @@ static struct fio_option options[] = {
                .type   = FIO_OPT_INT,
                .cb     = str_prio_cb,
                .help   = "Set job IO priority value",
+               .minval = 0,
+               .maxval = 7,
        },
        {
                .name   = "prioclass",
                .type   = FIO_OPT_INT,
                .cb     = str_prioclass_cb,
                .help   = "Set job IO priority class",
+               .minval = 0,
+               .maxval = 3,
        },
 #endif
        {
diff --git a/parse.c b/parse.c
index 2e8a2a520f3906a66e608a7900f02c7a8f534221..5347f675b07e6d7a88d6a6ade63bbcd0574f129b 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -366,6 +366,38 @@ int parse_option(const char *opt, struct fio_option *options, void *data)
        return 1;
 }
 
+static void show_option_range(struct fio_option *o)
+{
+       if (!o->minval && !o->maxval)
+               return;
+
+       printf("%16s: min=%d, max=%d\n", "range", o->minval, o->maxval);
+}
+
+static void show_option_values(struct fio_option *o)
+{
+       const char *msg;
+       int i = 0;
+
+       if (!o->posval)
+               return;
+
+       do {
+               msg = o->posval[i];
+               if (!msg)
+                       break;
+
+               if (!i)
+                       printf("%16s: ", "valid values");
+
+               printf("%s,", msg);
+               i++;
+       } while (1);
+
+       if (i)
+               printf("\n");
+}
+
 int show_cmd_help(struct fio_option *options, const char *name)
 {
        int show_all = !strcmp(name, "all");
@@ -391,6 +423,8 @@ int show_cmd_help(struct fio_option *options, const char *name)
                        if (match) {
                                printf("%16s: %s\n", "type", typehelp[o->type]);
                                printf("%16s: %s\n", "default", o->def ? o->def : "no default");
+                               show_option_range(o);
+                               show_option_values(o);
                        }
                }
 
diff --git a/parse.h b/parse.h
index edba7fc6b0256261906b6c4820a3899dc71281ed..3e3c9d9f596c59b9c4e6b6b5269c097adf04fceb 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -30,6 +30,7 @@ struct fio_option {
        void *cb;                       /* callback */
        const char *help;               /* help text for option */
        const char *def;                /* default setting */
+       const char *posval[16];         /* possible values */
 };
 
 typedef int (str_cb_fn)(void *, char *);