+static void add_to_lopt(struct option *lopt, struct fio_option *o,
+ const char *name, int val)
+{
+ lopt->name = (char *) name;
+ lopt->val = val;
+ if (o->type == FIO_OPT_STR_SET)
+ lopt->has_arg = no_argument;
+ else
+ lopt->has_arg = required_argument;
+}
+
+static void options_to_lopts(struct fio_option *opts,
+ struct option *long_options,
+ int i, int option_type)
+{
+ struct fio_option *o = &opts[0];
+ while (o->name) {
+ add_to_lopt(&long_options[i], o, o->name, option_type);
+ if (o->alias) {
+ i++;
+ add_to_lopt(&long_options[i], o, o->alias, option_type);
+ }
+
+ i++;
+ o++;
+ assert(i < FIO_NR_OPTIONS);
+ }
+}
+
+void fio_options_set_ioengine_opts(struct option *long_options,
+ struct thread_data *td)
+{
+ unsigned int i;
+
+ i = 0;
+ while (long_options[i].name) {
+ if (long_options[i].val == FIO_GETOPT_IOENGINE) {
+ memset(&long_options[i], 0, sizeof(*long_options));
+ break;
+ }
+ i++;
+ }
+
+ /*
+ * Just clear out the prior ioengine options.
+ */
+ if (!td || !td->eo)
+ return;
+
+ options_to_lopts(td->io_ops->options, long_options, i,
+ FIO_GETOPT_IOENGINE);
+}
+