2 * This file contains the ini and command liner parser main.
12 #include "compiler/compiler.h"
19 #include "lib/ieee754.h"
22 #ifdef CONFIG_ARITHMETIC
26 static const char *opt_type_names[] = {
41 "OPT_SOFT_DEPRECATED",
45 static const struct fio_option *__fio_options;
47 static int vp_cmp(const void *p1, const void *p2)
49 const struct value_pair *vp1 = p1;
50 const struct value_pair *vp2 = p2;
52 return strlen(vp2->ival) - strlen(vp1->ival);
55 static void posval_sort(const struct fio_option *o, struct value_pair *vpmap)
57 const struct value_pair *vp;
60 memset(vpmap, 0, PARSE_MAX_VP * sizeof(struct value_pair));
62 for (entries = 0; entries < PARSE_MAX_VP; entries++) {
63 vp = &o->posval[entries];
64 if (!vp->ival || vp->ival[0] == '\0')
67 memcpy(&vpmap[entries], vp, sizeof(*vp));
70 qsort(vpmap, entries, sizeof(struct value_pair), vp_cmp);
73 static void show_option_range(const struct fio_option *o,
74 ssize_t (*logger)(const char *format, ...))
76 if (o->type == FIO_OPT_FLOAT_LIST) {
78 if (!o->minfp && !o->maxfp)
81 logger("%20s: ", "range");
82 if (o->minfp != DBL_MIN) {
83 logger("min=%f", o->minfp);
86 if (o->maxfp != DBL_MAX)
87 logger("%smax=%f", sep, o->maxfp);
89 } else if (!o->posval[0].ival) {
90 if (!o->minval && !o->maxval)
93 logger("%20s: min=%d", "range", o->minval);
95 logger(", max=%d", o->maxval);
100 static void show_option_values(const struct fio_option *o)
104 for (i = 0; i < PARSE_MAX_VP; i++) {
105 const struct value_pair *vp = &o->posval[i];
110 log_info("%20s: %-10s", i == 0 ? "valid values" : "", vp->ival);
112 log_info(" %s", vp->help);
120 static void show_option_help(const struct fio_option *o, int is_err)
122 const char *typehelp[] = {
126 "string with possible k/m/g postfix (opt=4k)",
127 "string with time postfix (opt=10s)",
129 "string with dual range (opt=1k-4k,4k-8k)",
130 "integer value (opt=100)",
131 "boolean value (opt=1)",
132 "list of floating point values separated by ':' (opt=5.9:7.8)",
137 ssize_t (*logger)(const char *format, ...);
145 logger("%20s: %s\n", "alias", o->alias);
147 logger("%20s: %s\n", "type", typehelp[o->type]);
148 logger("%20s: %s\n", "default", o->def ? o->def : "no default");
150 logger("%20s: only for profile '%s'\n", "valid", o->prof_name);
151 show_option_range(o, logger);
152 show_option_values(o);
155 static unsigned long long get_mult_time(const char *str, int len,
160 unsigned long long mult = 1;
164 * Go forward until we hit a non-digit, or +/- sign
166 while ((p - str) <= len) {
167 if (!isdigit((int) *p) && (*p != '+') && (*p != '-'))
172 if (!isalpha((int) *p)) {
180 for (i = 0; i < strlen(c); i++)
181 c[i] = tolower((unsigned char)c[i]);
183 if (!strncmp("us", c, 2) || !strncmp("usec", c, 4))
185 else if (!strncmp("ms", c, 2) || !strncmp("msec", c, 4))
187 else if (!strcmp("s", c))
189 else if (!strcmp("m", c))
190 mult = 60 * 1000000UL;
191 else if (!strcmp("h", c))
192 mult = 60 * 60 * 1000000UL;
193 else if (!strcmp("d", c))
194 mult = 24 * 60 * 60 * 1000000ULL;
200 static int is_separator(char c)
213 static unsigned long long __get_mult_bytes(const char *p, void *data,
216 unsigned int kb_base = fio_get_kb_base(data);
217 unsigned long long ret = 1;
218 unsigned int i, pow = 0, mult = kb_base;
226 for (i = 0; i < strlen(c); i++) {
227 c[i] = tolower((unsigned char)c[i]);
228 if (is_separator(c[i])) {
234 /* If kb_base is 1000, use true units.
235 * If kb_base is 1024, use opposite units.
237 if (!strncmp("pib", c, 3)) {
241 else if (kb_base == 1024)
243 } else if (!strncmp("tib", c, 3)) {
247 else if (kb_base == 1024)
249 } else if (!strncmp("gib", c, 3)) {
253 else if (kb_base == 1024)
255 } else if (!strncmp("mib", c, 3)) {
259 else if (kb_base == 1024)
261 } else if (!strncmp("kib", c, 3)) {
265 else if (kb_base == 1024)
267 } else if (!strncmp("p", c, 1) || !strncmp("pb", c, 2)) {
269 } else if (!strncmp("t", c, 1) || !strncmp("tb", c, 2)) {
271 } else if (!strncmp("g", c, 1) || !strncmp("gb", c, 2)) {
273 } else if (!strncmp("m", c, 1) || !strncmp("mb", c, 2)) {
275 } else if (!strncmp("k", c, 1) || !strncmp("kb", c, 2)) {
277 } else if (!strncmp("%", c, 1)) {
284 ret *= (unsigned long long) mult;
290 static unsigned long long get_mult_bytes(const char *str, int len, void *data,
297 return __get_mult_bytes(str, data, percent);
300 * Go forward until we hit a non-digit, or +/- sign
302 while ((p - str) <= len) {
303 if (!isdigit((int) *p) &&
304 (((*p != '+') && (*p != '-')) || digit_seen))
306 digit_seen |= isdigit((int) *p);
310 if (!isalpha((int) *p) && (*p != '%'))
313 return __get_mult_bytes(p, data, percent);
316 extern int evaluate_arithmetic_expression(const char *buffer, long long *ival,
317 double *dval, double implied_units,
321 * Convert string into a floating number. Return 1 for success and 0 otherwise.
323 int str_to_float(const char *str, double *val, int is_time)
325 #ifdef CONFIG_ARITHMETIC
331 rc = evaluate_arithmetic_expression(str, &ival, &dval, 1.0, is_time);
338 return 1 == sscanf(str, "%lf", val);
342 * convert string into decimal value, noting any size suffix
344 int str_to_decimal(const char *str, long long *val, int kilo, void *data,
345 int is_seconds, int is_time)
349 #ifdef CONFIG_ARITHMETIC
352 double implied_units = 1.0;
359 #ifdef CONFIG_ARITHMETIC
361 implied_units = 1000000.0;
363 rc = evaluate_arithmetic_expression(str, &ival, &dval, implied_units, is_time);
364 if (str[0] == '(' && !rc) {
365 if (!kilo && is_seconds)
366 *val = ival / 1000000LL;
373 if (strstr(str, "0x") || strstr(str, "0X"))
378 *val = strtoll(str, NULL, base);
379 if (*val == LONG_MAX && errno == ERANGE)
384 unsigned long long mult;
387 mult = get_mult_bytes(str, len, data, &perc);
393 *val *= get_mult_time(str, len, is_seconds);
398 int check_str_bytes(const char *p, long long *val, void *data)
400 return str_to_decimal(p, val, 1, data, 0, 0);
403 int check_str_time(const char *p, long long *val, int is_seconds)
405 return str_to_decimal(p, val, 0, NULL, is_seconds, 1);
408 void strip_blank_front(char **p)
414 while (isspace((int) *s))
420 void strip_blank_end(char *p)
437 while ((isspace((int) *s) || iscntrl((int) *s)) && (s > start))
443 static int check_range_bytes(const char *str, long long *val, void *data)
447 if (!str_to_decimal(str, &__val, 1, data, 0, 0)) {
455 static int check_int(const char *p, int *val)
459 if (strstr(p, "0x") || strstr(p, "0X")) {
460 if (sscanf(p, "%x", val) == 1)
463 if (sscanf(p, "%u", val) == 1)
470 static size_t opt_len(const char *str)
474 postfix = strchr(str, ':');
478 return (int)(postfix - str);
481 static int str_match_len(const struct value_pair *vp, const char *str)
483 return max(strlen(vp->ival), opt_len(str));
486 #define val_store(ptr, val, off, or, data, o) \
488 ptr = td_var((data), (o), (off)); \
495 static const char *opt_type_name(const struct fio_option *o)
497 compiletime_assert(ARRAY_SIZE(opt_type_names) - 1 == FIO_OPT_UNSUPPORTED,
498 "opt_type_names[] index");
500 if (o->type <= FIO_OPT_UNSUPPORTED)
501 return opt_type_names[o->type];
503 return "OPT_UNKNOWN?";
506 static int __handle_option(const struct fio_option *o, const char *ptr,
507 void *data, int first, int more, int curr)
511 long long ull, *ullp;
513 long long ull1, ull2;
516 int ret = 0, is_time = 0;
517 const struct value_pair *vp;
518 struct value_pair posval[PARSE_MAX_VP];
519 int i, all_skipped = 1;
521 dprint(FD_PARSE, "__handle_option=%s, type=%s, ptr=%s\n", o->name,
522 opt_type_name(o), ptr);
524 if (!ptr && o->type != FIO_OPT_STR_SET && o->type != FIO_OPT_STR) {
525 log_err("Option %s requires an argument\n", o->name);
531 case FIO_OPT_STR_ULL:
532 case FIO_OPT_STR_MULTI: {
533 fio_opt_str_fn *fn = o->cb;
535 posval_sort(o, posval);
538 for (i = 0; i < PARSE_MAX_VP; i++) {
540 if (!vp->ival || vp->ival[0] == '\0')
545 if (!strncmp(vp->ival, ptr, str_match_len(vp, ptr))) {
549 if (o->type == FIO_OPT_STR_ULL)
550 val_store(ullp, vp->oval, o->off1, vp->orval, data, o);
552 val_store(ilp, vp->oval, o->off1, vp->orval, data, o);
557 if (ret && !all_skipped)
558 show_option_values(o);
563 case FIO_OPT_STR_VAL_TIME:
568 case FIO_OPT_STR_VAL: {
569 fio_opt_str_val_fn *fn = o->cb;
572 if (!is_time && o->is_time)
573 is_time = o->is_time;
575 tmp[sizeof(tmp) - 1] = '\0';
576 strncpy(tmp, ptr, sizeof(tmp) - 1);
577 p = strchr(tmp, ',');
582 ret = check_str_time(tmp, &ull, o->is_seconds);
584 ret = check_str_bytes(tmp, &ull, data);
586 dprint(FD_PARSE, " ret=%d, out=%llu\n", ret, ull);
590 if (o->pow2 && !is_power_of_2(ull)) {
591 log_err("%s: must be a power-of-2\n", o->name);
595 if (o->maxval && ull > o->maxval) {
596 log_err("max value out of range: %llu"
597 " (%llu max)\n", ull, o->maxval);
600 if (o->minval && ull < o->minval) {
601 log_err("min value out of range: %lld"
602 " (%d min)\n", ull, o->minval);
605 if (o->posval[0].ival) {
606 posval_sort(o, posval);
609 for (i = 0; i < PARSE_MAX_VP; i++) {
611 if (!vp->ival || vp->ival[0] == '\0')
613 if (vp->oval == ull) {
619 log_err("fio: value %llu not allowed:\n", ull);
620 show_option_values(o);
626 ret = fn(data, &ull);
628 if (o->type == FIO_OPT_INT) {
630 val_store(ilp, ull, o->off1, 0, data, o);
633 val_store(ilp, ull, o->off2, 0, data, o);
637 val_store(ilp, ull, o->off3, 0, data, o);
642 val_store(ilp, ull, o->off2, 0, data, o);
646 val_store(ilp, ull, o->off3, 0, data, o);
649 } else if (o->type == FIO_OPT_ULL) {
651 val_store(ullp, ull, o->off1, 0, data, o);
654 val_store(ullp, ull, o->off2, 0, data, o);
658 val_store(ullp, ull, o->off3, 0, data, o);
663 val_store(ullp, ull, o->off2, 0, data, o);
667 val_store(ullp, ull, o->off3, 0, data, o);
672 val_store(ullp, ull, o->off1, 0, data, o);
675 val_store(ullp, ull, o->off2, 0, data, o);
681 case FIO_OPT_FLOAT_LIST: {
686 ** Initialize precision to 0 and zero out list
687 ** in case specified list is shorter than default
691 ilp = td_var(data, o, o->off2);
695 flp = td_var(data, o, o->off1);
696 for(i = 0; i < o->maxlen; i++)
699 if (curr >= o->maxlen) {
700 log_err("the list exceeding max length %d\n",
704 if (!str_to_float(ptr, &uf, 0)) { /* this breaks if we ever have lists of times */
705 log_err("not a floating point value: %s\n", ptr);
708 if (o->minfp || o->maxfp) {
710 log_err("value out of range: %f"
711 " (range max: %f)\n", uf, o->maxfp);
715 log_err("value out of range: %f"
716 " (range min: %f)\n", uf, o->minfp);
721 flp = td_var(data, o, o->off1);
724 dprint(FD_PARSE, " out=%f\n", uf);
727 ** Calculate precision for output by counting
728 ** number of digits after period. Find first
729 ** period in entire remaining list each time
731 cp2 = strchr(ptr, '.');
735 while (*++cp2 != '\0' && *cp2 >= '0' && *cp2 <= '9')
739 ilp = td_var(data, o, o->off2);
747 case FIO_OPT_STR_STORE: {
748 fio_opt_str_fn *fn = o->cb;
754 cp = td_var(data, o, o->off1);
760 else if (o->posval[0].ival) {
761 posval_sort(o, posval);
764 for (i = 0; i < PARSE_MAX_VP; i++) {
766 if (!vp->ival || vp->ival[0] == '\0' || !cp)
769 if (!strncmp(vp->ival, ptr, str_match_len(vp, ptr))) {
775 rest = strstr(*cp ?: ptr, ":");
789 show_option_values(o);
798 case FIO_OPT_RANGE: {
802 tmp[sizeof(tmp) - 1] = '\0';
803 strncpy(tmp, ptr, sizeof(tmp) - 1);
805 /* Handle bsrange with separate read,write values: */
806 p1 = strchr(tmp, ',');
810 p1 = strchr(tmp, '-');
812 p1 = strchr(tmp, ':');
824 if (!check_range_bytes(p1, &ull1, data) &&
825 !check_range_bytes(p2, &ull2, data)) {
828 unsigned long long foo = ull1;
835 val_store(ullp, ull1, o->off1, 0, data, o);
836 val_store(ullp, ull2, o->off2, 0, data, o);
839 if (o->off3 && o->off4) {
840 val_store(ullp, ull1, o->off3, 0, data, o);
841 val_store(ullp, ull2, o->off4, 0, data, o);
845 if (o->off5 && o->off6) {
846 val_store(ullp, ull1, o->off5, 0, data, o);
847 val_store(ullp, ull2, o->off6, 0, data, o);
852 if (o->off3 && o->off4) {
853 val_store(ullp, ull1, o->off3, 0, data, o);
854 val_store(ullp, ull2, o->off4, 0, data, o);
858 if (o->off5 && o->off6) {
859 val_store(ullp, ull1, o->off5, 0, data, o);
860 val_store(ullp, ull2, o->off6, 0, data, o);
869 case FIO_OPT_STR_SET: {
870 fio_opt_int_fn *fn = o->cb;
873 ret = check_int(ptr, &il);
874 else if (o->type == FIO_OPT_BOOL)
879 dprint(FD_PARSE, " ret=%d, out=%d\n", ret, il);
884 if (o->maxval && il > (int) o->maxval) {
885 log_err("max value out of range: %d (%llu max)\n",
889 if (o->minval && il < o->minval) {
890 log_err("min value out of range: %d (%d min)\n",
902 val_store(ilp, il, o->off1, 0, data, o);
905 val_store(ilp, il, o->off2, 0, data, o);
910 case FIO_OPT_DEPRECATED:
913 case FIO_OPT_SOFT_DEPRECATED:
914 log_info("Option %s is deprecated\n", o->name);
917 log_err("Bad option type %u\n", o->type);
925 ret = o->verify(o, data);
927 log_err("Correct format for offending option\n");
928 log_err("%20s: %s\n", o->name, o->help);
929 show_option_help(o, 1);
936 static int handle_option(const struct fio_option *o, const char *__ptr,
939 char *o_ptr, *ptr, *ptr2;
942 dprint(FD_PARSE, "handle_option=%s, ptr=%s\n", o->name, __ptr);
946 o_ptr = ptr = strdup(__ptr);
949 * See if we have another set of parameters, hidden after a comma.
950 * Do this before parsing this round, to check if we should
951 * copy set 1 options to set 2.
960 (o->type != FIO_OPT_STR_STORE) &&
961 (o->type != FIO_OPT_STR) &&
962 (o->type != FIO_OPT_FLOAT_LIST)) {
963 ptr2 = strchr(ptr, ',');
964 if (ptr2 && *(ptr2 + 1) == '\0')
966 if (o->type != FIO_OPT_STR_MULTI && o->type != FIO_OPT_RANGE) {
968 ptr2 = strchr(ptr, ':');
970 ptr2 = strchr(ptr, '-');
972 } else if (ptr && o->type == FIO_OPT_FLOAT_LIST) {
973 ptr2 = strchr(ptr, ':');
977 * Don't return early if parsing the first option fails - if
978 * we are doing multiple arguments, we can allow the first one
981 __ret = __handle_option(o, ptr, data, !done, !!ptr2, done);
997 struct fio_option *find_option(struct fio_option *options, const char *opt)
999 struct fio_option *o;
1001 for (o = &options[0]; o->name; o++) {
1002 if (!o_match(o, opt))
1004 if (o->type == FIO_OPT_UNSUPPORTED) {
1005 log_err("Option <%s>: %s\n", o->name, o->help);
1015 const struct fio_option *
1016 find_option_c(const struct fio_option *options, const char *opt)
1018 return find_option((struct fio_option *)options, opt);
1021 static const struct fio_option *
1022 get_option(char *opt, const struct fio_option *options, char **post)
1024 const struct fio_option *o;
1027 ret = strchr(opt, '=');
1033 strip_blank_end(ret);
1034 o = find_option_c(options, ret);
1036 o = find_option_c(options, opt);
1043 static int opt_cmp(const void *p1, const void *p2)
1045 const struct fio_option *o;
1052 s = strdup(*((char **) p1));
1053 o = get_option(s, __fio_options, &foo);
1059 s = strdup(*((char **) p2));
1060 o = get_option(s, __fio_options, &foo);
1066 return prio2 - prio1;
1069 void sort_options(char **opts, const struct fio_option *options, int num_opts)
1071 __fio_options = options;
1072 qsort(opts, num_opts, sizeof(char *), opt_cmp);
1073 __fio_options = NULL;
1076 static void add_to_dump_list(const struct fio_option *o,
1077 struct flist_head *dump_list, const char *post)
1079 struct print_option *p;
1084 p = malloc(sizeof(*p));
1085 p->name = strdup(o->name);
1087 p->value = strdup(post);
1091 flist_add_tail(&p->list, dump_list);
1094 int parse_cmd_option(const char *opt, const char *val,
1095 const struct fio_option *options, void *data,
1096 struct flist_head *dump_list)
1098 const struct fio_option *o;
1100 o = find_option_c(options, opt);
1102 log_err("Bad option <%s>\n", opt);
1106 if (handle_option(o, val, data)) {
1107 log_err("fio: failed parsing %s=%s\n", opt, val);
1111 add_to_dump_list(o, dump_list, val);
1115 int parse_option(char *opt, const char *input, const struct fio_option *options,
1116 const struct fio_option **o, void *data,
1117 struct flist_head *dump_list)
1122 log_err("fio: failed parsing %s\n", input);
1127 *o = get_option(opt, options, &post);
1130 int len = strlen(opt);
1131 if (opt + len + 1 != post)
1132 memmove(opt + len + 1, post, strlen(post));
1138 if (handle_option(*o, post, data)) {
1139 log_err("fio: failed parsing %s\n", input);
1143 add_to_dump_list(*o, dump_list, post);
1148 * Option match, levenshtein distance. Handy for not quite remembering what
1149 * the option name is.
1151 int string_distance(const char *s1, const char *s2)
1153 unsigned int s1_len = strlen(s1);
1154 unsigned int s2_len = strlen(s2);
1155 unsigned int *p, *q, *r;
1158 p = malloc(sizeof(unsigned int) * (s2_len + 1));
1159 q = malloc(sizeof(unsigned int) * (s2_len + 1));
1162 for (i = 1; i <= s2_len; i++)
1163 p[i] = p[i - 1] + 1;
1165 for (i = 1; i <= s1_len; i++) {
1167 for (j = 1; j <= s2_len; j++) {
1168 unsigned int sub = p[j - 1];
1171 if (s1[i - 1] != s2[j - 1])
1174 pmin = min(q[j - 1] + 1, sub);
1175 q[j] = min(p[j] + 1, pmin);
1189 * Make a guess of whether the distance from 's1' is significant enough
1190 * to warrant printing the guess. We set this to a 1/2 match.
1192 int string_distance_ok(const char *opt, int distance)
1197 len = (len + 1) / 2;
1198 return distance <= len;
1201 static const struct fio_option *find_child(const struct fio_option *options,
1202 const struct fio_option *o)
1204 const struct fio_option *__o;
1206 for (__o = options + 1; __o->name; __o++)
1207 if (__o->parent && !strcmp(__o->parent, o->name))
1213 static void __print_option(const struct fio_option *o,
1214 const struct fio_option *org,
1226 p += sprintf(p, "%s", " ");
1228 sprintf(p, "%s", o->name);
1230 log_info("%-24s: %s\n", name, o->help);
1233 static void print_option(const struct fio_option *o)
1235 const struct fio_option *parent;
1236 const struct fio_option *__o;
1237 unsigned int printed;
1240 __print_option(o, NULL, 0);
1247 while ((__o = find_child(o, parent)) != NULL) {
1248 __print_option(__o, o, level);
1257 int show_cmd_help(const struct fio_option *options, const char *name)
1259 const struct fio_option *o, *closest;
1260 unsigned int best_dist = -1U;
1264 if (!name || !strcmp(name, "all"))
1269 for (o = &options[0]; o->name; o++) {
1272 if (o->type == FIO_OPT_DEPRECATED ||
1273 o->type == FIO_OPT_SOFT_DEPRECATED)
1275 if (!exec_profile && o->prof_name)
1277 if (exec_profile && !(o->prof_name && !strcmp(exec_profile, o->prof_name)))
1281 if (!strcmp(name, o->name) ||
1282 (o->alias && !strcmp(name, o->alias)))
1287 dist = string_distance(name, o->name);
1288 if (dist < best_dist) {
1295 if (show_all || match) {
1298 log_info("%20s: %s\n", o->name, o->help);
1309 show_option_help(o, 0);
1315 log_err("No such command: %s", name);
1318 * Only print an appropriately close option, one where the edit
1319 * distance isn't too big. Otherwise we get crazy matches.
1321 if (closest && best_dist < 3) {
1322 log_info(" - showing closest match\n");
1323 log_info("%20s: %s\n", closest->name, closest->help);
1324 show_option_help(closest, 0);
1332 * Handle parsing of default parameters.
1334 void fill_default_options(void *data, const struct fio_option *options)
1336 const struct fio_option *o;
1338 dprint(FD_PARSE, "filling default options\n");
1340 for (o = &options[0]; o->name; o++)
1342 handle_option(o, o->def, data);
1345 static void option_init(struct fio_option *o)
1347 if (o->type == FIO_OPT_DEPRECATED || o->type == FIO_OPT_UNSUPPORTED ||
1348 o->type == FIO_OPT_SOFT_DEPRECATED)
1350 if (o->name && !o->lname)
1351 log_err("Option %s: missing long option name\n", o->name);
1352 if (o->type == FIO_OPT_BOOL) {
1356 if (o->type == FIO_OPT_INT) {
1358 o->maxval = UINT_MAX;
1360 if (o->type == FIO_OPT_ULL) {
1362 o->maxval = ULLONG_MAX;
1364 if (o->type == FIO_OPT_STR_SET && o->def && !o->no_warn_def) {
1365 log_err("Option %s: string set option with"
1366 " default will always be true\n", o->name);
1368 if (!o->cb && !o->off1)
1369 log_err("Option %s: neither cb nor offset given\n", o->name);
1371 log_info("Option %s: no category defined. Setting to misc\n", o->name);
1372 o->category = FIO_OPT_C_GENERAL;
1373 o->group = FIO_OPT_G_INVALID;
1375 if (o->type == FIO_OPT_STR || o->type == FIO_OPT_STR_STORE ||
1376 o->type == FIO_OPT_STR_MULTI)
1381 * Sanitize the options structure. For now it just sets min/max for bool
1382 * values and whether both callback and offsets are given.
1384 void options_init(struct fio_option *options)
1386 struct fio_option *o;
1388 dprint(FD_PARSE, "init options\n");
1390 for (o = &options[0]; o->name; o++) {
1393 o->inv_opt = find_option(options, o->inverse);
1397 void options_mem_dupe(const struct fio_option *options, void *data)
1399 const struct fio_option *o;
1402 dprint(FD_PARSE, "dup options\n");
1404 for (o = &options[0]; o->name; o++) {
1405 if (o->type != FIO_OPT_STR_STORE)
1408 ptr = td_var(data, o, o->off1);
1410 *ptr = strdup(*ptr);
1414 void options_free(const struct fio_option *options, void *data)
1416 const struct fio_option *o;
1419 dprint(FD_PARSE, "free options\n");
1421 for (o = &options[0]; o->name; o++) {
1422 if (o->type != FIO_OPT_STR_STORE || !o->off1 || o->no_free)
1425 ptr = td_var(data, o, o->off1);