File name generation fix
authorJens Axboe <jens.axboe@oracle.com>
Mon, 12 Mar 2007 11:40:26 +0000 (12:40 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Mon, 12 Mar 2007 11:40:26 +0000 (12:40 +0100)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
init.c

diff --git a/init.c b/init.c
index eee23359afc68d209366d7f95cb1c5242de111bf..e88ff9b178a56de8d95285d5251225134dc20d0e 100644 (file)
--- a/init.c
+++ b/init.c
@@ -804,6 +804,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
        int numjobs, i;
        struct fio_file *f;
        const char *engine;
        int numjobs, i;
        struct fio_file *f;
        const char *engine;
+       int fn_given;
 
        /*
         * the def_thread is just for options, it's not a real job
 
        /*
         * the def_thread is just for options, it's not a real job
@@ -826,6 +827,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
        if (td->odirect)
                td->io_ops->flags |= FIO_RAWIO;
 
        if (td->odirect)
                td->io_ops->flags |= FIO_RAWIO;
 
+       fn_given = (int) td->filename;
        if (!td->filename)
                td->filename = strdup(jobname);
 
        if (!td->filename)
                td->filename = strdup(jobname);
 
@@ -844,7 +846,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
        else
                td->nr_uniq_files = td->open_files;
 
        else
                td->nr_uniq_files = td->open_files;
 
-       if (td->filetype == FIO_TYPE_FILE || td->filename) {
+       if (td->filetype == FIO_TYPE_FILE) {
                char tmp[PATH_MAX];
                int len = 0;
 
                char tmp[PATH_MAX];
                int len = 0;
 
@@ -867,10 +869,10 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
                        memset(f, 0, sizeof(*f));
                        f->fd = -1;
 
                        memset(f, 0, sizeof(*f));
                        f->fd = -1;
 
-                       if (td->filename)
+                       if (fn_given)
                                sprintf(tmp + len, "%s", td->filename);
                        else
                                sprintf(tmp + len, "%s", td->filename);
                        else
-                               sprintf(tmp + len, "%s.%d.%d", jobname, td->thread_number, i);
+                               sprintf(tmp + len, "%s.%d.%d", td->filename, td->thread_number, i);
                        f->file_name = strdup(tmp);
                }
        } else {
                        f->file_name = strdup(tmp);
                }
        } else {