nr_files conflict with filename
[fio.git] / init.c
diff --git a/init.c b/init.c
index f3c756e960dc4c33afe8a3503236921311b1baf6..1cb384570200d5d575201de47da48b1bc08ef92b 100644 (file)
--- a/init.c
+++ b/init.c
@@ -752,6 +752,11 @@ static void fixup_options(struct thread_data *td)
        if (td->iodepth_batch > td->iodepth || !td->iodepth_batch)
                td->iodepth_batch = td->iodepth;
 
+       if (!td->nr_files)
+               td->nr_files = td->files_index;
+       else if (td->nr_files > td->files_index)
+               td->nr_files = td->files_index;
+
        if (td->open_files > td->nr_files || !td->open_files)
                td->open_files = td->nr_files;
 }
@@ -830,9 +835,13 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
        if (!td->filename) {
                td->filename = strdup(jobname);
 
-               for (i = 0; i < td->nr_files; i++) {
-                       sprintf(fname, "%s.%d.%d", td->filename, td->thread_number, i);
-                       add_file(td, fname);
+               if (td->nr_files == 1)
+                       add_file(td, td->filename);
+               else {
+                       for (i = 0; i < td->nr_files; i++) {
+                               sprintf(fname, "%s.%d.%d", td->filename, td->thread_number, i);
+                               add_file(td, fname);
+                       }
                }
        }
 
@@ -843,9 +852,6 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
                        sprintf(fname, "%s/%s", td->directory, f->file_name);
                        f->file_name = strdup(fname);
                }
-
-               f->file_size = td->total_file_size / td->nr_files;
-               f->file_offset = td->start_offset;
        }
                
        td->mutex = fio_sem_init(0);
@@ -1101,12 +1107,20 @@ static int str_fst_cb(void *data, const char *str)
 static int str_filename_cb(void *data, const char *input)
 {
        struct thread_data *td = data;
-       char *fname, *str;
+       char *fname, *str, *p;
 
-       str = strdup(input);
-       while ((fname = strsep(&str, ":")) != NULL)
+       p = str = strdup(input);
+
+       strip_blank_front(&str);
+       strip_blank_end(str);
+
+       while ((fname = strsep(&str, ":")) != NULL) {
+               if (!strlen(fname))
+                       break;
                add_file(td, fname);
+       }
 
+       free(p);
        return 0;
 }