X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=parse.c;h=9a6494f32db811746ba46303b5f300a83e1ddfc6;hp=9891974d57bca8bd62752f78e421a8b6978d62f3;hb=f982d35f5ae88f728c6853aaf57448db8f5fcf98;hpb=6a4cf74fc2521b601cb1cc9478526cc441830a5c diff --git a/parse.c b/parse.c index 9891974d..9a6494f3 100644 --- a/parse.c +++ b/parse.c @@ -16,7 +16,6 @@ #include "options.h" static struct fio_option *__fio_options; -extern unsigned int fio_get_kb_base(void *); static int vp_cmp(const void *p1, const void *p2) { @@ -47,7 +46,7 @@ static void posval_sort(struct fio_option *o, struct value_pair *vpmap) static void show_option_range(struct fio_option *o, int (*logger)(const char *format, ...)) { - if (o->type == FIO_OPT_FLOAT_LIST){ + if (o->type == FIO_OPT_FLOAT_LIST) { if (isnan(o->minfp) && isnan(o->maxfp)) return; @@ -356,7 +355,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, int first, int more, int curr) { int il, *ilp; - double* flp; + double *flp; long long ull, *ullp; long ul1, ul2; double uf; @@ -414,23 +413,29 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, case FIO_OPT_INT: case FIO_OPT_STR_VAL: { fio_opt_str_val_fn *fn = o->cb; + char tmp[128], *p; + + strncpy(tmp, ptr, sizeof(tmp) - 1); + p = strchr(tmp, ','); + if (p) + *p = '\0'; if (is_time) - ret = check_str_time(ptr, &ull); + ret = check_str_time(tmp, &ull); else - ret = check_str_bytes(ptr, &ull, data); + ret = check_str_bytes(tmp, &ull, data); if (ret) break; if (o->maxval && ull > o->maxval) { - log_err("max value out of range: %lld" - " (%d max)\n", ull, o->maxval); + log_err("max value out of range: %llu" + " (%u max)\n", ull, o->maxval); return 1; } if (o->minval && ull < o->minval) { - log_err("min value out of range: %lld" - " (%d min)\n", ull, o->minval); + log_err("min value out of range: %llu" + " (%u min)\n", ull, o->minval); return 1; } @@ -444,12 +449,32 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, else val_store(ilp, ull, o->off1, 0, data); } - if (!more) { + if (curr == 1) { if (o->roff2) *(unsigned int *) o->roff2 = ull; else if (o->off2) val_store(ilp, ull, o->off2, 0, data); } + if (curr == 2) { + if (o->roff3) + *(unsigned int *) o->roff3 = ull; + else if (o->off3) + val_store(ilp, ull, o->off3, 0, data); + } + if (!more) { + if (curr < 1) { + if (o->roff2) + *(unsigned int *) o->roff2 = ull; + else if (o->off2) + val_store(ilp, ull, o->off2, 0, data); + } + if (curr < 2) { + if (o->roff3) + *(unsigned int *) o->roff3 = ull; + else if (o->off3) + val_store(ilp, ull, o->off3, 0, data); + } + } } else { if (first) { if (o->roff1) @@ -479,7 +504,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, o->maxlen); return 1; } - if(!str_to_float(ptr, &uf)){ + if (!str_to_float(ptr, &uf)) { log_err("not a floating point value: %s\n", ptr); return 1; } @@ -598,12 +623,43 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, else val_store(ilp, ul2, o->off2, 0, data); } - if (o->roff3 && o->roff4) { - *(unsigned int *) o->roff3 = ul1; - *(unsigned int *) o->roff4 = ul2; - } else if (o->off3 && o->off4) { - val_store(ilp, ul1, o->off3, 0, data); - val_store(ilp, ul2, o->off4, 0, data); + if (curr == 1) { + if (o->roff3 && o->roff4) { + *(unsigned int *) o->roff3 = ul1; + *(unsigned int *) o->roff4 = ul2; + } else if (o->off3 && o->off4) { + val_store(ilp, ul1, o->off3, 0, data); + val_store(ilp, ul2, o->off4, 0, data); + } + } + if (curr == 2) { + if (o->roff5 && o->roff6) { + *(unsigned int *) o->roff5 = ul1; + *(unsigned int *) o->roff6 = ul2; + } else if (o->off5 && o->off6) { + val_store(ilp, ul1, o->off5, 0, data); + val_store(ilp, ul2, o->off6, 0, data); + } + } + if (!more) { + if (curr < 1) { + if (o->roff3 && o->roff4) { + *(unsigned int *) o->roff3 = ul1; + *(unsigned int *) o->roff4 = ul2; + } else if (o->off3 && o->off4) { + val_store(ilp, ul1, o->off3, 0, data); + val_store(ilp, ul2, o->off4, 0, data); + } + } + if (curr < 2) { + if (o->roff5 && o->roff6) { + *(unsigned int *) o->roff5 = ul1; + *(unsigned int *) o->roff6 = ul2; + } else if (o->off5 && o->off6) { + val_store(ilp, ul1, o->off5, 0, data); + val_store(ilp, ul2, o->off6, 0, data); + } + } } } @@ -707,7 +763,7 @@ static int handle_option(struct fio_option *o, const char *__ptr, void *data) ptr2 = strchr(ptr, ','); if (ptr2 && *(ptr2 + 1) == '\0') *ptr2 = '\0'; - if (o->type != FIO_OPT_STR_MULTI) { + if (o->type != FIO_OPT_STR_MULTI && o->type != FIO_OPT_RANGE) { if (!ptr2) ptr2 = strchr(ptr, ':'); if (!ptr2) @@ -833,9 +889,8 @@ int parse_option(char *opt, const char *input, return 1; } - if (!handle_option(*o, post, data)) { + if (!handle_option(*o, post, data)) return 0; - } log_err("fio: failed parsing %s\n", input); return 1; @@ -1030,6 +1085,10 @@ void option_init(struct fio_option *o) o->minval = 0; o->maxval = 1; } + if (o->type == FIO_OPT_INT) { + if (!o->maxval) + o->maxval = UINT_MAX; + } if (o->type == FIO_OPT_FLOAT_LIST) { o->minfp = NAN; o->maxfp = NAN; @@ -1047,6 +1106,10 @@ void option_init(struct fio_option *o) (o->roff1 || o->roff2 || o->roff3 || o->roff4))) { log_err("Option %s: both cb and offset given\n", o->name); } + if (!o->category) { + log_info("Options %s: no category defined. Setting to misc\n", o->name); + o->category = FIO_OPT_C_GENERAL; + } } /* @@ -1059,8 +1122,11 @@ void options_init(struct fio_option *options) dprint(FD_PARSE, "init options\n"); - for (o = &options[0]; o->name; o++) + for (o = &options[0]; o->name; o++) { option_init(o); + if (o->inverse) + o->inv_opt = find_option(options, o->inverse); + } } void options_free(struct fio_option *options, void *data)