From f9633d729f0d2067c3f79b5e82e7129de1e650cd Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 6 Sep 2013 09:59:56 -0600 Subject: [PATCH] Fix problem with --showcmd and callbacks that verify David reports: I'm using "fio --showcmd file.job" to convert a script to plain commandline arguments and this fails if the directory specified in job file does not exist. While this has to be an error if the job is being executed, it should not be in context of --showcmd. To reproduce: $ cat job.fio [global] directory=/x $ fio --showcmd job.fio fio: /x is not a directory fio: failed parsing directory=/x fio: job global dropped Expected output: fio --directory=/x Signed-off-by: Jens Axboe --- fio.h | 1 + init.c | 10 ++++++++-- options.c | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/fio.h b/fio.h index e7d5c27c..0d7fbeb9 100644 --- a/fio.h +++ b/fio.h @@ -420,6 +420,7 @@ extern void td_fill_rand_seeds(struct thread_data *); extern void add_job_opts(const char **, int); extern char *num2str(unsigned long, int, int, int, int); extern int ioengine_load(struct thread_data *); +extern int parse_dryrun(void); extern uintptr_t page_mask; extern uintptr_t page_size; diff --git a/init.c b/init.c index 1afc3417..bf54e953 100644 --- a/init.c +++ b/init.c @@ -915,6 +915,12 @@ static char *make_filename(char *buf, struct thread_options *o, return buf; } + +int parse_dryrun(void) +{ + return dump_cmdline || parse_only; +} + /* * Adds a job to the list of things todo. Sanitizes the various options * to make sure we don't have conflicts, and initializes various @@ -939,7 +945,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num, /* * if we are just dumping the output command line, don't add the job */ - if (dump_cmdline || parse_only) { + if (parse_dryrun()) { put_job(td); return 0; } @@ -1944,7 +1950,7 @@ int parse_options(int argc, char *argv[]) fio_options_free(&def_thread); if (!thread_number) { - if (dump_cmdline || parse_only) + if (parse_dryrun()) return 0; if (exec_profile) return 0; diff --git a/options.c b/options.c index caf89d3c..a20b5c55 100644 --- a/options.c +++ b/options.c @@ -777,6 +777,9 @@ static int str_directory_cb(void *data, const char fio_unused *str) struct thread_data *td = data; struct stat sb; + if (parse_dryrun()) + return 0; + if (lstat(td->o.directory, &sb) < 0) { int ret = errno; -- 2.25.1