Fix problem with --showcmd and callbacks that verify
authorJens Axboe <axboe@kernel.dk>
Fri, 6 Sep 2013 15:59:56 +0000 (09:59 -0600)
committerJens Axboe <axboe@kernel.dk>
Fri, 6 Sep 2013 15:59:56 +0000 (09:59 -0600)
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 <axboe@kernel.dk>
fio.h
init.c
options.c

diff --git a/fio.h b/fio.h
index e7d5c27c8420de2fae7b25ed784e96e61336869e..0d7fbeb9b734980e4883d5feff3dde2a6e5ba9e0 100644 (file)
--- 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 1afc3417140c756aa81345ddfb35446b4b7fe978..bf54e9537bb8a7505653cfb48779ca8bfb41d9f0 100644 (file)
--- 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;
index caf89d3c64fccd29668c0b49814169fb784f523f..a20b5c5579ced11908a0074d29724ea203722094 100644 (file)
--- 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;