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:
567 case FIO_OPT_STR_VAL: {
568 fio_opt_str_val_fn *fn = o->cb;
571 if (!is_time && o->is_time)
572 is_time = o->is_time;
574 tmp[sizeof(tmp) - 1] = '\0';
575 strncpy(tmp, ptr, sizeof(tmp) - 1);
576 p = strchr(tmp, ',');
581 ret = check_str_time(tmp, &ull, o->is_seconds);
583 ret = check_str_bytes(tmp, &ull, data);
585 dprint(FD_PARSE, " ret=%d, out=%llu\n", ret, ull);
589 if (o->pow2 && !is_power_of_2(ull)) {
590 log_err("%s: must be a power-of-2\n", o->name);
594 if (o->maxval && ull > o->maxval) {
595 log_err("max value out of range: %llu"
596 " (%llu max)\n", ull, o->maxval);
599 if (o->minval && ull < o->minval) {
600 log_err("min value out of range: %lld"
601 " (%d min)\n", ull, o->minval);
604 if (o->posval[0].ival) {
605 posval_sort(o, posval);
608 for (i = 0; i < PARSE_MAX_VP; i++) {
610 if (!vp->ival || vp->ival[0] == '\0')
612 if (vp->oval == ull) {
618 log_err("fio: value %llu not allowed:\n", ull);
619 show_option_values(o);
625 ret = fn(data, &ull);
627 if (o->type == FIO_OPT_INT) {
629 val_store(ilp, ull, o->off1, 0, data, o);
632 val_store(ilp, ull, o->off2, 0, data, o);
636 val_store(ilp, ull, o->off3, 0, data, o);
641 val_store(ilp, ull, o->off2, 0, data, o);
645 val_store(ilp, ull, o->off3, 0, data, o);
648 } else if (o->type == FIO_OPT_ULL) {
650 val_store(ullp, ull, o->off1, 0, data, o);
653 val_store(ullp, ull, o->off2, 0, data, o);
657 val_store(ullp, ull, o->off3, 0, data, o);
662 val_store(ullp, ull, o->off2, 0, data, o);
666 val_store(ullp, ull, o->off3, 0, data, o);
671 val_store(ullp, ull, o->off1, 0, data, o);
674 val_store(ullp, ull, o->off2, 0, data, o);
680 case FIO_OPT_FLOAT_LIST: {
685 ** Initialize precision to 0 and zero out list
686 ** in case specified list is shorter than default
690 ilp = td_var(data, o, o->off2);
694 flp = td_var(data, o, o->off1);
695 for(i = 0; i < o->maxlen; i++)
698 if (curr >= o->maxlen) {
699 log_err("the list exceeding max length %d\n",
703 if (!str_to_float(ptr, &uf, 0)) { /* this breaks if we ever have lists of times */
704 log_err("not a floating point value: %s\n", ptr);
707 if (o->minfp || o->maxfp) {
709 log_err("value out of range: %f"
710 " (range max: %f)\n", uf, o->maxfp);
714 log_err("value out of range: %f"
715 " (range min: %f)\n", uf, o->minfp);
720 flp = td_var(data, o, o->off1);
723 dprint(FD_PARSE, " out=%f\n", uf);
726 ** Calculate precision for output by counting
727 ** number of digits after period. Find first
728 ** period in entire remaining list each time
730 cp2 = strchr(ptr, '.');
734 while (*++cp2 != '\0' && *cp2 >= '0' && *cp2 <= '9')
738 ilp = td_var(data, o, o->off2);
746 case FIO_OPT_STR_STORE: {
747 fio_opt_str_fn *fn = o->cb;
753 cp = td_var(data, o, o->off1);
759 else if (o->posval[0].ival) {
760 posval_sort(o, posval);
763 for (i = 0; i < PARSE_MAX_VP; i++) {
765 if (!vp->ival || vp->ival[0] == '\0' || !cp)
768 if (!strncmp(vp->ival, ptr, str_match_len(vp, ptr))) {
774 rest = strstr(*cp ?: ptr, ":");
788 show_option_values(o);
797 case FIO_OPT_RANGE: {
801 tmp[sizeof(tmp) - 1] = '\0';
802 strncpy(tmp, ptr, sizeof(tmp) - 1);
804 /* Handle bsrange with separate read,write values: */
805 p1 = strchr(tmp, ',');
809 p1 = strchr(tmp, '-');
811 p1 = strchr(tmp, ':');
823 if (!check_range_bytes(p1, &ull1, data) &&
824 !check_range_bytes(p2, &ull2, data)) {
827 unsigned long long foo = ull1;
834 val_store(ullp, ull1, o->off1, 0, data, o);
835 val_store(ullp, ull2, o->off2, 0, data, o);
838 if (o->off3 && o->off4) {
839 val_store(ullp, ull1, o->off3, 0, data, o);
840 val_store(ullp, ull2, o->off4, 0, data, o);
844 if (o->off5 && o->off6) {
845 val_store(ullp, ull1, o->off5, 0, data, o);
846 val_store(ullp, ull2, o->off6, 0, data, o);
851 if (o->off3 && o->off4) {
852 val_store(ullp, ull1, o->off3, 0, data, o);
853 val_store(ullp, ull2, o->off4, 0, data, o);
857 if (o->off5 && o->off6) {
858 val_store(ullp, ull1, o->off5, 0, data, o);
859 val_store(ullp, ull2, o->off6, 0, data, o);
868 case FIO_OPT_STR_SET: {
869 fio_opt_int_fn *fn = o->cb;
872 ret = check_int(ptr, &il);
873 else if (o->type == FIO_OPT_BOOL)
878 dprint(FD_PARSE, " ret=%d, out=%d\n", ret, il);
883 if (o->maxval && il > (int) o->maxval) {
884 log_err("max value out of range: %d (%llu max)\n",
888 if (o->minval && il < o->minval) {
889 log_err("min value out of range: %d (%d min)\n",
901 val_store(ilp, il, o->off1, 0, data, o);
904 val_store(ilp, il, o->off2, 0, data, o);
909 case FIO_OPT_DEPRECATED:
911 case FIO_OPT_SOFT_DEPRECATED:
912 log_info("Option %s is deprecated\n", o->name);
915 log_err("Bad option type %u\n", o->type);
923 ret = o->verify(o, data);
925 log_err("Correct format for offending option\n");
926 log_err("%20s: %s\n", o->name, o->help);
927 show_option_help(o, 1);
934 static int handle_option(const struct fio_option *o, const char *__ptr,
937 char *o_ptr, *ptr, *ptr2;
940 dprint(FD_PARSE, "handle_option=%s, ptr=%s\n", o->name, __ptr);
944 o_ptr = ptr = strdup(__ptr);
947 * See if we have another set of parameters, hidden after a comma.
948 * Do this before parsing this round, to check if we should
949 * copy set 1 options to set 2.
958 (o->type != FIO_OPT_STR_STORE) &&
959 (o->type != FIO_OPT_STR) &&
960 (o->type != FIO_OPT_FLOAT_LIST)) {
961 ptr2 = strchr(ptr, ',');
962 if (ptr2 && *(ptr2 + 1) == '\0')
964 if (o->type != FIO_OPT_STR_MULTI && o->type != FIO_OPT_RANGE) {
966 ptr2 = strchr(ptr, ':');
968 ptr2 = strchr(ptr, '-');
970 } else if (ptr && o->type == FIO_OPT_FLOAT_LIST) {
971 ptr2 = strchr(ptr, ':');
975 * Don't return early if parsing the first option fails - if
976 * we are doing multiple arguments, we can allow the first one
979 __ret = __handle_option(o, ptr, data, !done, !!ptr2, done);
995 struct fio_option *find_option(struct fio_option *options, const char *opt)
997 struct fio_option *o;
999 for (o = &options[0]; o->name; o++) {
1000 if (!o_match(o, opt))
1002 if (o->type == FIO_OPT_UNSUPPORTED) {
1003 log_err("Option <%s>: %s\n", o->name, o->help);
1013 const struct fio_option *
1014 find_option_c(const struct fio_option *options, const char *opt)
1016 return find_option((struct fio_option *)options, opt);
1019 static const struct fio_option *
1020 get_option(char *opt, const struct fio_option *options, char **post)
1022 const struct fio_option *o;
1025 ret = strchr(opt, '=');
1031 strip_blank_end(ret);
1032 o = find_option_c(options, ret);
1034 o = find_option_c(options, opt);
1041 static int opt_cmp(const void *p1, const void *p2)
1043 const struct fio_option *o;
1050 s = strdup(*((char **) p1));
1051 o = get_option(s, __fio_options, &foo);
1057 s = strdup(*((char **) p2));
1058 o = get_option(s, __fio_options, &foo);
1064 return prio2 - prio1;
1067 void sort_options(char **opts, const struct fio_option *options, int num_opts)
1069 __fio_options = options;
1070 qsort(opts, num_opts, sizeof(char *), opt_cmp);
1071 __fio_options = NULL;
1074 static void add_to_dump_list(const struct fio_option *o,
1075 struct flist_head *dump_list, const char *post)
1077 struct print_option *p;
1082 p = malloc(sizeof(*p));
1083 p->name = strdup(o->name);
1085 p->value = strdup(post);
1089 flist_add_tail(&p->list, dump_list);
1092 int parse_cmd_option(const char *opt, const char *val,
1093 const struct fio_option *options, void *data,
1094 struct flist_head *dump_list)
1096 const struct fio_option *o;
1098 o = find_option_c(options, opt);
1100 log_err("Bad option <%s>\n", opt);
1104 if (handle_option(o, val, data)) {
1105 log_err("fio: failed parsing %s=%s\n", opt, val);
1109 add_to_dump_list(o, dump_list, val);
1113 int parse_option(char *opt, const char *input, const struct fio_option *options,
1114 const struct fio_option **o, void *data,
1115 struct flist_head *dump_list)
1120 log_err("fio: failed parsing %s\n", input);
1125 *o = get_option(opt, options, &post);
1128 int len = strlen(opt);
1129 if (opt + len + 1 != post)
1130 memmove(opt + len + 1, post, strlen(post));
1136 if (handle_option(*o, post, data)) {
1137 log_err("fio: failed parsing %s\n", input);
1141 add_to_dump_list(*o, dump_list, post);
1146 * Option match, levenshtein distance. Handy for not quite remembering what
1147 * the option name is.
1149 int string_distance(const char *s1, const char *s2)
1151 unsigned int s1_len = strlen(s1);
1152 unsigned int s2_len = strlen(s2);
1153 unsigned int *p, *q, *r;
1156 p = malloc(sizeof(unsigned int) * (s2_len + 1));
1157 q = malloc(sizeof(unsigned int) * (s2_len + 1));
1160 for (i = 1; i <= s2_len; i++)
1161 p[i] = p[i - 1] + 1;
1163 for (i = 1; i <= s1_len; i++) {
1165 for (j = 1; j <= s2_len; j++) {
1166 unsigned int sub = p[j - 1];
1169 if (s1[i - 1] != s2[j - 1])
1172 pmin = min(q[j - 1] + 1, sub);
1173 q[j] = min(p[j] + 1, pmin);
1187 * Make a guess of whether the distance from 's1' is significant enough
1188 * to warrant printing the guess. We set this to a 1/2 match.
1190 int string_distance_ok(const char *opt, int distance)
1195 len = (len + 1) / 2;
1196 return distance <= len;
1199 static const struct fio_option *find_child(const struct fio_option *options,
1200 const struct fio_option *o)
1202 const struct fio_option *__o;
1204 for (__o = options + 1; __o->name; __o++)
1205 if (__o->parent && !strcmp(__o->parent, o->name))
1211 static void __print_option(const struct fio_option *o,
1212 const struct fio_option *org,
1224 p += sprintf(p, "%s", " ");
1226 sprintf(p, "%s", o->name);
1228 log_info("%-24s: %s\n", name, o->help);
1231 static void print_option(const struct fio_option *o)
1233 const struct fio_option *parent;
1234 const struct fio_option *__o;
1235 unsigned int printed;
1238 __print_option(o, NULL, 0);
1245 while ((__o = find_child(o, parent)) != NULL) {
1246 __print_option(__o, o, level);
1255 int show_cmd_help(const struct fio_option *options, const char *name)
1257 const struct fio_option *o, *closest;
1258 unsigned int best_dist = -1U;
1262 if (!name || !strcmp(name, "all"))
1267 for (o = &options[0]; o->name; o++) {
1270 if (o->type == FIO_OPT_DEPRECATED ||
1271 o->type == FIO_OPT_SOFT_DEPRECATED)
1273 if (!exec_profile && o->prof_name)
1275 if (exec_profile && !(o->prof_name && !strcmp(exec_profile, o->prof_name)))
1279 if (!strcmp(name, o->name) ||
1280 (o->alias && !strcmp(name, o->alias)))
1285 dist = string_distance(name, o->name);
1286 if (dist < best_dist) {
1293 if (show_all || match) {
1296 log_info("%20s: %s\n", o->name, o->help);
1307 show_option_help(o, 0);
1313 log_err("No such command: %s", name);
1316 * Only print an appropriately close option, one where the edit
1317 * distance isn't too big. Otherwise we get crazy matches.
1319 if (closest && best_dist < 3) {
1320 log_info(" - showing closest match\n");
1321 log_info("%20s: %s\n", closest->name, closest->help);
1322 show_option_help(closest, 0);
1330 * Handle parsing of default parameters.
1332 void fill_default_options(void *data, const struct fio_option *options)
1334 const struct fio_option *o;
1336 dprint(FD_PARSE, "filling default options\n");
1338 for (o = &options[0]; o->name; o++)
1340 handle_option(o, o->def, data);
1343 static void option_init(struct fio_option *o)
1345 if (o->type == FIO_OPT_DEPRECATED || o->type == FIO_OPT_UNSUPPORTED ||
1346 o->type == FIO_OPT_SOFT_DEPRECATED)
1348 if (o->name && !o->lname)
1349 log_err("Option %s: missing long option name\n", o->name);
1350 if (o->type == FIO_OPT_BOOL) {
1354 if (o->type == FIO_OPT_INT) {
1356 o->maxval = UINT_MAX;
1358 if (o->type == FIO_OPT_ULL) {
1360 o->maxval = ULLONG_MAX;
1362 if (o->type == FIO_OPT_STR_SET && o->def && !o->no_warn_def) {
1363 log_err("Option %s: string set option with"
1364 " default will always be true\n", o->name);
1366 if (!o->cb && !o->off1)
1367 log_err("Option %s: neither cb nor offset given\n", o->name);
1369 log_info("Option %s: no category defined. Setting to misc\n", o->name);
1370 o->category = FIO_OPT_C_GENERAL;
1371 o->group = FIO_OPT_G_INVALID;
1373 if (o->type == FIO_OPT_STR || o->type == FIO_OPT_STR_STORE ||
1374 o->type == FIO_OPT_STR_MULTI)
1379 * Sanitize the options structure. For now it just sets min/max for bool
1380 * values and whether both callback and offsets are given.
1382 void options_init(struct fio_option *options)
1384 struct fio_option *o;
1386 dprint(FD_PARSE, "init options\n");
1388 for (o = &options[0]; o->name; o++) {
1391 o->inv_opt = find_option(options, o->inverse);
1395 void options_mem_dupe(const struct fio_option *options, void *data)
1397 const struct fio_option *o;
1400 dprint(FD_PARSE, "dup options\n");
1402 for (o = &options[0]; o->name; o++) {
1403 if (o->type != FIO_OPT_STR_STORE)
1406 ptr = td_var(data, o, o->off1);
1408 *ptr = strdup(*ptr);
1412 void options_free(const struct fio_option *options, void *data)
1414 const struct fio_option *o;
1417 dprint(FD_PARSE, "free options\n");
1419 for (o = &options[0]; o->name; o++) {
1420 if (o->type != FIO_OPT_STR_STORE || !o->off1 || o->no_free)
1423 ptr = td_var(data, o, o->off1);