parse: add posval support to FIO_OPT_INT
[fio.git] / parse.c
diff --git a/parse.c b/parse.c
index 5b8e10f9f2e936ef55817c2d44b291e7c868e9f4..dddcb8e51cc007634c60050de0a812f7518ca8c1 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -465,6 +465,24 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                                        " (%u min)\n", ull, o->minval);
                        return 1;
                }
+               if (o->posval[0].ival) {
+                       posval_sort(o, posval);
+
+                       ret = 1;
+                       for (i = 0; i < PARSE_MAX_VP; i++) {
+                               vp = &posval[i];
+                               if (!vp->ival || vp->ival[0] == '\0')
+                                       continue;
+                               if (vp->oval == ull) {
+                                       ret = 0;
+                                       break;
+                               }
+                       }
+                       if (ret) {
+                               log_err("value %d not in allowed range\n",ull);
+                               return 1;
+                       }
+               }
 
                if (fn)
                        ret = fn(data, &ull);