Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file contains the ini and command liner parser main. |
| 3 | */ |
| 4 | #include <stdio.h> |
| 5 | #include <stdlib.h> |
| 6 | #include <unistd.h> |
| 7 | #include <ctype.h> |
| 8 | #include <string.h> |
| 9 | #include <errno.h> |
| 10 | #include <limits.h> |
Aaron Carroll | 88b5a39 | 2008-10-07 11:25:20 +0200 | [diff] [blame] | 11 | #include <stdlib.h> |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 12 | |
| 13 | #include "parse.h" |
Jens Axboe | a3d741f | 2008-02-27 18:32:33 +0100 | [diff] [blame] | 14 | #include "debug.h" |
Jens Axboe | 9f988e2 | 2010-03-04 10:42:38 +0100 | [diff] [blame] | 15 | #include "options.h" |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 16 | |
Jens Axboe | 3b8b713 | 2008-06-10 19:46:23 +0200 | [diff] [blame] | 17 | static struct fio_option *fio_options; |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 18 | extern unsigned int fio_get_kb_base(void *); |
Jens Axboe | 3b8b713 | 2008-06-10 19:46:23 +0200 | [diff] [blame] | 19 | |
Jens Axboe | f085737 | 2007-03-19 13:15:23 +0100 | [diff] [blame] | 20 | static int vp_cmp(const void *p1, const void *p2) |
| 21 | { |
| 22 | const struct value_pair *vp1 = p1; |
| 23 | const struct value_pair *vp2 = p2; |
| 24 | |
| 25 | return strlen(vp2->ival) - strlen(vp1->ival); |
| 26 | } |
| 27 | |
| 28 | static void posval_sort(struct fio_option *o, struct value_pair *vpmap) |
| 29 | { |
| 30 | const struct value_pair *vp; |
| 31 | int entries; |
| 32 | |
| 33 | memset(vpmap, 0, PARSE_MAX_VP * sizeof(struct value_pair)); |
| 34 | |
| 35 | for (entries = 0; entries < PARSE_MAX_VP; entries++) { |
| 36 | vp = &o->posval[entries]; |
| 37 | if (!vp->ival || vp->ival[0] == '\0') |
| 38 | break; |
| 39 | |
| 40 | memcpy(&vpmap[entries], vp, sizeof(*vp)); |
| 41 | } |
| 42 | |
| 43 | qsort(vpmap, entries, sizeof(struct value_pair), vp_cmp); |
| 44 | } |
| 45 | |
Jens Axboe | d447a8c | 2009-07-17 22:26:15 +0200 | [diff] [blame] | 46 | static void show_option_range(struct fio_option *o, FILE *out) |
Jens Axboe | b1ec1da | 2007-02-23 10:29:16 +0100 | [diff] [blame] | 47 | { |
| 48 | if (!o->minval && !o->maxval) |
| 49 | return; |
| 50 | |
Jens Axboe | d447a8c | 2009-07-17 22:26:15 +0200 | [diff] [blame] | 51 | fprintf(out, "%20s: min=%d", "range", o->minval); |
Jens Axboe | 3980127 | 2009-07-01 09:06:12 +0200 | [diff] [blame] | 52 | if (o->maxval) |
Jens Axboe | d447a8c | 2009-07-17 22:26:15 +0200 | [diff] [blame] | 53 | fprintf(out, ", max=%d", o->maxval); |
| 54 | fprintf(out, "\n"); |
Jens Axboe | b1ec1da | 2007-02-23 10:29:16 +0100 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | static void show_option_values(struct fio_option *o) |
| 58 | { |
Jens Axboe | a3073f4 | 2010-03-05 10:06:15 +0100 | [diff] [blame] | 59 | int i; |
Jens Axboe | b1ec1da | 2007-02-23 10:29:16 +0100 | [diff] [blame] | 60 | |
Jens Axboe | a3073f4 | 2010-03-05 10:06:15 +0100 | [diff] [blame] | 61 | for (i = 0; i < PARSE_MAX_VP; i++) { |
Jens Axboe | 7837213 | 2007-03-14 13:24:07 +0100 | [diff] [blame] | 62 | const struct value_pair *vp = &o->posval[i]; |
| 63 | |
| 64 | if (!vp->ival) |
Jens Axboe | a3073f4 | 2010-03-05 10:06:15 +0100 | [diff] [blame] | 65 | continue; |
Jens Axboe | b1ec1da | 2007-02-23 10:29:16 +0100 | [diff] [blame] | 66 | |
Jens Axboe | 7837213 | 2007-03-14 13:24:07 +0100 | [diff] [blame] | 67 | printf("%20s: %-10s", i == 0 ? "valid values" : "", vp->ival); |
| 68 | if (vp->help) |
| 69 | printf(" %s", vp->help); |
| 70 | printf("\n"); |
Jens Axboe | a3073f4 | 2010-03-05 10:06:15 +0100 | [diff] [blame] | 71 | } |
Jens Axboe | b1ec1da | 2007-02-23 10:29:16 +0100 | [diff] [blame] | 72 | |
| 73 | if (i) |
| 74 | printf("\n"); |
| 75 | } |
| 76 | |
Jens Axboe | d447a8c | 2009-07-17 22:26:15 +0200 | [diff] [blame] | 77 | static void show_option_help(struct fio_option *o, FILE *out) |
| 78 | { |
| 79 | const char *typehelp[] = { |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 80 | "invalid", |
Jens Axboe | d447a8c | 2009-07-17 22:26:15 +0200 | [diff] [blame] | 81 | "string (opt=bla)", |
| 82 | "string with possible k/m/g postfix (opt=4k)", |
| 83 | "string with time postfix (opt=10s)", |
| 84 | "string (opt=bla)", |
| 85 | "string with dual range (opt=1k-4k,4k-8k)", |
| 86 | "integer value (opt=100)", |
| 87 | "boolean value (opt=1)", |
| 88 | "no argument (opt)", |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 89 | "deprecated", |
Jens Axboe | d447a8c | 2009-07-17 22:26:15 +0200 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | if (o->alias) |
| 93 | fprintf(out, "%20s: %s\n", "alias", o->alias); |
| 94 | |
| 95 | fprintf(out, "%20s: %s\n", "type", typehelp[o->type]); |
| 96 | fprintf(out, "%20s: %s\n", "default", o->def ? o->def : "no default"); |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 97 | if (o->prof_name) |
| 98 | fprintf(out, "%20s: only for profile '%s'\n", "valid", o->prof_name); |
Jens Axboe | d447a8c | 2009-07-17 22:26:15 +0200 | [diff] [blame] | 99 | show_option_range(o, stdout); |
| 100 | show_option_values(o); |
| 101 | } |
| 102 | |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 103 | static unsigned long get_mult_time(char c) |
| 104 | { |
| 105 | switch (c) { |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 106 | case 'm': |
| 107 | case 'M': |
| 108 | return 60; |
| 109 | case 'h': |
| 110 | case 'H': |
| 111 | return 60 * 60; |
| 112 | case 'd': |
| 113 | case 'D': |
| 114 | return 24 * 60 * 60; |
| 115 | default: |
| 116 | return 1; |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 117 | } |
| 118 | } |
| 119 | |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 120 | static unsigned long long get_mult_bytes(char c, void *data) |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 121 | { |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 122 | unsigned int kb_base = fio_get_kb_base(data); |
Jens Axboe | a639f0b | 2009-07-18 08:25:35 +0200 | [diff] [blame] | 123 | unsigned long long ret = 1; |
| 124 | |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 125 | switch (c) { |
Jens Axboe | a639f0b | 2009-07-18 08:25:35 +0200 | [diff] [blame] | 126 | default: |
| 127 | break; |
Jens Axboe | b09da8f | 2009-07-17 23:16:17 +0200 | [diff] [blame] | 128 | case 'p': |
| 129 | case 'P': |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 130 | ret *= (unsigned long long) kb_base; |
Jens Axboe | a639f0b | 2009-07-18 08:25:35 +0200 | [diff] [blame] | 131 | case 't': |
| 132 | case 'T': |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 133 | ret *= (unsigned long long) kb_base; |
Jens Axboe | a639f0b | 2009-07-18 08:25:35 +0200 | [diff] [blame] | 134 | case 'g': |
| 135 | case 'G': |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 136 | ret *= (unsigned long long) kb_base; |
Jens Axboe | a639f0b | 2009-07-18 08:25:35 +0200 | [diff] [blame] | 137 | case 'm': |
| 138 | case 'M': |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 139 | ret *= (unsigned long long) kb_base; |
Jens Axboe | a639f0b | 2009-07-18 08:25:35 +0200 | [diff] [blame] | 140 | case 'k': |
| 141 | case 'K': |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 142 | ret *= (unsigned long long) kb_base; |
Jens Axboe | a639f0b | 2009-07-18 08:25:35 +0200 | [diff] [blame] | 143 | break; |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 144 | } |
Jens Axboe | a639f0b | 2009-07-18 08:25:35 +0200 | [diff] [blame] | 145 | |
| 146 | return ret; |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | /* |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 150 | * convert string into decimal value, noting any size suffix |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 151 | */ |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 152 | int str_to_decimal(const char *str, long long *val, int kilo, void *data) |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 153 | { |
Jens Axboe | b347f9d | 2009-03-09 14:15:21 +0100 | [diff] [blame] | 154 | int len, base; |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 155 | |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 156 | len = strlen(str); |
Jens Axboe | f90eff5 | 2006-11-06 11:08:21 +0100 | [diff] [blame] | 157 | if (!len) |
| 158 | return 1; |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 159 | |
Jens Axboe | b347f9d | 2009-03-09 14:15:21 +0100 | [diff] [blame] | 160 | if (strstr(str, "0x") || strstr(str, "0X")) |
| 161 | base = 16; |
| 162 | else |
| 163 | base = 10; |
| 164 | |
| 165 | *val = strtoll(str, NULL, base); |
Jens Axboe | cda866c | 2007-01-10 16:02:32 +0100 | [diff] [blame] | 166 | if (*val == LONG_MAX && errno == ERANGE) |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 167 | return 1; |
| 168 | |
Jens Axboe | 975462a | 2009-12-23 08:54:52 +0100 | [diff] [blame] | 169 | if (kilo) { |
| 170 | const char *p; |
| 171 | /* |
| 172 | * if the last char is 'b' or 'B', the user likely used |
| 173 | * "1gb" instead of just "1g". If the second to last is also |
| 174 | * a letter, adjust. |
| 175 | */ |
| 176 | p = str + len - 1; |
| 177 | if ((*p == 'b' || *p == 'B') && isalpha(*(p - 1))) |
| 178 | --p; |
| 179 | |
| 180 | *val *= get_mult_bytes(*p, data); |
| 181 | } else |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 182 | *val *= get_mult_time(str[len - 1]); |
Jens Axboe | 787f7e9 | 2006-11-06 13:26:29 +0100 | [diff] [blame] | 183 | |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 184 | return 0; |
| 185 | } |
| 186 | |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 187 | static int check_str_bytes(const char *p, long long *val, void *data) |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 188 | { |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 189 | return str_to_decimal(p, val, 1, data); |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 190 | } |
| 191 | |
Jens Axboe | 63f2937 | 2007-01-10 13:20:09 +0100 | [diff] [blame] | 192 | static int check_str_time(const char *p, long long *val) |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 193 | { |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 194 | return str_to_decimal(p, val, 0, NULL); |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | void strip_blank_front(char **p) |
| 198 | { |
| 199 | char *s = *p; |
| 200 | |
| 201 | while (isspace(*s)) |
| 202 | s++; |
Jens Axboe | 4d651da | 2007-03-28 19:34:53 +0200 | [diff] [blame] | 203 | |
| 204 | *p = s; |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | void strip_blank_end(char *p) |
| 208 | { |
Jens Axboe | 853ee7f | 2009-03-06 20:29:29 +0100 | [diff] [blame] | 209 | char *start = p, *s; |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 210 | |
Jens Axboe | 523bfad | 2007-04-04 11:04:06 +0200 | [diff] [blame] | 211 | s = strchr(p, ';'); |
| 212 | if (s) |
| 213 | *s = '\0'; |
| 214 | s = strchr(p, '#'); |
| 215 | if (s) |
| 216 | *s = '\0'; |
| 217 | if (s) |
| 218 | p = s; |
| 219 | |
Jens Axboe | 7f7e6e5 | 2007-07-19 14:50:05 +0200 | [diff] [blame] | 220 | s = p + strlen(p); |
Jens Axboe | 853ee7f | 2009-03-06 20:29:29 +0100 | [diff] [blame] | 221 | while ((isspace(*s) || iscntrl(*s)) && (s > start)) |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 222 | s--; |
| 223 | |
| 224 | *(s + 1) = '\0'; |
| 225 | } |
| 226 | |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 227 | static int check_range_bytes(const char *str, long *val, void *data) |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 228 | { |
| 229 | char suffix; |
| 230 | |
Jens Axboe | 787f7e9 | 2006-11-06 13:26:29 +0100 | [diff] [blame] | 231 | if (!strlen(str)) |
| 232 | return 1; |
| 233 | |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 234 | if (sscanf(str, "%lu%c", val, &suffix) == 2) { |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 235 | *val *= get_mult_bytes(suffix, data); |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 236 | return 0; |
| 237 | } |
| 238 | |
| 239 | if (sscanf(str, "%lu", val) == 1) |
| 240 | return 0; |
| 241 | |
| 242 | return 1; |
| 243 | } |
| 244 | |
Jens Axboe | 63f2937 | 2007-01-10 13:20:09 +0100 | [diff] [blame] | 245 | static int check_int(const char *p, int *val) |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 246 | { |
Jens Axboe | 787f7e9 | 2006-11-06 13:26:29 +0100 | [diff] [blame] | 247 | if (!strlen(p)) |
| 248 | return 1; |
Jens Axboe | d78ee46 | 2007-08-10 14:03:20 +0200 | [diff] [blame] | 249 | if (strstr(p, "0x") || strstr(p, "0X")) { |
Jens Axboe | a61bdfd | 2007-07-30 09:07:04 +0200 | [diff] [blame] | 250 | if (sscanf(p, "%x", val) == 1) |
| 251 | return 0; |
| 252 | } else { |
| 253 | if (sscanf(p, "%u", val) == 1) |
| 254 | return 0; |
| 255 | } |
Jens Axboe | cb2c86f | 2006-10-26 13:48:34 +0200 | [diff] [blame] | 256 | |
| 257 | return 1; |
| 258 | } |
| 259 | |
Jens Axboe | 5f6ddf1 | 2010-03-09 20:40:44 +0100 | [diff] [blame] | 260 | #define val_store(ptr, val, off, or, data) \ |
Jens Axboe | 17abbe8 | 2006-11-06 11:23:10 +0100 | [diff] [blame] | 261 | do { \ |
| 262 | ptr = td_var((data), (off)); \ |
Jens Axboe | 5f6ddf1 | 2010-03-09 20:40:44 +0100 | [diff] [blame] | 263 | if ((or)) \ |
| 264 | *ptr |= (val); \ |
| 265 | else \ |
| 266 | *ptr = (val); \ |
Jens Axboe | 17abbe8 | 2006-11-06 11:23:10 +0100 | [diff] [blame] | 267 | } while (0) |
| 268 | |
Jens Axboe | f90eff5 | 2006-11-06 11:08:21 +0100 | [diff] [blame] | 269 | static int __handle_option(struct fio_option *o, const char *ptr, void *data, |
Jens Axboe | 787f7e9 | 2006-11-06 13:26:29 +0100 | [diff] [blame] | 270 | int first, int more) |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 271 | { |
Jens Axboe | 63f2937 | 2007-01-10 13:20:09 +0100 | [diff] [blame] | 272 | int il, *ilp; |
| 273 | long long ull, *ullp; |
| 274 | long ul1, ul2; |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 275 | char **cp; |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 276 | int ret = 0, is_time = 0; |
| 277 | |
Jens Axboe | a3d741f | 2008-02-27 18:32:33 +0100 | [diff] [blame] | 278 | dprint(FD_PARSE, "__handle_option=%s, type=%d, ptr=%s\n", o->name, |
| 279 | o->type, ptr); |
| 280 | |
Jens Axboe | e3cedca | 2008-11-19 19:57:52 +0100 | [diff] [blame] | 281 | if (!ptr && o->type != FIO_OPT_STR_SET && o->type != FIO_OPT_STR) { |
Jens Axboe | 08e26e3 | 2006-11-21 13:15:10 +0100 | [diff] [blame] | 282 | fprintf(stderr, "Option %s requires an argument\n", o->name); |
| 283 | return 1; |
| 284 | } |
| 285 | |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 286 | switch (o->type) { |
Jens Axboe | 5f6ddf1 | 2010-03-09 20:40:44 +0100 | [diff] [blame] | 287 | case FIO_OPT_STR: |
| 288 | case FIO_OPT_STR_MULTI: { |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 289 | fio_opt_str_fn *fn = o->cb; |
Jens Axboe | b1ec1da | 2007-02-23 10:29:16 +0100 | [diff] [blame] | 290 | const struct value_pair *vp; |
Jens Axboe | f085737 | 2007-03-19 13:15:23 +0100 | [diff] [blame] | 291 | struct value_pair posval[PARSE_MAX_VP]; |
Jens Axboe | ae2ddba | 2010-03-10 12:49:03 +0100 | [diff] [blame] | 292 | int i, all_skipped = 1; |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 293 | |
Jens Axboe | f085737 | 2007-03-19 13:15:23 +0100 | [diff] [blame] | 294 | posval_sort(o, posval); |
| 295 | |
Jens Axboe | 5f6ddf1 | 2010-03-09 20:40:44 +0100 | [diff] [blame] | 296 | ret = 1; |
Jens Axboe | b1ec1da | 2007-02-23 10:29:16 +0100 | [diff] [blame] | 297 | for (i = 0; i < PARSE_MAX_VP; i++) { |
Jens Axboe | f085737 | 2007-03-19 13:15:23 +0100 | [diff] [blame] | 298 | vp = &posval[i]; |
Jens Axboe | b1ec1da | 2007-02-23 10:29:16 +0100 | [diff] [blame] | 299 | if (!vp->ival || vp->ival[0] == '\0') |
Jens Axboe | a3073f4 | 2010-03-05 10:06:15 +0100 | [diff] [blame] | 300 | continue; |
Jens Axboe | ae2ddba | 2010-03-10 12:49:03 +0100 | [diff] [blame] | 301 | all_skipped = 0; |
Jens Axboe | b1ec1da | 2007-02-23 10:29:16 +0100 | [diff] [blame] | 302 | if (!strncmp(vp->ival, ptr, strlen(vp->ival))) { |
| 303 | ret = 0; |
Jens Axboe | 5f6ddf1 | 2010-03-09 20:40:44 +0100 | [diff] [blame] | 304 | if (o->roff1) { |
| 305 | if (vp->or) |
| 306 | *(unsigned int *) o->roff1 |= vp->oval; |
| 307 | else |
| 308 | *(unsigned int *) o->roff1 = vp->oval; |
| 309 | } else { |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 310 | if (!o->off1) |
Jens Axboe | 5f6ddf1 | 2010-03-09 20:40:44 +0100 | [diff] [blame] | 311 | continue; |
| 312 | val_store(ilp, vp->oval, o->off1, vp->or, data); |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 313 | } |
Jens Axboe | 5f6ddf1 | 2010-03-09 20:40:44 +0100 | [diff] [blame] | 314 | continue; |
Jens Axboe | b1ec1da | 2007-02-23 10:29:16 +0100 | [diff] [blame] | 315 | } |
| 316 | } |
| 317 | |
Jens Axboe | ae2ddba | 2010-03-10 12:49:03 +0100 | [diff] [blame] | 318 | if (ret && !all_skipped) |
Jens Axboe | b1ec1da | 2007-02-23 10:29:16 +0100 | [diff] [blame] | 319 | show_option_values(o); |
| 320 | else if (fn) |
| 321 | ret = fn(data, ptr); |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 322 | break; |
| 323 | } |
| 324 | case FIO_OPT_STR_VAL_TIME: |
| 325 | is_time = 1; |
Jens Axboe | f7fa265 | 2009-03-09 14:20:20 +0100 | [diff] [blame] | 326 | case FIO_OPT_INT: |
Jens Axboe | e01b22b | 2009-06-09 15:43:25 +0200 | [diff] [blame] | 327 | case FIO_OPT_STR_VAL: { |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 328 | fio_opt_str_val_fn *fn = o->cb; |
| 329 | |
| 330 | if (is_time) |
| 331 | ret = check_str_time(ptr, &ull); |
| 332 | else |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 333 | ret = check_str_bytes(ptr, &ull, data); |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 334 | |
| 335 | if (ret) |
| 336 | break; |
| 337 | |
Jens Axboe | db8e016 | 2007-01-10 13:41:26 +0100 | [diff] [blame] | 338 | if (o->maxval && ull > o->maxval) { |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 339 | fprintf(stderr, "max value out of range: %lld" |
| 340 | " (%d max)\n", ull, o->maxval); |
Jens Axboe | db8e016 | 2007-01-10 13:41:26 +0100 | [diff] [blame] | 341 | return 1; |
| 342 | } |
| 343 | if (o->minval && ull < o->minval) { |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 344 | fprintf(stderr, "min value out of range: %lld" |
| 345 | " (%d min)\n", ull, o->minval); |
Jens Axboe | db8e016 | 2007-01-10 13:41:26 +0100 | [diff] [blame] | 346 | return 1; |
| 347 | } |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 348 | |
| 349 | if (fn) |
| 350 | ret = fn(data, &ull); |
| 351 | else { |
Jens Axboe | e01b22b | 2009-06-09 15:43:25 +0200 | [diff] [blame] | 352 | if (o->type == FIO_OPT_INT) { |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 353 | if (first) { |
| 354 | if (o->roff1) |
Jens Axboe | 7758d4f | 2010-03-18 16:50:31 +0100 | [diff] [blame] | 355 | *(unsigned int *) o->roff1 = ull; |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 356 | else |
Jens Axboe | 5f6ddf1 | 2010-03-09 20:40:44 +0100 | [diff] [blame] | 357 | val_store(ilp, ull, o->off1, 0, data); |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 358 | } |
| 359 | if (!more) { |
| 360 | if (o->roff2) |
Jens Axboe | 7758d4f | 2010-03-18 16:50:31 +0100 | [diff] [blame] | 361 | *(unsigned int *) o->roff2 = ull; |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 362 | else if (o->off2) |
Jens Axboe | 5f6ddf1 | 2010-03-09 20:40:44 +0100 | [diff] [blame] | 363 | val_store(ilp, ull, o->off2, 0, data); |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 364 | } |
Jens Axboe | 75e6f36 | 2006-11-03 08:17:09 +0100 | [diff] [blame] | 365 | } else { |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 366 | if (first) { |
| 367 | if (o->roff1) |
| 368 | *(unsigned long long *) o->roff1 = ull; |
| 369 | else |
Jens Axboe | 5f6ddf1 | 2010-03-09 20:40:44 +0100 | [diff] [blame] | 370 | val_store(ullp, ull, o->off1, 0, data); |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 371 | } |
| 372 | if (!more) { |
| 373 | if (o->roff2) |
| 374 | *(unsigned long long *) o->roff2 = ull; |
| 375 | else if (o->off2) |
Jens Axboe | 5f6ddf1 | 2010-03-09 20:40:44 +0100 | [diff] [blame] | 376 | val_store(ullp, ull, o->off2, 0, data); |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 377 | } |
Jens Axboe | 75e6f36 | 2006-11-03 08:17:09 +0100 | [diff] [blame] | 378 | } |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 379 | } |
| 380 | break; |
| 381 | } |
Jens Axboe | af52b34 | 2007-03-13 10:07:47 +0100 | [diff] [blame] | 382 | case FIO_OPT_STR_STORE: { |
| 383 | fio_opt_str_fn *fn = o->cb; |
| 384 | |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 385 | if (o->roff1) |
| 386 | cp = (char **) o->roff1; |
| 387 | else |
| 388 | cp = td_var(data, o->off1); |
| 389 | |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 390 | *cp = strdup(ptr); |
Jens Axboe | af52b34 | 2007-03-13 10:07:47 +0100 | [diff] [blame] | 391 | if (fn) { |
| 392 | ret = fn(data, ptr); |
| 393 | if (ret) { |
| 394 | free(*cp); |
| 395 | *cp = NULL; |
| 396 | } |
| 397 | } |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 398 | break; |
Jens Axboe | af52b34 | 2007-03-13 10:07:47 +0100 | [diff] [blame] | 399 | } |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 400 | case FIO_OPT_RANGE: { |
Jens Axboe | b765a37 | 2006-10-27 15:00:16 +0200 | [diff] [blame] | 401 | char tmp[128]; |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 402 | char *p1, *p2; |
| 403 | |
Jens Axboe | 0bbab0e | 2006-11-02 09:18:36 +0100 | [diff] [blame] | 404 | strncpy(tmp, ptr, sizeof(tmp) - 1); |
Jens Axboe | b765a37 | 2006-10-27 15:00:16 +0200 | [diff] [blame] | 405 | |
| 406 | p1 = strchr(tmp, '-'); |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 407 | if (!p1) { |
Jens Axboe | 0c9baf9 | 2007-01-11 15:59:26 +0100 | [diff] [blame] | 408 | p1 = strchr(tmp, ':'); |
| 409 | if (!p1) { |
| 410 | ret = 1; |
| 411 | break; |
| 412 | } |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 413 | } |
| 414 | |
| 415 | p2 = p1 + 1; |
| 416 | *p1 = '\0'; |
Jens Axboe | b765a37 | 2006-10-27 15:00:16 +0200 | [diff] [blame] | 417 | p1 = tmp; |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 418 | |
| 419 | ret = 1; |
Jens Axboe | d6978a3 | 2009-07-18 21:04:09 +0200 | [diff] [blame] | 420 | if (!check_range_bytes(p1, &ul1, data) && |
| 421 | !check_range_bytes(p2, &ul2, data)) { |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 422 | ret = 0; |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 423 | if (ul1 > ul2) { |
Jens Axboe | f90eff5 | 2006-11-06 11:08:21 +0100 | [diff] [blame] | 424 | unsigned long foo = ul1; |
| 425 | |
| 426 | ul1 = ul2; |
| 427 | ul2 = foo; |
| 428 | } |
| 429 | |
| 430 | if (first) { |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 431 | if (o->roff1) |
Jens Axboe | 7758d4f | 2010-03-18 16:50:31 +0100 | [diff] [blame] | 432 | *(unsigned int *) o->roff1 = ul1; |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 433 | else |
Jens Axboe | 5f6ddf1 | 2010-03-09 20:40:44 +0100 | [diff] [blame] | 434 | val_store(ilp, ul1, o->off1, 0, data); |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 435 | if (o->roff2) |
Jens Axboe | 7758d4f | 2010-03-18 16:50:31 +0100 | [diff] [blame] | 436 | *(unsigned int *) o->roff2 = ul2; |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 437 | else |
Jens Axboe | 5f6ddf1 | 2010-03-09 20:40:44 +0100 | [diff] [blame] | 438 | val_store(ilp, ul2, o->off2, 0, data); |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 439 | } |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 440 | if (o->roff3 && o->roff4) { |
Jens Axboe | 7758d4f | 2010-03-18 16:50:31 +0100 | [diff] [blame] | 441 | *(unsigned int *) o->roff3 = ul1; |
| 442 | *(unsigned int *) o->roff4 = ul2; |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 443 | } else if (o->off3 && o->off4) { |
Jens Axboe | 5f6ddf1 | 2010-03-09 20:40:44 +0100 | [diff] [blame] | 444 | val_store(ilp, ul1, o->off3, 0, data); |
| 445 | val_store(ilp, ul2, o->off4, 0, data); |
Jens Axboe | 17abbe8 | 2006-11-06 11:23:10 +0100 | [diff] [blame] | 446 | } |
| 447 | } |
| 448 | |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 449 | break; |
| 450 | } |
Jens Axboe | 13335dd | 2007-01-10 13:14:02 +0100 | [diff] [blame] | 451 | case FIO_OPT_BOOL: { |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 452 | fio_opt_int_fn *fn = o->cb; |
| 453 | |
| 454 | ret = check_int(ptr, &il); |
| 455 | if (ret) |
| 456 | break; |
| 457 | |
Jens Axboe | db8e016 | 2007-01-10 13:41:26 +0100 | [diff] [blame] | 458 | if (o->maxval && il > (int) o->maxval) { |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 459 | fprintf(stderr, "max value out of range: %d (%d max)\n", |
| 460 | il, o->maxval); |
Jens Axboe | db8e016 | 2007-01-10 13:41:26 +0100 | [diff] [blame] | 461 | return 1; |
| 462 | } |
| 463 | if (o->minval && il < o->minval) { |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 464 | fprintf(stderr, "min value out of range: %d (%d min)\n", |
| 465 | il, o->minval); |
Jens Axboe | db8e016 | 2007-01-10 13:41:26 +0100 | [diff] [blame] | 466 | return 1; |
| 467 | } |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 468 | |
Jens Axboe | 76a43db | 2007-01-11 13:24:44 +0100 | [diff] [blame] | 469 | if (o->neg) |
| 470 | il = !il; |
| 471 | |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 472 | if (fn) |
| 473 | ret = fn(data, &il); |
| 474 | else { |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 475 | if (first) { |
| 476 | if (o->roff1) |
| 477 | *(unsigned int *)o->roff1 = il; |
| 478 | else |
Jens Axboe | 5f6ddf1 | 2010-03-09 20:40:44 +0100 | [diff] [blame] | 479 | val_store(ilp, il, o->off1, 0, data); |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 480 | } |
| 481 | if (!more) { |
| 482 | if (o->roff2) |
| 483 | *(unsigned int *) o->roff2 = il; |
| 484 | else if (o->off2) |
Jens Axboe | 5f6ddf1 | 2010-03-09 20:40:44 +0100 | [diff] [blame] | 485 | val_store(ilp, il, o->off2, 0, data); |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 486 | } |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 487 | } |
| 488 | break; |
| 489 | } |
| 490 | case FIO_OPT_STR_SET: { |
| 491 | fio_opt_str_set_fn *fn = o->cb; |
| 492 | |
| 493 | if (fn) |
| 494 | ret = fn(data); |
| 495 | else { |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 496 | if (first) { |
| 497 | if (o->roff1) |
| 498 | *(unsigned int *) o->roff1 = 1; |
| 499 | else |
Jens Axboe | 5f6ddf1 | 2010-03-09 20:40:44 +0100 | [diff] [blame] | 500 | val_store(ilp, 1, o->off1, 0, data); |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 501 | } |
| 502 | if (!more) { |
| 503 | if (o->roff2) |
| 504 | *(unsigned int *) o->roff2 = 1; |
| 505 | else if (o->off2) |
Jens Axboe | 5f6ddf1 | 2010-03-09 20:40:44 +0100 | [diff] [blame] | 506 | val_store(ilp, 1, o->off2, 0, data); |
Jens Axboe | 02c6aad | 2010-03-04 13:49:11 +0100 | [diff] [blame] | 507 | } |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 508 | } |
| 509 | break; |
| 510 | } |
Jens Axboe | 15ca150 | 2008-04-07 09:26:02 +0200 | [diff] [blame] | 511 | case FIO_OPT_DEPRECATED: |
| 512 | fprintf(stdout, "Option %s is deprecated\n", o->name); |
| 513 | break; |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 514 | default: |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 515 | fprintf(stderr, "Bad option type %u\n", o->type); |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 516 | ret = 1; |
| 517 | } |
| 518 | |
Jens Axboe | 70a4c0c | 2009-07-01 09:24:05 +0200 | [diff] [blame] | 519 | if (ret) |
| 520 | return ret; |
| 521 | |
Jens Axboe | d447a8c | 2009-07-17 22:26:15 +0200 | [diff] [blame] | 522 | if (o->verify) { |
Jens Axboe | 70a4c0c | 2009-07-01 09:24:05 +0200 | [diff] [blame] | 523 | ret = o->verify(o, data); |
Jens Axboe | d447a8c | 2009-07-17 22:26:15 +0200 | [diff] [blame] | 524 | if (ret) { |
| 525 | fprintf(stderr,"Correct format for offending option\n"); |
| 526 | fprintf(stderr, "%20s: %s\n", o->name, o->help); |
| 527 | show_option_help(o, stderr); |
| 528 | } |
| 529 | } |
Jens Axboe | 70a4c0c | 2009-07-01 09:24:05 +0200 | [diff] [blame] | 530 | |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 531 | return ret; |
| 532 | } |
| 533 | |
Jens Axboe | 7c8f1a5 | 2009-06-09 12:28:57 +0200 | [diff] [blame] | 534 | static int handle_option(struct fio_option *o, const char *__ptr, void *data) |
Jens Axboe | f90eff5 | 2006-11-06 11:08:21 +0100 | [diff] [blame] | 535 | { |
Jens Axboe | b62bdf2 | 2010-03-10 12:36:17 +0100 | [diff] [blame] | 536 | char *o_ptr, *ptr, *ptr2; |
| 537 | int ret, done; |
Jens Axboe | f90eff5 | 2006-11-06 11:08:21 +0100 | [diff] [blame] | 538 | |
Jens Axboe | 7c8f1a5 | 2009-06-09 12:28:57 +0200 | [diff] [blame] | 539 | dprint(FD_PARSE, "handle_option=%s, ptr=%s\n", o->name, __ptr); |
| 540 | |
Jens Axboe | b62bdf2 | 2010-03-10 12:36:17 +0100 | [diff] [blame] | 541 | o_ptr = ptr = NULL; |
Jens Axboe | 7c8f1a5 | 2009-06-09 12:28:57 +0200 | [diff] [blame] | 542 | if (__ptr) |
Jens Axboe | b62bdf2 | 2010-03-10 12:36:17 +0100 | [diff] [blame] | 543 | o_ptr = ptr = strdup(__ptr); |
Jens Axboe | a3d741f | 2008-02-27 18:32:33 +0100 | [diff] [blame] | 544 | |
Jens Axboe | f90eff5 | 2006-11-06 11:08:21 +0100 | [diff] [blame] | 545 | /* |
Jens Axboe | b62bdf2 | 2010-03-10 12:36:17 +0100 | [diff] [blame] | 546 | * See if we have another set of parameters, hidden after a comma. |
| 547 | * Do this before parsing this round, to check if we should |
Jens Axboe | 787f7e9 | 2006-11-06 13:26:29 +0100 | [diff] [blame] | 548 | * copy set 1 options to set 2. |
Jens Axboe | f90eff5 | 2006-11-06 11:08:21 +0100 | [diff] [blame] | 549 | */ |
Jens Axboe | b62bdf2 | 2010-03-10 12:36:17 +0100 | [diff] [blame] | 550 | done = 0; |
| 551 | ret = 1; |
| 552 | do { |
| 553 | int __ret; |
| 554 | |
| 555 | ptr2 = NULL; |
| 556 | if (ptr && |
| 557 | (o->type != FIO_OPT_STR_STORE) && |
| 558 | (o->type != FIO_OPT_STR)) { |
| 559 | ptr2 = strchr(ptr, ','); |
| 560 | if (ptr2 && *(ptr2 + 1) == '\0') |
| 561 | *ptr2 = '\0'; |
| 562 | if (o->type != FIO_OPT_STR_MULTI) { |
| 563 | if (!ptr2) |
| 564 | ptr2 = strchr(ptr, ':'); |
| 565 | if (!ptr2) |
| 566 | ptr2 = strchr(ptr, '-'); |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | /* |
| 571 | * Don't return early if parsing the first option fails - if |
| 572 | * we are doing multiple arguments, we can allow the first one |
| 573 | * being empty. |
| 574 | */ |
| 575 | __ret = __handle_option(o, ptr, data, !done, !!ptr2); |
| 576 | if (ret) |
| 577 | ret = __ret; |
| 578 | |
Jens Axboe | 0c9baf9 | 2007-01-11 15:59:26 +0100 | [diff] [blame] | 579 | if (!ptr2) |
Jens Axboe | b62bdf2 | 2010-03-10 12:36:17 +0100 | [diff] [blame] | 580 | break; |
Jens Axboe | 787f7e9 | 2006-11-06 13:26:29 +0100 | [diff] [blame] | 581 | |
Jens Axboe | b62bdf2 | 2010-03-10 12:36:17 +0100 | [diff] [blame] | 582 | ptr = ptr2 + 1; |
| 583 | done++; |
| 584 | } while (1); |
Jens Axboe | 787f7e9 | 2006-11-06 13:26:29 +0100 | [diff] [blame] | 585 | |
Jens Axboe | b62bdf2 | 2010-03-10 12:36:17 +0100 | [diff] [blame] | 586 | if (o_ptr) |
| 587 | free(o_ptr); |
| 588 | return ret; |
Jens Axboe | f90eff5 | 2006-11-06 11:08:21 +0100 | [diff] [blame] | 589 | } |
| 590 | |
Jens Axboe | 3b8b713 | 2008-06-10 19:46:23 +0200 | [diff] [blame] | 591 | static struct fio_option *get_option(const char *opt, |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 592 | struct fio_option *options, char **post) |
Jens Axboe | 3b8b713 | 2008-06-10 19:46:23 +0200 | [diff] [blame] | 593 | { |
| 594 | struct fio_option *o; |
| 595 | char *ret; |
| 596 | |
| 597 | ret = strchr(opt, '='); |
| 598 | if (ret) { |
| 599 | *post = ret; |
| 600 | *ret = '\0'; |
| 601 | ret = (char *) opt; |
| 602 | (*post)++; |
Jens Axboe | 43c129b | 2008-12-08 14:06:42 +0100 | [diff] [blame] | 603 | strip_blank_end(ret); |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 604 | o = find_option(options, ret); |
Jens Axboe | 3b8b713 | 2008-06-10 19:46:23 +0200 | [diff] [blame] | 605 | } else { |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 606 | o = find_option(options, opt); |
Jens Axboe | 3b8b713 | 2008-06-10 19:46:23 +0200 | [diff] [blame] | 607 | *post = NULL; |
| 608 | } |
| 609 | |
| 610 | return o; |
| 611 | } |
| 612 | |
| 613 | static int opt_cmp(const void *p1, const void *p2) |
| 614 | { |
| 615 | struct fio_option *o1, *o2; |
| 616 | char *s1, *s2, *foo; |
Jens Axboe | 8cdabc1 | 2008-11-19 12:31:43 +0100 | [diff] [blame] | 617 | int prio1, prio2; |
Jens Axboe | 3b8b713 | 2008-06-10 19:46:23 +0200 | [diff] [blame] | 618 | |
| 619 | s1 = strdup(*((char **) p1)); |
| 620 | s2 = strdup(*((char **) p2)); |
| 621 | |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 622 | o1 = get_option(s1, fio_options, &foo); |
| 623 | o2 = get_option(s2, fio_options, &foo); |
Jens Axboe | 0b9d69e | 2009-09-11 22:29:54 +0200 | [diff] [blame] | 624 | |
Jens Axboe | 8cdabc1 | 2008-11-19 12:31:43 +0100 | [diff] [blame] | 625 | prio1 = prio2 = 0; |
| 626 | if (o1) |
| 627 | prio1 = o1->prio; |
| 628 | if (o2) |
| 629 | prio2 = o2->prio; |
Jens Axboe | 3b8b713 | 2008-06-10 19:46:23 +0200 | [diff] [blame] | 630 | |
| 631 | free(s1); |
| 632 | free(s2); |
Jens Axboe | 8cdabc1 | 2008-11-19 12:31:43 +0100 | [diff] [blame] | 633 | return prio2 - prio1; |
Jens Axboe | 3b8b713 | 2008-06-10 19:46:23 +0200 | [diff] [blame] | 634 | } |
| 635 | |
| 636 | void sort_options(char **opts, struct fio_option *options, int num_opts) |
| 637 | { |
| 638 | fio_options = options; |
| 639 | qsort(opts, num_opts, sizeof(char *), opt_cmp); |
| 640 | fio_options = NULL; |
| 641 | } |
| 642 | |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 643 | int parse_cmd_option(const char *opt, const char *val, |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 644 | struct fio_option *options, void *data) |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 645 | { |
| 646 | struct fio_option *o; |
| 647 | |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 648 | o = find_option(options, opt); |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 649 | if (!o) { |
Jens Axboe | 43c129b | 2008-12-08 14:06:42 +0100 | [diff] [blame] | 650 | fprintf(stderr, "Bad option <%s>\n", opt); |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 651 | return 1; |
| 652 | } |
| 653 | |
Jens Axboe | b1508cf | 2006-11-02 09:12:40 +0100 | [diff] [blame] | 654 | if (!handle_option(o, val, data)) |
| 655 | return 0; |
| 656 | |
| 657 | fprintf(stderr, "fio: failed parsing %s=%s\n", opt, val); |
| 658 | return 1; |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 659 | } |
| 660 | |
Aaron Carroll | 88b5a39 | 2008-10-07 11:25:20 +0200 | [diff] [blame] | 661 | /* |
| 662 | * Return a copy of the input string with substrings of the form ${VARNAME} |
| 663 | * substituted with the value of the environment variable VARNAME. The |
| 664 | * substitution always occurs, even if VARNAME is empty or the corresponding |
| 665 | * environment variable undefined. |
| 666 | */ |
| 667 | static char *option_dup_subs(const char *opt) |
| 668 | { |
| 669 | char out[OPT_LEN_MAX+1]; |
| 670 | char in[OPT_LEN_MAX+1]; |
| 671 | char *outptr = out; |
| 672 | char *inptr = in; |
| 673 | char *ch1, *ch2, *env; |
| 674 | ssize_t nchr = OPT_LEN_MAX; |
| 675 | size_t envlen; |
| 676 | |
Jens Axboe | a0741cb | 2010-03-05 12:46:37 +0100 | [diff] [blame] | 677 | if (strlen(opt) + 1 > OPT_LEN_MAX) { |
Jens Axboe | 38789b5 | 2010-03-03 09:23:20 +0100 | [diff] [blame] | 678 | fprintf(stderr, "OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX); |
| 679 | return NULL; |
| 680 | } |
| 681 | |
Aaron Carroll | 88b5a39 | 2008-10-07 11:25:20 +0200 | [diff] [blame] | 682 | in[OPT_LEN_MAX] = '\0'; |
| 683 | strncpy(in, opt, OPT_LEN_MAX); |
| 684 | |
| 685 | while (*inptr && nchr > 0) { |
| 686 | if (inptr[0] == '$' && inptr[1] == '{') { |
| 687 | ch2 = strchr(inptr, '}'); |
| 688 | if (ch2 && inptr+1 < ch2) { |
| 689 | ch1 = inptr+2; |
| 690 | inptr = ch2+1; |
| 691 | *ch2 = '\0'; |
| 692 | |
| 693 | env = getenv(ch1); |
| 694 | if (env) { |
| 695 | envlen = strlen(env); |
| 696 | if (envlen <= nchr) { |
| 697 | memcpy(outptr, env, envlen); |
| 698 | outptr += envlen; |
| 699 | nchr -= envlen; |
| 700 | } |
| 701 | } |
| 702 | |
| 703 | continue; |
| 704 | } |
| 705 | } |
| 706 | |
| 707 | *outptr++ = *inptr++; |
| 708 | --nchr; |
| 709 | } |
| 710 | |
| 711 | *outptr = '\0'; |
| 712 | return strdup(out); |
| 713 | } |
| 714 | |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 715 | int parse_option(const char *opt, struct fio_option *options, void *data) |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 716 | { |
Jens Axboe | b469282 | 2006-10-27 13:43:22 +0200 | [diff] [blame] | 717 | struct fio_option *o; |
Jens Axboe | 3b8b713 | 2008-06-10 19:46:23 +0200 | [diff] [blame] | 718 | char *post, *tmp; |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 719 | |
Aaron Carroll | 88b5a39 | 2008-10-07 11:25:20 +0200 | [diff] [blame] | 720 | tmp = option_dup_subs(opt); |
Jens Axboe | 38789b5 | 2010-03-03 09:23:20 +0100 | [diff] [blame] | 721 | if (!tmp) |
| 722 | return 1; |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 723 | |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 724 | o = get_option(tmp, options, &post); |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 725 | if (!o) { |
Jens Axboe | 43c129b | 2008-12-08 14:06:42 +0100 | [diff] [blame] | 726 | fprintf(stderr, "Bad option <%s>\n", tmp); |
Jens Axboe | 0401bca | 2007-03-29 11:00:43 +0200 | [diff] [blame] | 727 | free(tmp); |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 728 | return 1; |
| 729 | } |
| 730 | |
Jens Axboe | 0401bca | 2007-03-29 11:00:43 +0200 | [diff] [blame] | 731 | if (!handle_option(o, post, data)) { |
| 732 | free(tmp); |
Jens Axboe | b1508cf | 2006-11-02 09:12:40 +0100 | [diff] [blame] | 733 | return 0; |
Jens Axboe | 0401bca | 2007-03-29 11:00:43 +0200 | [diff] [blame] | 734 | } |
Jens Axboe | b1508cf | 2006-11-02 09:12:40 +0100 | [diff] [blame] | 735 | |
| 736 | fprintf(stderr, "fio: failed parsing %s\n", opt); |
Jens Axboe | 0401bca | 2007-03-29 11:00:43 +0200 | [diff] [blame] | 737 | free(tmp); |
Jens Axboe | b1508cf | 2006-11-02 09:12:40 +0100 | [diff] [blame] | 738 | return 1; |
Jens Axboe | e1f3650 | 2006-10-27 10:54:08 +0200 | [diff] [blame] | 739 | } |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 740 | |
Jens Axboe | 0e9f7fa | 2007-03-01 14:05:30 +0100 | [diff] [blame] | 741 | /* |
| 742 | * Option match, levenshtein distance. Handy for not quite remembering what |
| 743 | * the option name is. |
| 744 | */ |
| 745 | static int string_distance(const char *s1, const char *s2) |
| 746 | { |
| 747 | unsigned int s1_len = strlen(s1); |
| 748 | unsigned int s2_len = strlen(s2); |
| 749 | unsigned int *p, *q, *r; |
| 750 | unsigned int i, j; |
| 751 | |
| 752 | p = malloc(sizeof(unsigned int) * (s2_len + 1)); |
| 753 | q = malloc(sizeof(unsigned int) * (s2_len + 1)); |
| 754 | |
| 755 | p[0] = 0; |
| 756 | for (i = 1; i <= s2_len; i++) |
| 757 | p[i] = p[i - 1] + 1; |
| 758 | |
| 759 | for (i = 1; i <= s1_len; i++) { |
| 760 | q[0] = p[0] + 1; |
| 761 | for (j = 1; j <= s2_len; j++) { |
| 762 | unsigned int sub = p[j - 1]; |
| 763 | |
| 764 | if (s1[i - 1] != s2[j - 1]) |
| 765 | sub++; |
| 766 | |
| 767 | q[j] = min(p[j] + 1, min(q[j - 1] + 1, sub)); |
| 768 | } |
| 769 | r = p; |
| 770 | p = q; |
| 771 | q = r; |
| 772 | } |
| 773 | |
| 774 | i = p[s2_len]; |
| 775 | free(p); |
| 776 | free(q); |
| 777 | return i; |
| 778 | } |
| 779 | |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 780 | static struct fio_option *find_child(struct fio_option *options, |
| 781 | struct fio_option *o) |
| 782 | { |
| 783 | struct fio_option *__o; |
| 784 | |
Jens Axboe | fdf2874 | 2007-07-31 23:06:09 +0200 | [diff] [blame] | 785 | for (__o = options + 1; __o->name; __o++) |
| 786 | if (__o->parent && !strcmp(__o->parent, o->name)) |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 787 | return __o; |
| 788 | |
| 789 | return NULL; |
| 790 | } |
| 791 | |
Jens Axboe | 323d911 | 2008-03-01 15:12:14 +0100 | [diff] [blame] | 792 | static void __print_option(struct fio_option *o, struct fio_option *org, |
| 793 | int level) |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 794 | { |
| 795 | char name[256], *p; |
Jens Axboe | 323d911 | 2008-03-01 15:12:14 +0100 | [diff] [blame] | 796 | int depth; |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 797 | |
| 798 | if (!o) |
| 799 | return; |
Jens Axboe | ef9aff5 | 2007-07-31 22:56:53 +0200 | [diff] [blame] | 800 | if (!org) |
| 801 | org = o; |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 802 | |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 803 | p = name; |
Jens Axboe | 323d911 | 2008-03-01 15:12:14 +0100 | [diff] [blame] | 804 | depth = level; |
| 805 | while (depth--) |
| 806 | p += sprintf(p, "%s", " "); |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 807 | |
| 808 | sprintf(p, "%s", o->name); |
| 809 | |
| 810 | printf("%-24s: %s\n", name, o->help); |
Jens Axboe | 323d911 | 2008-03-01 15:12:14 +0100 | [diff] [blame] | 811 | } |
| 812 | |
| 813 | static void print_option(struct fio_option *o) |
| 814 | { |
| 815 | struct fio_option *parent; |
| 816 | struct fio_option *__o; |
| 817 | unsigned int printed; |
| 818 | unsigned int level; |
| 819 | |
| 820 | __print_option(o, NULL, 0); |
| 821 | parent = o; |
| 822 | level = 0; |
| 823 | do { |
| 824 | level++; |
| 825 | printed = 0; |
| 826 | |
| 827 | while ((__o = find_child(o, parent)) != NULL) { |
| 828 | __print_option(__o, o, level); |
| 829 | o = __o; |
| 830 | printed++; |
| 831 | } |
| 832 | |
| 833 | parent = o; |
| 834 | } while (printed); |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 835 | } |
| 836 | |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 837 | int show_cmd_help(struct fio_option *options, const char *name) |
Jens Axboe | 0e9f7fa | 2007-03-01 14:05:30 +0100 | [diff] [blame] | 838 | { |
| 839 | struct fio_option *o, *closest; |
Jens Axboe | d091d09 | 2010-04-01 19:56:23 +0200 | [diff] [blame] | 840 | unsigned int best_dist = -1U; |
Jens Axboe | 29fc6af | 2007-01-09 21:22:02 +0100 | [diff] [blame] | 841 | int found = 0; |
Jens Axboe | 320beef | 2007-03-01 10:44:12 +0100 | [diff] [blame] | 842 | int show_all = 0; |
| 843 | |
| 844 | if (!name || !strcmp(name, "all")) |
| 845 | show_all = 1; |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 846 | |
Jens Axboe | 0e9f7fa | 2007-03-01 14:05:30 +0100 | [diff] [blame] | 847 | closest = NULL; |
| 848 | best_dist = -1; |
Jens Axboe | 4945ba1 | 2007-01-11 14:36:56 +0100 | [diff] [blame] | 849 | for (o = &options[0]; o->name; o++) { |
Jens Axboe | 320beef | 2007-03-01 10:44:12 +0100 | [diff] [blame] | 850 | int match = 0; |
| 851 | |
Jens Axboe | 15ca150 | 2008-04-07 09:26:02 +0200 | [diff] [blame] | 852 | if (o->type == FIO_OPT_DEPRECATED) |
| 853 | continue; |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 854 | if (!exec_profile && o->prof_name) |
| 855 | continue; |
Jens Axboe | 15ca150 | 2008-04-07 09:26:02 +0200 | [diff] [blame] | 856 | |
Jens Axboe | 0e9f7fa | 2007-03-01 14:05:30 +0100 | [diff] [blame] | 857 | if (name) { |
Jens Axboe | 7f9348f | 2007-03-15 14:09:28 +0100 | [diff] [blame] | 858 | if (!strcmp(name, o->name) || |
| 859 | (o->alias && !strcmp(name, o->alias))) |
Jens Axboe | 0e9f7fa | 2007-03-01 14:05:30 +0100 | [diff] [blame] | 860 | match = 1; |
| 861 | else { |
| 862 | unsigned int dist; |
| 863 | |
| 864 | dist = string_distance(name, o->name); |
| 865 | if (dist < best_dist) { |
| 866 | best_dist = dist; |
| 867 | closest = o; |
| 868 | } |
| 869 | } |
| 870 | } |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 871 | |
| 872 | if (show_all || match) { |
Jens Axboe | 29fc6af | 2007-01-09 21:22:02 +0100 | [diff] [blame] | 873 | found = 1; |
Jens Axboe | c167ded | 2007-03-14 13:02:53 +0100 | [diff] [blame] | 874 | if (match) |
Jens Axboe | 07b3232 | 2010-03-05 09:48:44 +0100 | [diff] [blame] | 875 | printf("%20s: %s\n", o->name, o->help); |
Jens Axboe | c167ded | 2007-03-14 13:02:53 +0100 | [diff] [blame] | 876 | if (show_all) { |
Jens Axboe | afdf935 | 2007-07-31 16:14:34 +0200 | [diff] [blame] | 877 | if (!o->parent) |
Jens Axboe | 323d911 | 2008-03-01 15:12:14 +0100 | [diff] [blame] | 878 | print_option(o); |
Jens Axboe | 4945ba1 | 2007-01-11 14:36:56 +0100 | [diff] [blame] | 879 | continue; |
Jens Axboe | c167ded | 2007-03-14 13:02:53 +0100 | [diff] [blame] | 880 | } |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 881 | } |
| 882 | |
Jens Axboe | 70df2f1 | 2007-01-11 14:04:47 +0100 | [diff] [blame] | 883 | if (!match) |
| 884 | continue; |
| 885 | |
Jens Axboe | d447a8c | 2009-07-17 22:26:15 +0200 | [diff] [blame] | 886 | show_option_help(o, stdout); |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 887 | } |
| 888 | |
Jens Axboe | 29fc6af | 2007-01-09 21:22:02 +0100 | [diff] [blame] | 889 | if (found) |
| 890 | return 0; |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 891 | |
Jens Axboe | 0e9f7fa | 2007-03-01 14:05:30 +0100 | [diff] [blame] | 892 | printf("No such command: %s", name); |
Jens Axboe | d091d09 | 2010-04-01 19:56:23 +0200 | [diff] [blame] | 893 | |
| 894 | /* |
| 895 | * Only print an appropriately close option, one where the edit |
| 896 | * distance isn't too big. Otherwise we get crazy matches. |
| 897 | */ |
| 898 | if (closest && best_dist < 3) { |
Jens Axboe | 0e9f7fa | 2007-03-01 14:05:30 +0100 | [diff] [blame] | 899 | printf(" - showing closest match\n"); |
| 900 | printf("%20s: %s\n", closest->name, closest->help); |
Jens Axboe | d447a8c | 2009-07-17 22:26:15 +0200 | [diff] [blame] | 901 | show_option_help(closest, stdout); |
Jens Axboe | 0e9f7fa | 2007-03-01 14:05:30 +0100 | [diff] [blame] | 902 | } else |
| 903 | printf("\n"); |
| 904 | |
Jens Axboe | 29fc6af | 2007-01-09 21:22:02 +0100 | [diff] [blame] | 905 | return 1; |
Jens Axboe | fd28ca4 | 2007-01-09 21:20:13 +0100 | [diff] [blame] | 906 | } |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 907 | |
Jens Axboe | 13335dd | 2007-01-10 13:14:02 +0100 | [diff] [blame] | 908 | /* |
| 909 | * Handle parsing of default parameters. |
| 910 | */ |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 911 | void fill_default_options(void *data, struct fio_option *options) |
| 912 | { |
Jens Axboe | 4945ba1 | 2007-01-11 14:36:56 +0100 | [diff] [blame] | 913 | struct fio_option *o; |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 914 | |
Jens Axboe | a3d741f | 2008-02-27 18:32:33 +0100 | [diff] [blame] | 915 | dprint(FD_PARSE, "filling default options\n"); |
| 916 | |
Jens Axboe | 4945ba1 | 2007-01-11 14:36:56 +0100 | [diff] [blame] | 917 | for (o = &options[0]; o->name; o++) |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 918 | if (o->def) |
| 919 | handle_option(o, o->def, data); |
Jens Axboe | ee73849 | 2007-01-10 11:23:16 +0100 | [diff] [blame] | 920 | } |
Jens Axboe | 13335dd | 2007-01-10 13:14:02 +0100 | [diff] [blame] | 921 | |
Jens Axboe | 9f988e2 | 2010-03-04 10:42:38 +0100 | [diff] [blame] | 922 | void option_init(struct fio_option *o) |
| 923 | { |
| 924 | if (o->type == FIO_OPT_DEPRECATED) |
| 925 | return; |
| 926 | if (o->type == FIO_OPT_BOOL) { |
| 927 | o->minval = 0; |
| 928 | o->maxval = 1; |
| 929 | } |
| 930 | if (o->type == FIO_OPT_STR_SET && o->def) { |
| 931 | fprintf(stderr, "Option %s: string set option with" |
| 932 | " default will always be true\n", o->name); |
| 933 | } |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 934 | if (!o->cb && (!o->off1 && !o->roff1)) { |
Jens Axboe | 9f988e2 | 2010-03-04 10:42:38 +0100 | [diff] [blame] | 935 | fprintf(stderr, "Option %s: neither cb nor offset given\n", |
| 936 | o->name); |
| 937 | } |
Jens Axboe | 5f6ddf1 | 2010-03-09 20:40:44 +0100 | [diff] [blame] | 938 | if (o->type == FIO_OPT_STR || o->type == FIO_OPT_STR_STORE || |
| 939 | o->type == FIO_OPT_STR_MULTI) |
Jens Axboe | 9f988e2 | 2010-03-04 10:42:38 +0100 | [diff] [blame] | 940 | return; |
Jens Axboe | e2de69d | 2010-03-04 14:05:48 +0100 | [diff] [blame] | 941 | if (o->cb && ((o->off1 || o->off2 || o->off3 || o->off4) || |
| 942 | (o->roff1 || o->roff2 || o->roff3 || o->roff4))) { |
Jens Axboe | 9f988e2 | 2010-03-04 10:42:38 +0100 | [diff] [blame] | 943 | fprintf(stderr, "Option %s: both cb and offset given\n", |
| 944 | o->name); |
| 945 | } |
| 946 | } |
| 947 | |
Jens Axboe | 13335dd | 2007-01-10 13:14:02 +0100 | [diff] [blame] | 948 | /* |
| 949 | * Sanitize the options structure. For now it just sets min/max for bool |
Jens Axboe | 5b0a888 | 2007-01-11 14:40:27 +0100 | [diff] [blame] | 950 | * values and whether both callback and offsets are given. |
Jens Axboe | 13335dd | 2007-01-10 13:14:02 +0100 | [diff] [blame] | 951 | */ |
| 952 | void options_init(struct fio_option *options) |
| 953 | { |
Jens Axboe | 4945ba1 | 2007-01-11 14:36:56 +0100 | [diff] [blame] | 954 | struct fio_option *o; |
Jens Axboe | 13335dd | 2007-01-10 13:14:02 +0100 | [diff] [blame] | 955 | |
Jens Axboe | a3d741f | 2008-02-27 18:32:33 +0100 | [diff] [blame] | 956 | dprint(FD_PARSE, "init options\n"); |
| 957 | |
Jens Axboe | 9f988e2 | 2010-03-04 10:42:38 +0100 | [diff] [blame] | 958 | for (o = &options[0]; o->name; o++) |
| 959 | option_init(o); |
Jens Axboe | 13335dd | 2007-01-10 13:14:02 +0100 | [diff] [blame] | 960 | } |