Skip to content

Commit

Permalink
init: escape description option string
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Nov 27, 2013
1 parent ff52be3 commit 292cc47
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 19 deletions.
2 changes: 1 addition & 1 deletion fio.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ extern int parse_cmd_line(int, char **, int);
extern int fio_backend(void);
extern void reset_fio_state(void);
extern void clear_io_state(struct thread_data *);
extern int fio_options_parse(struct thread_data *, char **, int);
extern int fio_options_parse(struct thread_data *, char **, int, int);
extern void fio_keywords_init(void);
extern int fio_cmd_option_parse(struct thread_data *, const char *, char *);
extern int fio_cmd_ioengine_option_parse(struct thread_data *, const char *, char *);
Expand Down
14 changes: 5 additions & 9 deletions init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1146,9 +1146,9 @@ void add_job_opts(const char **o, int client_type)
td = get_new_job(0, td_parent, 0);
}
if (in_global)
fio_options_parse(td_parent, (char **) &o[i], 1);
fio_options_parse(td_parent, (char **) &o[i], 1, 0);
else
fio_options_parse(td, (char **) &o[i], 1);
fio_options_parse(td, (char **) &o[i], 1, 0);
i++;
}

Expand Down Expand Up @@ -1329,14 +1329,10 @@ int parse_jobs_ini(char *file, int is_buf, int stonewall_flag, int type)
num_opts++;
}

ret = fio_options_parse(td, opts, num_opts);
if (!ret) {
if (dump_cmdline)
for (i = 0; i < num_opts; i++)
log_info("--%s ", opts[i]);

ret = fio_options_parse(td, opts, num_opts, dump_cmdline);
if (!ret)
ret = add_job(td, name, 0, 0, type);
} else {
else {
log_err("fio: job %s dropped\n", name);
put_job(td);
}
Expand Down
7 changes: 4 additions & 3 deletions options.c
Original file line number Diff line number Diff line change
Expand Up @@ -3550,7 +3550,8 @@ static char **dup_and_sub_options(char **opts, int num_opts)
return opts_copy;
}

int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
int fio_options_parse(struct thread_data *td, char **opts, int num_opts,
int dump_cmdline)
{
int i, ret, unknown;
char **opts_copy;
Expand All @@ -3561,7 +3562,7 @@ int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
struct fio_option *o;
int newret = parse_option(opts_copy[i], opts[i], fio_options,
&o, td);
&o, td, dump_cmdline);

if (opts_copy[i]) {
if (newret && !o) {
Expand Down Expand Up @@ -3590,7 +3591,7 @@ int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
if (td->eo)
newret = parse_option(opts_copy[i], opts[i],
td->io_ops->options, &o,
td->eo);
td->eo, dump_cmdline);

ret |= newret;
if (!o)
Expand Down
25 changes: 20 additions & 5 deletions parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,8 @@ int parse_cmd_option(const char *opt, const char *val,
}

int parse_option(char *opt, const char *input,
struct fio_option *options, struct fio_option **o, void *data)
struct fio_option *options, struct fio_option **o, void *data,
int dump_cmdline)
{
char *post;

Expand All @@ -965,11 +966,25 @@ int parse_option(char *opt, const char *input,
return 1;
}

if (!handle_option(*o, post, data))
return 0;
if (handle_option(*o, post, data)) {
log_err("fio: failed parsing %s\n", input);
return 1;
}

log_err("fio: failed parsing %s\n", input);
return 1;
if (dump_cmdline) {
const char *delim;

if (!strcmp("description", (*o)->name))
delim = "\"";
else
delim = "";

log_info("--%s%s", (*o)->name, post ? "" : " ");
if (post)
log_info("=%s%s%s ", delim, post, delim);
}

return 0;
}

/*
Expand Down
2 changes: 1 addition & 1 deletion parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct fio_option {

typedef int (str_cb_fn)(void *, char *);

extern int parse_option(char *, const char *, struct fio_option *, struct fio_option **, void *);
extern int parse_option(char *, const char *, struct fio_option *, struct fio_option **, void *, int);
extern void sort_options(char **, struct fio_option *, int);
extern int parse_cmd_option(const char *t, const char *l, struct fio_option *, void *);
extern int show_cmd_help(struct fio_option *, const char *);
Expand Down

0 comments on commit 292cc47

Please sign in to comment.